*** This class provides Binary Compatibility only, not Source Compatibility ***

Class ViewerEntry

java.lang.Object
java.rmi.server.RemoteObject
java.rmi.server.RemoteServer
java.rmi.server.UnicastRemoteObject
com.sas.services.publish.AbstractEntry
com.sas.services.publish.ViewerEntry
All Implemented Interfaces:
com.sas.entities.EntityKeyInterface, com.sas.io.InputStreamProviderInterface, com.sas.io.ReaderProviderInterface, EntryInterface, ViewerEntryInterface, Serializable, Remote

@SASScope("ALL") @BinaryCompatibilityOnly public class ViewerEntry extends AbstractEntry implements ViewerEntryInterface
Represents a viewer entry that can then be added to a result package for publishing. In the MVA Publishing Framework, a viewer is a custom-written template that contains HTML tags for formatting result set package content for view-only transports, such as e-mail. The viewer file is applied to the package during package publishing. A viewer file is particularly useful for rendering a SAS data set in a tabular format for viewing in e-mail. Also, it is useful for streaming dynamic information in the form of a binary file or a URL for inclusion in an electronic newsletter format.

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:
  • Constructor Details

    • ViewerEntry

      public ViewerEntry() throws RemoteException
      Creates a default instance. This constructor should not be used and is only provided since the compiler was previously providing a default public constructor. Use ViewerEntry(File file, int viewerType)or ViewerEntry(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 include HTML_VIEWERor TEXT_VIEWER.

      There is no default MIME type. To set the MIME type for the entry, use setMIMEType(java.lang.String).

      Throws:
      IllegalArgumentException - If a null file 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 include HTML_VIEWERor TEXT_VIEWER.

      There is no default MIME type. To set the MIME type for the entry, use setMIMEType(java.lang.String).

      Throws:
      IllegalArgumentException - If a null input stream, a null name, or an invalid viewer type is specified.
      RemoteException - If a network anomaly is encountered.
  • Method Details

    • getName

      public String getName() throws RemoteException, TransportException, IllegalStateException
      Returns the name of the file.
      Specified by:
      getName in interface ViewerEntryInterface
      Returns:
      String The 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

      public String getMIMEType() throws RemoteException, TransportException, IllegalStateException
      Returns the MIME type associated with this viewer entry. The user-specified MIME type is assigned when the viewer entry is published.
      Specified by:
      getMIMEType in interface ViewerEntryInterface
      Returns:
      String The MIME type associated with this file; can be null.
      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:
      setMIMEType in interface ViewerEntryInterface
      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

      public int getViewerType() throws RemoteException, TransportException, IllegalStateException
      Returns the type of viewer, HTML or text.
      Specified by:
      getViewerType in interface ViewerEntryInterface
      Returns:
      int The type of viewer. Supported viewer types include HTML_VIEWERor TEXT_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, IllegalStateException
      Returns 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:
      getEncoding in interface ViewerEntryInterface
      Returns:
      String The 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:
      setEncoding in interface ViewerEntryInterface
      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, IllegalStateException
      Gets the input stream for this binary file entry.
      Specified by:
      getInputStream in interface ViewerEntryInterface
      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, IOException
      Gets reader for the text file entry.
      Specified by:
      getReader in interface ViewerEntryInterface
      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.
      Use getInputStream()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 utilize getRemoteInputStream(java.lang.Object)in order to obtain the input stream.
      Specified by:
      getInputStream in interface com.sas.io.InputStreamProviderInterface
      Specified by:
      getInputStream in interface ViewerEntryInterface
      Parameters:
      streamID - The stream description should be null; 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.
      Use getInputStream()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:
      getRemoteInputStream in interface com.sas.io.InputStreamProviderInterface
      Specified by:
      getRemoteInputStream in interface ViewerEntryInterface
      Parameters:
      streamID - The stream description should be null ;it will be ignored.
      Returns:
      RemoteInputStream The 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.
      Use getReader()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 utilize getRemoteReader(java.lang.Object) in order to obtain the reader.
      Specified by:
      getReader in interface com.sas.io.ReaderProviderInterface
      Specified by:
      getReader in interface ViewerEntryInterface
      Parameters:
      readerID - The reader description should be null; 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.
      Use getReader()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:
      getRemoteReader in interface com.sas.io.ReaderProviderInterface
      Specified by:
      getRemoteReader in interface ViewerEntryInterface
      Parameters:
      readerID - The reader description should be null ;it will be ignored.
      Returns:
      RemoteReader The 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, IllegalStateException
      Deprecated.
      this method no longer needed as getInputStream() will return an input stream that can be used in a remote environment
      Check if getInputStream(Object streamID)will succeed. See getInputStream(Object streamID)to determine whether this method should be used.
      Specified by:
      hasInputStream in interface com.sas.io.InputStreamProviderInterface
      Specified by:
      hasInputStream in interface ViewerEntryInterface
      Returns:
      non-null if getInputStream(java.lang.Object) would succeed; throws UnmarshalException if it would fail
      Throws:
      UnmarshalException - if invoked on a remote object
      IllegalStateException - 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, IllegalStateException
      Deprecated.
      this method no longer needed as getReader() will return a reader that can be used in a remote environment
      Check if getReader(java.lang.Object)will succeed. See getReader(java.lang.Object)to determine whether this method should be used.
      Specified by:
      hasReader in interface com.sas.io.ReaderProviderInterface
      Specified by:
      hasReader in interface ViewerEntryInterface
      Returns:
      non-null if getReader(java.lang.Object) would succeed; throws UnmarshalException if it would fail
      Throws:
      UnmarshalException - if invoked on a remote object
      RemoteException - 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, IllegalStateException
      Consume 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 Throwable
      At finalize time, cleanup temporary files if necessary.
      Overrides:
      finalize in class Object
      Throws:
      Throwable