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

com.sas.services.publish
Class HTMLFile

com.sas.services.publish.HTMLFile
All Implemented Interfaces:
com.sas.entities.EntityKeyInterface, com.sas.io.InputStreamProviderInterface, HTMLFileInterface, java.io.Serializable, java.rmi.Remote

public class HTMLFile
implements HTMLFileInterface

The HTMLFileInterface provides a mechanism for setting and getting the attributes of a file contained within an HTML entry.

Files that implement HTMLFileInterface can be inserted into an HTML entry. HTMLEntryInterfaceis a container for various files that implement HTMLFileInterface. Within MVA SAS, the ODS HTML statement generates HTML files. The body file contains the results from the procedure. The contents file is a table of contents that links to the body file. The pages file is a table of pages that links to the body file. The frame file is a frame that displays the table of contents, the table of pages and the body file. The HTML entry provides a way to identify each of these files, and encapsulate them into one entry.

The HTML file is limited to just one role. One file should be designated as the main file for the HTML entry. The main file identifies which file in the HTML entry should be used as the starting point when browsing the HTML entry. The main file will have a role of HTMLFileInterface.MAIN_BODY_FILEor HTMLFileInterface.MAIN_FRAME_FILE. If a frame file exists, it should be designated as the main file; otherwise, the body file should be designated as the main file. All other files are considered companion files. The companion files are any files other than the main HTML file. The companion files can include, body, frame, contents and page files, as well as any miscellaneous files (such as HTML, GIF, JPG) needed by the HTML entry. Supported companion roles include HTMLFileInterface.FRAME_COMPANION,HTMLFileInterface.BODY_COMPANION, HTMLFileInterface.PAGE_COMPANION,HTMLFileInterface.CONTENTS_COMPANION, HTMLFileInterface.MISC_COMPANION.

Since:
1.0
See Also:
HTMLEntry, Serialized Form

Field Summary
 
Fields inherited from interface com.sas.services.publish.HTMLFileInterface
BODY_COMPANION, CONTENTS_COMPANION, FRAME_COMPANION, MAIN_BODY_FILE, MAIN_FRAME_FILE, MISC_COMPANION, PAGE_COMPANION
 
Constructor Summary
  HTMLFile()
          Constructs a default instance.
protected HTMLFile(java.lang.Class theClass)
          Constructs an instance using RMI socket factories appropriate for the specified class.
  HTMLFile(java.io.File file, int role)
          Creates an HTML file or companion file.
  HTMLFile(java.io.InputStream inputStream, java.lang.String name, int role)
          Creates an HTML file or companion file.
 
Method Summary
protected  void closeEntry()
          Remove any temporary files needed for inputstream re-use.
 void consumeStream()
          Consume and close the input stream provided on the constructor.
protected  void finalize()
          At finalize time, cleanup temporary files if necessary.
 java.lang.String getEncoding()
          Returns the encoding for this file.
 java.lang.String getEntityKey()
          Get the unique identifier of this result package or entry.
 java.io.InputStream getInputStream()
          Gets the input stream for this file.
 java.io.InputStream getInputStream(java.lang.Object streamID)
          Deprecated. Use getInputStream()which now supports remote input streams.
 java.lang.String getMIMEType()
          Returns the MIME type of the file.
 java.lang.String getName()
          Returns the name of the file.
 com.sas.io.RemoteInputStreamInterface getRemoteInputStream(java.lang.Object streamID)
          Deprecated. Use getInputStream()which now supports remote input streams.
 int getRole()
          Returns the role of this file within the HTML entry.
 java.lang.String getURL()
          Returns the URL for this file.
 java.lang.Object hasInputStream()
          Deprecated. this method no longer needed as getInputStream() will return an input stream that can be used in a remote environment
 boolean isReadOnly()
          Returns true when the entry is read only.
 boolean sameEntity(com.sas.entities.EntityKeyInterface entity)
           
 void setEncoding(java.lang.String encoding)
          Sets the file encoding.
 void setEntityKey(java.lang.String entityKey)
          Set the unique entity key.
 void setMIMEType(java.lang.String mimeType)
          Sets the MIME type associated with this file; can be null.
 void setURL(java.lang.String url)
          Sets the URL of the file.
 

Constructor Detail

HTMLFile

public HTMLFile()
         throws java.rmi.RemoteException
Constructs a default instance. A public constructor is provided since the compiler has been previosly generating a default public constructor. Use HTMLFile(File file, int role)instead of this constructor.

Throws:
java.rmi.RemoteException - If a network anomaly is encountered.

HTMLFile

protected HTMLFile(java.lang.Class theClass)
            throws java.rmi.RemoteException
Constructs an instance 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:
java.rmi.RemoteException - if unable to export the remote object.

