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

com.sas.services.publish
Class BinaryFileEntry

com.sas.services.publish.BinaryFileEntry
All Implemented Interfaces:
com.sas.entities.EntityKeyInterface, com.sas.io.InputStreamProviderInterface, BinaryFileEntryInterface, EntryInterface, java.io.Serializable, java.rmi.Remote

public class BinaryFileEntry
implements BinaryFileEntryInterface

Represents a binary file entry that can then be added to a result package for publishing. See Constructing a Result Package to Publish for an example of how this class is used.

Since:
1.0
See Also:
Serialized Form

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, VIEWER_COMPAT_VERSION
 
Constructor Summary
BinaryFileEntry(java.io.File file)
          Creates a binary file entry.
BinaryFileEntry(java.io.InputStream inputStream, java.lang.String name)
          Creates a binary file entry.
 
Method Summary
protected  void closeEntry()
          Remove any temporary files needed for inputstream re-use and mark this entry as closed.
 void consumeStream()
          Consume and close the input stream provided on the constructor.
protected  void finalize()
          At finalize time, cleanup temporary files if necessary.
 java.io.InputStream getInputStream()
          Gets the input stream for this binary file entry.
 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 associated with this binary file entry.
 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.
 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
 void setMIMEType(java.lang.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, throwExceptionIfClosed
 
Methods inherited from interface com.sas.services.publish.EntryInterface
getDescription, getNameValuePairs, getURL, isReadOnly, setDescription, setNameValuePairs
 

Constructor Detail

BinaryFileEntry

public BinaryFileEntry(java.io.File file)
                throws java.lang.IllegalArgumentException,
                       java.rmi.RemoteException
Creates a binary file entry. When the binary 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(java.lang.String).

Parameters:
file - The binary file.
Throws:
java.lang.IllegalArgumentException - If a null file is specified.
java.rmi.RemoteException - If a network anomaly is encountered.

BinaryFileEntry

public BinaryFileEntry(java.io.InputStream inputStream,
                       java.lang.String name)
                throws java.lang.IllegalArgumentException,
                       java.rmi.RemoteException
Creates a binary file entry. When the binary 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(java.lang.String).

Parameters:
inputStream - The input stream of the binary file.
name - The name of the binary file entry. This name will be used as the name of the entry when publishing the package.
Throws:
java.lang.IllegalArgumentException - If a null input stream or a null name is specified.
java.rmi.RemoteException - If a network anomaly is encountered.
Method Detail

getName

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

Specified by:
getName in interface BinaryFileEntryInterface
Returns:
String The name of the file.
Throws:
java.lang.IllegalStateException - If the package containing this entry is already closed.
TransportException - If the transport encounters an error getting the name.
java.rmi.RemoteException - If a network anomaly is encountered.

getMIMEType

public java.lang.String getMIMEType()
                             throws java.rmi.RemoteException,
                                    TransportException,
                                    java.lang.IllegalStateException
Returns the MIME type associated with this binary file entry. The user-specified MIME type is assigned when the binary file entry is published.

Specified by:
getMIMEType in interface BinaryFileEntryInterface
Returns:
String The MIME type associated with this binary file entry; can be null.
Throws:
java.lang.IllegalStateException - If the package containing this entry is already closed.
TransportException - If the transport encounters an error getting the MIME type.
java.rmi.RemoteException - If a network anomaly is encountered

setMIMEType

public void setMIMEType(java.lang.String mimeType)
                 throws java.lang.IllegalStateException,
                        java.rmi.RemoteException
Sets the MIME associated with this file entry.

Specified by:
setMIMEType in interface BinaryFileEntryInterface
Parameters:
mimeType - The MIME type associated with this file entry.
Throws:
java.lang.IllegalStateException - If the entry is read only or if the package containing this entry has already been closed.
java.rmi.RemoteException - If a network anomaly is encountered.

getInputStream

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

Specified by:
getInputStream in interface BinaryFileEntryInterface
Returns:
The input stream that can be used for reading the contents of the binary file entry.
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.

getInputStream

public java.io.InputStream getInputStream(java.lang.Object streamID)
                                   throws java.io.IOException,
                                          java.rmi.RemoteException,
                                          java.rmi.UnmarshalException,
                                          java.lang.IllegalStateException
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 BinaryFileEntryInterface
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.lang.IllegalStateException - If the package containing this entry is already closed.
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,
                                                                  java.lang.IllegalStateException
Deprecated. Use getInputStream()which now supports remote input streams.

Get the binary file 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 BinaryFileEntryInterface
Parameters:
streamID - The stream description should be null ;it will be ignored.
Returns:
RemoteInputStream The file as a remote input stream.
Throws:
java.lang.IllegalStateException - If the package containing this entry is already closed.
com.sas.io.ChainedIOException - If an I/O error occurs obtaining the input stream.
java.rmi.RemoteException - If a network anomaly is encountered.

hasInputStream

public java.lang.Object hasInputStream()
                                throws java.rmi.UnmarshalException,
                                       java.rmi.RemoteException,
                                       java.lang.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(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 BinaryFileEntryInterface
Returns:
non-null if getInputStream(java.lang.Object) would succeed; throws UnmarshalException if it would fail
Throws:
java.rmi.UnmarshalException - if invoked on a remote object
java.lang.IllegalStateException - If the package containing this entry is already closed.
java.rmi.RemoteException - if a network I/O error occurs.

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.

closeEntry

protected void closeEntry()
Remove any temporary files needed for inputstream re-use and mark this entry as closed.


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.