Enhydra 3.1.1b1 API

org.enhydra.xml.io
Class ClosingInputSource

java.lang.Object
  |
  +--org.xml.sax.InputSource
        |
        +--org.enhydra.xml.io.ClosingInputSource

public class ClosingInputSource
extends InputSource

Input source that automatically close its InputStream when EOF is reached or an error occurs. This works around a flaw in the SAX API where there is not method of an entity handler that opens a stream to be informed when the stream is no longer needed.


Constructor Summary
ClosingInputSource()
          Zero-argument default constructor.
ClosingInputSource(InputSource inputSource, boolean openNow)
          Create a new input source from another input source.
ClosingInputSource(java.io.InputStream byteStream)
          Create a new input source with a byte stream.
ClosingInputSource(java.io.Reader characterStream)
          Create a new input source with a character stream.
ClosingInputSource(java.lang.String systemId)
          Create a new input source with a system identifier.
ClosingInputSource(java.lang.String systemId, boolean openNow)
          Create a new input source with a system identifier.
 
Method Summary
 void open()
          If the resource is specified by system id, open it now as a byte stream.
 void setByteStream(java.io.InputStream byteStream)
          Set the byte stream, copying it to a buffer.
 void setCharacterStream(java.io.Reader characterStream)
          Set the character stream, copying it to a buffer.
 
Methods inherited from class org.xml.sax.InputSource
getByteStream, getCharacterStream, getEncoding, getPublicId, getSystemId, setEncoding, setPublicId, setSystemId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClosingInputSource

public ClosingInputSource()
Zero-argument default constructor.
See Also:
InputSource.InputSource()

ClosingInputSource

public ClosingInputSource(InputSource inputSource,
                          boolean openNow)
                   throws java.io.IOException
Create a new input source from another input source.
Parameters:
inputSource - Input source specification to clone
openNow - If true, the input source is opened immediatly if specified as a system id.
See Also:
InputSource

ClosingInputSource

public ClosingInputSource(java.lang.String systemId)
Create a new input source with a system identifier.
Parameters:
systemId - The system identifier.
See Also:
InputSource.InputSource(String)

ClosingInputSource

public ClosingInputSource(java.lang.String systemId,
                          boolean openNow)
                   throws java.io.IOException
Create a new input source with a system identifier.
Parameters:
systemId - The system identifier.
openNow - If true, the input source is opened immediatly if specified as a system id.
Throws:
java.io.IOException - If an error occures opening the stream.
See Also:
InputSource.InputSource(String)

ClosingInputSource

public ClosingInputSource(java.io.InputStream byteStream)
Create a new input source with a byte stream.
See Also:
InputSource.InputSource(InputStream)

ClosingInputSource

public ClosingInputSource(java.io.Reader characterStream)
Create a new input source with a character stream.
See Also:
InputSource.InputSource(Reader)
Method Detail

open

public void open()
          throws java.io.IOException
If the resource is specified by system id, open it now as a byte stream. If the resource is specified by byte or character stream, this does nothing.

setByteStream

public void setByteStream(java.io.InputStream byteStream)
Set the byte stream, copying it to a buffer.
Overrides:
setByteStream in class InputSource
See Also:
InputSource.setByteStream(java.io.InputStream)

setCharacterStream

public void setCharacterStream(java.io.Reader characterStream)
Set the character stream, copying it to a buffer.
Overrides:
setCharacterStream in class InputSource
See Also:
InputSource.setCharacterStream(java.io.Reader)

Enhydra 3.1.1b1 API