HTMLFile

public HTMLFile(java.io.File file,
                int role)
         throws java.lang.IllegalArgumentException,
                java.rmi.RemoteException
Creates an HTML file or companion file. When the 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.

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

Parameters:
file - The file.
role - The role of the file. Valid roles include HTMLFileInterface.MAIN_BODY_FILE,HTMLFileInterface.MAIN_FRAME_FILE, HTMLFileInterface.BODY_COMPANION,HTMLFileInterface.FRAME_COMPANION, HTMLFileInterface.CONTENTS_COMPANION,HTMLFileInterface.PAGE_COMPANIONor HTMLFileInterface.MISC_COMPANION.
Throws:
java.lang.IllegalArgumentException - If a null file or invalid file type is specified.
java.rmi.RemoteException - If a network anomaly is encountered.

HTMLFile

public HTMLFile(java.io.InputStream inputStream,
                java.lang.String name,
                int role)
         throws java.lang.IllegalArgumentException,
                java.rmi.RemoteException
Creates an HTML file or companion file. When the file is published, the input stream will be consumed until end-of-file.

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

Parameters:
inputStream - The input stream of the HTML or companion file.
name - The name of the HTML or companion file. When an HTML file is published, the URL is used to publish the file, if it was specified. If the URL is not specified, this name will be used as the name of the file.
role - The role of the file. Valid roles include HTMLFileInterface.MAIN_BODY_FILE,HTMLFileInterface.MAIN_FRAME_FILE, HTMLFileInterface.BODY_COMPANION,HTMLFileInterface.FRAME_COMPANION, HTMLFileInterface.CONTENTS_COMPANION,HTMLFileInterface.PAGE_COMPANIONor HTMLFileInterface.MISC_COMPANION.
Throws:
java.lang.IllegalArgumentException - If a null input stream, a null name, or an invalid file type is specified.
java.rmi.RemoteException - If a network anomaly is encountered.
Method Detail

getURL

public java.lang.String getURL()
                        throws java.rmi.RemoteException
Returns the URL for this file.

Specified by:
getURL in interface HTMLFileInterface
Returns:
String The URL for the file.
Throws:
java.rmi.RemoteException - If a network anomaly is encountered.

setURL

public void setURL(java.lang.String url)
            throws java.lang.IllegalStateException,
                   java.rmi.RemoteException
Sets the URL of the file.

Specified by:
setURL in interface HTMLFileInterface
Parameters:
url - The URL for the file.
Throws:
java.lang.IllegalStateException - If the entry is read only.
java.rmi.RemoteException - If a network anomaly is encountered.

getEncoding

public java.lang.String getEncoding()
                             throws java.rmi.RemoteException
Returns the encoding for this file.

Specified by:
getEncoding in interface HTMLFileInterface
Returns:
String The encoding for this file.
Throws:
java.rmi.RemoteException - If a network anomaly is encountered.

setEncoding

public void setEncoding(java.lang.String encoding)
                 throws java.lang.IllegalStateException,
                        java.rmi.RemoteException
Sets the file encoding.

Specified by:
setEncoding in interface HTMLFileInterface
Parameters:
encoding - The encoding of the file.
Throws:
java.lang.IllegalStateException - If the entry is read only.
java.rmi.RemoteException - If a network anomaly is encountered.

isReadOnly

public boolean isReadOnly()
                   throws java.rmi.RemoteException
Returns true when the entry is read only. Entries are read only if they belong to an existing package that is being retrieved.

Returns:
boolean True if read only; otherwise if this is a new entry/package under construction, false is returned.
Throws:
java.rmi.RemoteException - If a network anomaly is encountered.

getName

public java.lang.String getName()
                         throws java.rmi.RemoteException
Returns the name of the file.

Specified by:
getName in interface HTMLFileInterface
Returns:
String The name of the file.
Throws:
java.rmi.RemoteException - If a network anomaly is encountered.

getMIMEType

public java.lang.String getMIMEType()
Returns the MIME type of the file.

Specified by:
getMIMEType in interface HTMLFileInterface
Returns:
String The MIME type of the file.

setMIMEType

public void setMIMEType(java.lang.String mimeType)
                 throws java.lang.IllegalStateException,
                        java.rmi.RemoteException
Sets the MIME type associated with this file; can be null.

Specified by:
setMIMEType in interface HTMLFileInterface
Parameters:
mimeType - The MIME type associated with this file.
Throws:
java.lang.IllegalStateException - If the entry is read only.
java.rmi.RemoteException - If a network anomaly is encountered.

getRole

public int getRole()
            throws java.rmi.RemoteException
Returns the role of this file within the HTML entry.

