*** This class provides Binary Compatibility only, not Source Compatibility ***
Class ViewerEntry
- All Implemented Interfaces:
com.sas.entities.EntityKeyInterface,com.sas.io.InputStreamProviderInterface,com.sas.io.ReaderProviderInterface,EntryInterface,ViewerEntryInterface,Serializable,Remote
The viewer is not used for rendering purposes in the Java Publishing Framework, but viewer entries can be published and retrieved.
See Constructing a Result Package to Publish for an example of how this class is used.
- Since:
- 1.0
- See Also:
-
Field Summary
Fields inherited from class com.sas.services.publish.AbstractEntry
BINARY_COMPAT_VERSION, CATALOG_COMPAT_VERSION, DATASET_COMPAT_VERSION, DEFAULT_ENTRY_VERSION, HTML_COMPAT_VERSION, MDDB_COMPAT_VERSION, NESTEDPACKAGE_COMPAT_VERSION, REFERENCE_COMPAT_VERSION, SQLVIEW_COMPAT_VERSION, TEXT_COMPAT_VERSION, VERSION_94_EXTENDED_ATTRIBUTES, VIEWER_COMPAT_VERSIONFields inherited from class java.rmi.server.RemoteObject
refFields inherited from interface com.sas.services.publish.ViewerEntryInterface
HTML_VIEWER, TEXT_VIEWER -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates a default instance.ViewerEntry(File file, int viewerType) Creates a viewer entry.ViewerEntry(InputStream inputStream, String name, int viewerType) Creates a viewer entry.protectedViewerEntry(Class theClass) Creates a new text file entry exporting a remote object using RMI socket factories appropriate for the specified class. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidRemove any temporary files needed for inputstream re-use and mark this entry as closed.voidConsume and close the input stream provided on the constructor.protected voidfinalize()At finalize time, cleanup temporary files if necessary.StringReturns the encoding of the viewer.InputStreamGets the input stream for this binary file entry.InputStreamgetInputStream(Object streamID) Deprecated.StringReturns the MIME type associated with this viewer entry.StringgetName()Returns the name of the file.ReaderGets reader for the text file entry.ReadergetReader(Object readerID) Deprecated.UsegetReader()which now supports remote readers.com.sas.io.RemoteInputStreamInterfacegetRemoteInputStream(Object streamID) Deprecated.UsegetInputStream()which now supports remote input streams.com.sas.io.RemoteReaderInterfacegetRemoteReader(Object readerID) Deprecated.UsegetReader()which now supports remote readers.intReturns the type of viewer, HTML or text.ObjectDeprecated.this method no longer needed as getInputStream() will return an input stream that can be used in a remote environmentObjectDeprecated.this method no longer needed as getReader() will return a reader that can be used in a remote environmentvoidsetEncoding(String encoding) Sets the viewer encoding.voidsetMIMEType(String mimeType) Sets the MIME associated with this file entry.Methods inherited from class com.sas.services.publish.AbstractEntry
getDescription, getEntityKey, getNameValuePairs, getURL, isClosed, isReadOnly, sameEntity, setClosed, setDescription, setEntityKey, setNameValuePairs, setRead, throwExceptionIfClosedMethods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, exportObject, exportObject, unexportObjectMethods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLogMethods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStubMethods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.sas.entities.EntityKeyInterface
getEntityKey, sameEntity, setEntityKeyMethods inherited from interface com.sas.services.publish.EntryInterface
getDescription, getNameValuePairs, getURL, isReadOnly, setDescription, setNameValuePairs
-
Constructor Details
-
ViewerEntry
public ViewerEntry() throws RemoteExceptionCreates a default instance. This constructor should not be used and is only provided since the compiler was previously providing a default public constructor. UseViewerEntry(File file, int viewerType)orViewerEntry(InputStream inputStream, String name, int viewerType)instead.- Throws:
RemoteException- If a network anomaly is encountered.
-
ViewerEntry
protected ViewerEntry(Class theClass) throws RemoteException Creates a new text file entry exporting a remote object using RMI socket factories appropriate for the specified class.- Parameters:
theClass- The class to use when determine which RMI socket factories are to be used when exporting a remote object.- Throws:
RemoteException- If a network anomaly is encountered.
-
ViewerEntry
public ViewerEntry(File file, int viewerType) throws IllegalArgumentException, RemoteException Creates a viewer entry. When the viewer file is published, the file name is used as the name. If a different name is preferred, use the constructor that takes the input stream and the name of the entry.- Parameters:
file- The viewer file.viewerType- The type of viewer. Valid types includeHTML_VIEWERorTEXT_VIEWER.There is no default MIME type. To set the MIME type for the entry, use
setMIMEType(java.lang.String).- Throws:
IllegalArgumentException- If anullfile or an an invalid viewer type is specified.RemoteException- If a network anomaly is encountered.
-
ViewerEntry
public ViewerEntry(InputStream inputStream, String name, int viewerType) throws IllegalArgumentException, RemoteException Creates a viewer entry. When the viewer file is published, the input stream will be consumed until end-of-file.- Parameters:
inputStream- The input stream of the viewer file.name- The name of the viewer entry. This name will be used as the name of the entry when publishing the package.viewerType- The type of viewer. Valid types includeHTML_VIEWERorTEXT_VIEWER.There is no default MIME type. To set the MIME type for the entry, use
setMIMEType(java.lang.String).- Throws:
IllegalArgumentException- If anullinput stream, anullname, or an invalid viewer type is specified.RemoteException- If a network anomaly is encountered.
-
-
Method Details
-
getName
Returns the name of the file.- Specified by:
getNamein interfaceViewerEntryInterface- Returns:
StringThe name of the file.- Throws:
IllegalStateException- if the result package containing this entry has already been closed.TransportException- If the transport encounters an error getting the name of the file.RemoteException- If a network anomaly is encountered.
-
getMIMEType
Returns the MIME type associated with this viewer entry. The user-specified MIME type is assigned when the viewer entry is published.- Specified by:
getMIMETypein interfaceViewerEntryInterface- Returns:
StringThe MIME type associated with this file; can benull.- Throws:
IllegalStateException- if the result package containing this entry has already been closed.TransportException- If the transport encounters an error getting the MIME type.RemoteException- If a network anomaly is encountered.
-
setMIMEType
public void setMIMEType(String mimeType) throws IllegalStateException, RemoteException Sets the MIME associated with this file entry.- Specified by:
setMIMETypein interfaceViewerEntryInterface- Parameters:
mimeType- The MIME type associated with this file entry.- Throws:
IllegalStateException- If the entry is read only or if the package containing this entry has already been closed.RemoteException- If a network anomaly is encountered.
-
getViewerType
Returns the type of viewer, HTML or text.- Specified by:
getViewerTypein interfaceViewerEntryInterface- Returns:
intThe type of viewer. Supported viewer types includeHTML_VIEWERorTEXT_VIEWER.- Throws:
IllegalStateException- if the result package containing this entry has already been closed.TransportException- If the transport encounters an error getting the viewer type.RemoteException- If a network anomaly is encountered
-
getEncoding
public String getEncoding() throws RemoteException, IllegalStateExceptionReturns the encoding of the viewer. If this is a text viewer, the text viewer may be in a different encoding. This method provides the text encoding, so that it can be used when creating readers to read the text viewer. If this is an HTML viewer, this identifies the encoding of the HTML file.- Specified by:
getEncodingin interfaceViewerEntryInterface- Returns:
StringThe encoding of the viewer; can be null.- Throws:
IllegalStateException- if the result package containing this entry has already been closed.RemoteException- If a network anomaly is encountered.
-
setEncoding
public void setEncoding(String encoding) throws IllegalStateException, RemoteException Sets the viewer encoding.If this is a text viewer, the encoding is used when constructing the Reader that is returned by getReader and getRemoteReader, and it is used to publish the viewer.
If this is an HTML viewer, the encoding of the HTML viewer is published as metadata along with the viewer entry. When published, the HTML viewer is parsed. If the charset= attribute is specified in the META tag, this encoding value will be used. If not found, the value set using this method will be used. Otherwise, a default encoding will be determined.
- Specified by:
setEncodingin interfaceViewerEntryInterface- Parameters:
encoding- The encoding for this viewer.- Throws:
IllegalStateException- If the entry is read only or if the result package containing this entry has already been closed.RemoteException- If a network anomaly is encountered
-
getInputStream
public InputStream getInputStream() throws RemoteException, IOException, IllegalStateExceptionGets the input stream for this binary file entry.- Specified by:
getInputStreamin interfaceViewerEntryInterface- Returns:
- The input stream that can be used for reading the contents of the binary file entry.
- Throws:
IllegalStateException- if the result package containing this entry has already been closed.IOException- If an error occurs constructing the input stream.RemoteException- If a network anomaly is encountered.
-
getReader
public Reader getReader() throws IllegalStateException, RemoteException, IOExceptionGets reader for the text file entry.- Specified by:
getReaderin interfaceViewerEntryInterface- Returns:
- The reader that can be used for reading the contents of the text file entry.
- Throws:
UnmarshalException- If invoked on a remote object.IllegalStateException- if the result package containing this entry has already been closed.IOException- If an error occurs constructing the input stream.RemoteException- If a network anomaly is encountered.
-
getInputStream
public InputStream getInputStream(Object streamID) throws RemoteException, IOException, IllegalStateException, UnmarshalException Deprecated.UsegetInputStream()which now supports remote input streams.Gets the input stream for this binary file entry. Because input streams are not remotable, this method will throw a RemoteException if it is invoked on a remote object. Distributed applications should utilizegetRemoteInputStream(java.lang.Object)in order to obtain the input stream.- Specified by:
getInputStreamin interfacecom.sas.io.InputStreamProviderInterface- Specified by:
getInputStreamin interfaceViewerEntryInterface- Parameters:
streamID- The stream description should benull; it will be ignored.- Returns:
- The input stream that can be used for reading the contents of the binary file entry.
- Throws:
UnmarshalException- If invoked on a remote object.IllegalStateException- if the result package containing this entry has already been closed.IOException- If an error occurs constructing the input stream.RemoteException- If a network anomaly is encountered.
-
getRemoteInputStream
public com.sas.io.RemoteInputStreamInterface getRemoteInputStream(Object streamID) throws IllegalStateException, com.sas.io.ChainedIOException, RemoteException Deprecated.UsegetInputStream()which now supports remote input streams.Get the HTML viewer as a remote input stream. If your application runs in a distributed environment, it is suggested that you use RemoteInputStream. InputStreams are not remote objects.- Specified by:
getRemoteInputStreamin interfacecom.sas.io.InputStreamProviderInterface- Specified by:
getRemoteInputStreamin interfaceViewerEntryInterface- Parameters:
streamID- The stream description should benull;it will be ignored.- Returns:
RemoteInputStreamThe file as a remote input stream.- Throws:
IllegalStateException- If the package has already been closed or if this is a text viewer. Text viewers support readers. HTML viewers support input streams.com.sas.io.ChainedIOException- If an I/O error occurs obtaining the input stream.RemoteException- If a network anomaly is encountered.
-
getReader
public Reader getReader(Object readerID) throws IllegalStateException, RemoteException, IOException Deprecated.UsegetReader()which now supports remote readers.Gets reader for the text file entry. Because readers are not remotable, this method will throw a RemoteException if it is invoked on a remote object. Distributed applications should utilizegetRemoteReader(java.lang.Object)in order to obtain the reader.- Specified by:
getReaderin interfacecom.sas.io.ReaderProviderInterface- Specified by:
getReaderin interfaceViewerEntryInterface- Parameters:
readerID- The reader description should benull; it will be ignored.- Returns:
- The reader that can be used for reading the contents of the text file entry.
- Throws:
UnmarshalException- If invoked on a remote object.IllegalStateException- if the result package containing this entry has already been closed.IOException- If an error occurs constructing the input stream.RemoteException- If a network anomaly is encountered.
-
getRemoteReader
public com.sas.io.RemoteReaderInterface getRemoteReader(Object readerID) throws IllegalStateException, com.sas.io.ChainedIOException, RemoteException Deprecated.UsegetReader()which now supports remote readers.Get the a remote reader. Because the Reader class is not a remotable, distributed applications should use a RemoteReader.- Specified by:
getRemoteReaderin interfacecom.sas.io.ReaderProviderInterface- Specified by:
getRemoteReaderin interfaceViewerEntryInterface- Parameters:
readerID- The reader description should benull;it will be ignored.- Returns:
RemoteReaderThe file as a remote Reader.- Throws:
IllegalStateException- If the result package has already been closed or of this is an HTML viewer. Text viewers support readers. HTML viewers support input streams.com.sas.io.ChainedIOException- If the transport encounters an I/O error obtaining the reader.RemoteException- If a network anomaly is encountered.
-
hasInputStream
public Object hasInputStream() throws UnmarshalException, RemoteException, IllegalStateExceptionDeprecated.this method no longer needed as getInputStream() will return an input stream that can be used in a remote environmentCheck ifgetInputStream(Object streamID)will succeed. SeegetInputStream(Object streamID)to determine whether this method should be used.- Specified by:
hasInputStreamin interfacecom.sas.io.InputStreamProviderInterface- Specified by:
hasInputStreamin interfaceViewerEntryInterface- Returns:
- non-null if getInputStream(java.lang.Object) would succeed; throws UnmarshalException if it would fail
- Throws:
UnmarshalException- if invoked on a remote objectIllegalStateException- if the result package containing this entry has already been closed.RemoteException- if a network I/O error occurs.
-
hasReader
public Object hasReader() throws UnmarshalException, RemoteException, IllegalStateExceptionDeprecated.this method no longer needed as getReader() will return a reader that can be used in a remote environmentCheck ifgetReader(java.lang.Object)will succeed. SeegetReader(java.lang.Object)to determine whether this method should be used.- Specified by:
hasReaderin interfacecom.sas.io.ReaderProviderInterface- Specified by:
hasReaderin interfaceViewerEntryInterface- Returns:
- non-null if getReader(java.lang.Object) would succeed; throws UnmarshalException if it would fail
- Throws:
UnmarshalException- if invoked on a remote objectRemoteException- if a network I/O error occurs.IllegalStateException- if the result package containing this entry has already been closed.
-
consumeStream
public void consumeStream() throws IOException, RemoteException, IllegalStateExceptionConsume and close the input stream provided on the constructor. If an input stream is provided on the entry's constructor, then it does not get consumed until the package is published. This method may be invoked to force the stream to get consumed and closed immediately instead of waiting until the publish occurs.- Throws:
IllegalStateException- If the package containing this entry is already closed.IOException- If an error occurs constructing the input stream.RemoteException- If a network anomaly is encountered.
-
closeEntry
protected void closeEntry()Remove any temporary files needed for inputstream re-use and mark this entry as closed. -
finalize
protected void finalize() throws ThrowableAt finalize time, cleanup temporary files if necessary.- Overrides:
finalizein classObject- Throws:
Throwable
-
getInputStream()which now supports remote input streams.