de.infinityloop.util.inout
Class OutputProxy

java.lang.Object
  extended by de.infinityloop.util.inout.OutputProxy

public class OutputProxy
extends java.lang.Object

A generalized output source object to pass around in the application. For simplicity, this uses a blue print of the org.xml.sax.InputSource interface.

Special feature: You can request "substreams", which logically belong to the main stream this Proxy stands for, but which are directed to different end points (files or streams). Not yet implemented (will use OutputStreamFactory).


Constructor Summary
OutputProxy()
          zero-arg constructor
OutputProxy(DiskFile file)
          Constructor for InputProxy with a DiskFile as parameter.
OutputProxy(java.io.OutputStream byteStream)
          Create a new output with a byte stream.
OutputProxy(java.lang.String systemId)
          Create a new output with a system identifier.
OutputProxy(java.io.Writer characterStream)
          Create a new output with a character stream.
 
Method Summary
 void close()
          close the proxy.
 java.io.OutputStream getByteStream(boolean doThrow)
          Get the byte stream for this output.
 java.io.Writer getCharacterStream(boolean doThrow)
          Returns the Reader.
 java.io.Writer getCharacterStream(java.lang.String enc)
          Returns a reader with the specified encoding
 java.lang.String getEncoding()
          Get the character encoding for a byte stream or URI.
 java.lang.String getPublicId()
          Get the public identifier for this object.
 java.lang.String getSystemId()
          Get the system identifier for this output.
 java.lang.String getSystemIdLocalFormat()
          Get the system identifier for this output, in local file system format.
 java.lang.String getSystemIdName()
          Returns the name portion to the systemId (i.e. it discards the path up to the file name
 java.lang.String getSystemIdPath()
          returns the path portion to the systemId (i.e. it truncates the actual file name, and includes the trailing '/'.
 void open(boolean doThrow)
          Opens the object for output.
 void setByteStream(java.io.OutputStream byteStream)
          Set the byte stream for this output.
 void setCharacterStream(java.io.Writer characterStream)
          Set the character stream for this output.
 void setEncoding(java.lang.String encoding)
          Set the character encoding, if known.
 void setPublicId(java.lang.String publicId)
          Set the public identifier for this output.
 void setSystemId(java.lang.String systemId)
          Set the system identifier for this output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutputProxy

public OutputProxy(DiskFile file)
Constructor for InputProxy with a DiskFile as parameter.


OutputProxy

public OutputProxy()
zero-arg constructor


OutputProxy

public OutputProxy(java.lang.String systemId)
Create a new output with a system identifier.


OutputProxy

public OutputProxy(java.io.OutputStream byteStream)
Create a new output with a byte stream.


OutputProxy

public OutputProxy(java.io.Writer characterStream)
Create a new output with a character stream.

Method Detail

setPublicId

public void setPublicId(java.lang.String publicId)
Set the public identifier for this output.


getPublicId

public java.lang.String getPublicId()
Get the public identifier for this object.

Returns:
The public identifier, or null if none was supplied.

setSystemId

public void setSystemId(java.lang.String systemId)
Set the system identifier for this output.

Parameters:
systemId - The system identifier as a string.

getSystemId

public java.lang.String getSystemId()
Get the system identifier for this output.

Returns:
The system identifier, or null if none was supplied.
See Also:
setSystemId(java.lang.String), getEncoding()

getSystemIdLocalFormat

public java.lang.String getSystemIdLocalFormat()
Get the system identifier for this output, in local file system format.

Returns:
The system identifier, or null if none was supplied.
See Also:
setSystemId(java.lang.String), getEncoding()

setByteStream

public void setByteStream(java.io.OutputStream byteStream)
Set the byte stream for this output.

Parameters:
byteStream - A byte stream containing an XML document or other entity.

getByteStream

public java.io.OutputStream getByteStream(boolean doThrow)
                                   throws java.lang.Exception
Get the byte stream for this output.

The getEncoding method will return the character encoding for this byte stream, or null if unknown.

Parameters:
doThrow - if true, an error result in throwing an appropriate Exception, otherwise simply null is returned
Returns:
The byte stream, or null if none was supplied.
Throws:
java.lang.Exception

setEncoding

public void setEncoding(java.lang.String encoding)
Set the character encoding, if known.

Parameters:
encoding - A string describing the character encoding.

getEncoding

public java.lang.String getEncoding()
Get the character encoding for a byte stream or URI.

Returns:
The encoding, or null if none was supplied.

setCharacterStream

public void setCharacterStream(java.io.Writer characterStream)
Set the character stream for this output.

Parameters:
characterStream - The character stream containing the XML document or other entity.

getCharacterStream

public java.io.Writer getCharacterStream(boolean doThrow)
                                  throws java.lang.Exception
Returns the Reader. If that does not exist, we create one from the input stream.

Parameters:
doThrow - if true, an error result in throwing an appropriate Exception, otherwise simply null is returned
Throws:
java.lang.Exception

getCharacterStream

public java.io.Writer getCharacterStream(java.lang.String enc)
                                  throws java.io.UnsupportedEncodingException,
                                         java.lang.Exception
Returns a reader with the specified encoding

Throws:
java.io.UnsupportedEncodingException
java.lang.Exception

getSystemIdPath

public java.lang.String getSystemIdPath()
returns the path portion to the systemId (i.e. it truncates the actual file name, and includes the trailing '/'.

Returns:
the empty string, when there is no system id defined.

getSystemIdName

public java.lang.String getSystemIdName()
Returns the name portion to the systemId (i.e. it discards the path up to the file name

Returns:
the empty string, when there is no system id defined.

open

public void open(boolean doThrow)
          throws java.lang.Exception
Opens the object for output. At construction time, we do not open the respective streams so you need to do this manually if need be. This applies not e.g. for a constructor using a stream - this is opened already by default.

Parameters:
doThrow - if true, an error result in throwing an appropriate Exception
Throws:
java.lang.Exception

close

public void close()
close the proxy. Used e.g. when handling output sessions.