Specified by:
getRole in interface HTMLFileInterface
Returns:
int The role of the file. Supported types include BODY_COMPANION, FRAME_COMPANION, CONTENTS_COMPANION, PAGE_COMPANIONand MISC_COMPANION.
Throws:
java.rmi.RemoteException - If a network anomaly is encountered.

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException,
                                          java.rmi.RemoteException
Gets the input stream for this file.

Specified by:
getInputStream in interface HTMLFileInterface
Returns:
The input stream that can be used for reading the contents of the binary file entry.
Throws:
java.io.IOException - If an error occurs constructing the input stream.
java.rmi.RemoteException - If a network anomaly is encountered.

getInputStream

public java.io.InputStream getInputStream(java.lang.Object streamID)
                                   throws java.io.IOException,
                                          java.rmi.RemoteException,
                                          java.rmi.UnmarshalException
Deprecated. Use getInputStream()which now supports remote input streams.

Gets the input stream for this file. 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(Object)in order to obtain the input stream.

Specified by:
getInputStream in interface com.sas.io.InputStreamProviderInterface
Specified by:
getInputStream in interface HTMLFileInterface
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:
java.rmi.UnmarshalException - If invoked on a remote object.
java.io.IOException - If an error occurs constructing the input stream.
java.rmi.RemoteException - If a network anomaly is encountered.

getRemoteInputStream

public com.sas.io.RemoteInputStreamInterface getRemoteInputStream(java.lang.Object streamID)
                                                           throws com.sas.io.ChainedIOException,
                                                                  java.rmi.RemoteException
Deprecated. Use getInputStream()which now supports remote input streams.

Get the a remote input stream.

Specified by:
getRemoteInputStream in interface com.sas.io.InputStreamProviderInterface
Specified by:
getRemoteInputStream in interface HTMLFileInterface
Parameters:
streamID - The stream description should be null ;it will be ignored.
Returns:
RemoteInputStream The file as a remote input stream.
Throws:
com.sas.io.ChainedIOException - If an I/O error occurs obtaining the remote input stream.
java.rmi.RemoteException - If a network anomaly is encountered.

hasInputStream

public java.lang.Object hasInputStream()
                                throws java.rmi.UnmarshalException,
                                       java.rmi.RemoteException
Deprecated. this method no longer needed as getInputStream() will return an input stream that can be used in a remote environment

Check if getInputStream(java.lang.Object)will succeed. See getInputStream(java.lang.Object)to determine whether this method should be used.

Specified by:
hasInputStream in interface com.sas.io.InputStreamProviderInterface
Specified by:
hasInputStream in interface HTMLFileInterface
Returns:
Object non-null if getInputStream(java.lang.Object) would succeed; throws UnmarshalException if it would fail
Throws:
java.rmi.UnmarshalException - if invoked on a remote obejct
java.rmi.RemoteException - if a network anomaly is encountered.
java.lang.IllegalStateException - if this result package has already been closed.

consumeStream

public void consumeStream()
                   throws java.io.IOException,
                          java.rmi.RemoteException,
                          java.lang.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:
java.lang.IllegalStateException - If the package containing this entry is already closed.
java.io.IOException - If an error occurs constructing the input stream.
java.rmi.RemoteException - If a network anomaly is encountered.

getEntityKey

public java.lang.String getEntityKey()
                              throws java.lang.IllegalStateException,
                                     java.rmi.RemoteException
Get the unique identifier of this result package or entry.

Specified by:
getEntityKey in interface com.sas.entities.EntityKeyInterface
Returns:
String Throws:
java.rmi.RemoteException - If a network anomaly is encountered.
java.lang.IllegalStateException

sameEntity

public boolean sameEntity(com.sas.entities.EntityKeyInterface entity)
                   throws java.rmi.RemoteException
Specified by:
sameEntity in interface com.sas.entities.EntityKeyInterface
Throws:
java.rmi.RemoteException

setEntityKey

public void setEntityKey(java.lang.String entityKey)
                  throws java.rmi.RemoteException,
                         java.lang.IllegalStateException
Set the unique entity key. The entity key for the result package or entry cannot be changed. This method will throw an IllegalStateException.

Specified by:
setEntityKey in interface com.sas.entities.EntityKeyInterface
Parameters:
entityKey - Unique entity key.
Throws:
java.lang.IllegalStateException - The unique entity key for a result package or entry cannot be changed.
java.rmi.RemoteException

closeEntry

protected void closeEntry()
Remove any temporary files needed for inputstream re-use.


finalize

protected void finalize()
                 throws java.lang.Throwable
At finalize time, cleanup temporary files if necessary.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

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




Copyright © 2009 SAS Institute Inc. All Rights Reserved.