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

com.sas.services.publish
Class TextFileEntry

com.sas.services.publish.TextFileEntry
All Implemented Interfaces:
com.sas.entities.EntityKeyInterface, com.sas.io.ReaderProviderInterface, EntryInterface, TextFileEntryInterface, java.io.Serializable, java.rmi.Remote

public class TextFileEntry
implements TextFileEntryInterface

Represents a text 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
  TextFileEntry()
          Creates a default instance.
protected TextFileEntry(java.lang.Class theClass)
          Creates a new text file entry exporting a remote object using RMI socket factories appropriate for the specified class.
  TextFileEntry(java.io.File file)
          Creates a text file entry.
  TextFileEntry(java.io.InputStream inputStream, java.lang.String name)
          Creates a text file entry.
  TextFileEntry(java.io.Reader reader, java.lang.String name)
          Creates a text 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.lang.String getMIMEType()
          Returns the MIME type associated with this text file entry.
 java.lang.String getName()
          Returns the name of the file.
 java.io.Reader getReader()
          Gets reader for the text file entry.
 java.io.Reader getReader(int maxLineLength)
          Gets reader for the text file entry.
 java.io.Reader getReader(java.lang.Object readerID)
          Deprecated. Use getReader()which now supports remote readers.
 com.sas.io.RemoteReaderInterface getRemoteReader(java.lang.Object readerID)
          Deprecated. Use getReader()which now supports remote readers.
 java.lang.Object hasReader()
          Deprecated. this method no longer needed as getReader() will return a reader that can be used in a remote environment
 void setEncoding(java.lang.String encoding)
          Sets the encoding of the text file.
 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

TextFileEntry

public TextFileEntry()
              throws java.rmi.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 {#TextFileEntry(File file)} instead.

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

TextFileEntry

protected TextFileEntry(java.lang.Class theClass)
                 throws java.rmi.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:
java.rmi.RemoteException - If a network anomaly is encountered.

TextFileEntry

public TextFileEntry(java.io.File file)
              throws java.lang.IllegalArgumentException,
                     java.rmi.RemoteException
Creates a text file entry. When the text 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 text file.
Throws:
java.lang.IllegalArgumentException - If a null file is specified.
java.rmi.RemoteException - If a network anomaly is encountered.

TextFileEntry

public TextFileEntry(java.io.InputStream inputStream,
                     java.lang.String name)
              throws java.lang.IllegalArgumentException,
                     java.rmi.RemoteException
Creates a text file entry. When the text file is published, the input stream will be consumed until end-of-file.

Parameters:
inputStream - The input stream of the text file.
name - The name of the text 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.

TextFileEntry

public TextFileEntry(java.io.Reader reader,
                     java.lang.String name)
              throws java.lang.IllegalArgumentException,
                     java.rmi.RemoteException
Creates a text file entry. When the text file is published, the reader will be consumed until end-of-file.

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

getMIMEType

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

Specified by:
getMIMEType in interface TextFileEntryInterface
Returns:
String The MIME type associated with this text file entry; can be null.
Throws:
java.lang.IllegalStateException - if the result package containing this entry has already been 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 TextFileEntryInterface
Parameters:
mimeType - The MIME type associated with this file entry.
Throws:
java.lang.IllegalStateException - If the entry is read only or if the result package containing this entry has alredy been closed.
java.rmi.RemoteException - If a network anomaly is encountered.

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 TextFileEntryInterface
Returns:
String The name of the file.
Throws:
java.lang.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.
java.rmi.RemoteException - If a network anomaly is encountered.

getReader

public java.io.Reader getReader()
                         throws java.io.IOException,
                                java.rmi.RemoteException,
                                java.lang.IllegalStateException
Gets reader for the text file entry.

Specified by:
getReader in interface TextFileEntryInterface
Returns:
The reader that can be used for reading the contents of the text file entry.
Throws:
java.lang.IllegalStateException - if the result package containing this entry has already been closed.
java.io.IOException - If an error occurs constructing the input stream.
java.rmi.RemoteException - If a network anomaly is encountered.

getReader

public java.io.Reader getReader(java.lang.Object readerID)
                         throws java.io.IOException,
                                java.rmi.RemoteException,
                                java.rmi.UnmarshalException,
                                java.lang.IllegalStateException
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 TextFileEntryInterface
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:
java.lang.IllegalStateException - if the result package containing this entry has already been 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.

getRemoteReader

public com.sas.io.RemoteReaderInterface getRemoteReader(java.lang.Object readerID)
                                                 throws com.sas.io.ChainedIOException,
                                                        java.rmi.RemoteException,
                                                        java.lang.IllegalStateException
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 TextFileEntryInterface
Parameters:
readerID - The reader description should be null ;it will be ignored.
Returns:
RemoteReader The file as a remote Reader.
Throws:
java.lang.IllegalStateException - if the result package containing this entry has already been closed.
com.sas.io.ChainedIOException - If an I/O error occurs obtaining the reader.
java.rmi.RemoteException - If a network anomaly is encountered.

setEncoding

public void setEncoding(java.lang.String encoding)
                 throws java.rmi.RemoteException,
                        java.lang.IllegalStateException
Sets the encoding of the text file. This method can only be specified when constructing a package to be published. If specified, the encoding is used when constructing the Reader that is returned by getReader and and getRemoteReader, and it is used to publish the file.

Specified by:
setEncoding in interface TextFileEntryInterface
Parameters:
encoding - The encoding for this text file.
Throws:
java.lang.IllegalStateException - If the entry is read only or if the result package containing this entry has already been closed.
java.rmi.RemoteException - If a network anomaly is encountered

hasReader

public java.lang.Object hasReader()
                           throws java.rmi.UnmarshalException,
                                  java.rmi.RemoteException,
                                  java.lang.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 succeeed.

Specified by:
hasReader in interface com.sas.io.ReaderProviderInterface
Specified by:
hasReader in interface TextFileEntryInterface
Returns:
non-null if getReader(java.lang.Object) would succeed; throws UnmarshalException if it would fail
Throws:
java.rmi.UnmarshalException - if invoked on a remote object
java.rmi.RemoteException - if a network I/O error occurs.
java.lang.IllegalStateException

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.


getReader

public java.io.Reader getReader(int maxLineLength)
                         throws java.io.IOException,
                                java.rmi.RemoteException,
                                java.lang.IllegalStateException
Gets reader for the text file entry. The maximum line length is by the Requester transport when reading the text file; it identifies the maximum length of any line that will be in the file. This is typically set to some larger value than is actually used. If a huge number is specified, some hosts will adjust this down to a more reasonable value. Lines longer than this specified maxLineLength will be truncated

The maximum line length parameter is only supported by the Requester transport; it will ignored by all other transports.

Specified by:
getReader in interface TextFileEntryInterface
Parameters:
maxLineLength - the maximum length of any line that will be in the file. This parameter is supported by the Requester transport; it will be ignored by all other delivery transports.
Returns:
The reader that can be used for reading the contents of the text file entry.
Throws:
java.io.IOException - If an error occurs constructing the input stream.
java.rmi.RemoteException - If a network anomaly is encountered.
java.lang.IllegalStateException - If the package containing this entry is already 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.