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(InputStream byteStream)
          Create a new input source with a byte stream.
ClosingInputSource(Reader characterStream)
          Create a new input source with a character stream.
ClosingInputSource(String systemId)
          Create a new input source with a system identifier.
ClosingInputSource(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(InputStream byteStream)
          Set the byte stream, copying it to a buffer.
 void setCharacterStream(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 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(String systemId)
Create a new input source with a system identifier.
Parameters:
systemId - The system identifier.
See Also:
InputSource.InputSource(String)

ClosingInputSource

public ClosingInputSource(String systemId,
                          boolean openNow)
                   throws 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:
IOException - If an error occures opening the stream.
See Also:
InputSource.InputSource(String)

ClosingInputSource

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

ClosingInputSource

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

open

public void open()
          throws 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(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(Reader characterStream)
Set the character stream, copying it to a buffer.
Overrides:
setCharacterStream in class InputSource
See Also:
InputSource.setCharacterStream(java.io.Reader)


Copyright © 1999-2002 enhydra.org (Mark Diekhans, David Li, Richard Kunze). All Rights reserved.