|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbiz.c24.io.api.presentation.Source
public abstract class Source
A class used to read data objects from an input stream or reader in a specific format.
This class is subclassed by format specific specialisations.
The input stream or reader used by this class will never be closed - it is the responsibility of the calling class
to maintain a reference to the appropriate object so that it can be closed when no longer required.
If character data is required and no input stream has been set then the stream will be wrapped by an InputStreamReader
using the default charset. Therefore if an encoding other than the default is required, an java.io.InputStreamReader
should be instantiated with that encoding and then supplied to this class.
Constructor Summary | |
---|---|
Source()
Constructs a new instance. |
|
Source(InputStream stream)
Constructs a new instance which will read from stream (optional operation). |
|
Source(Reader reader)
Constructs a new instance which will read from reader (optional operation). |
Method Summary | |
---|---|
protected void |
checkInit()
Used by subclasses to ensure a reader or input stream has been set. |
abstract Object |
clone()
|
String |
getEncoding()
Get the character encoding for a byte stream. |
InputStream |
getInputStream()
Returns the input stream (optional operation). |
InputStream |
getMarkableInputStream()
|
ParseListener |
getParseListener()
Returns the parse listener that will be notified of batch processing events. |
Reader |
getReader()
Returns the reader (optional operation). |
URI |
getSystemId()
Gets the optional System ID. |
protected Reader |
reader()
Used by subclasses to get a reference to the reader object responsible for reading the data. |
abstract void |
readObject(ComplexDataObject object)
Reads an object from the the reader or input stream that has been set (optional operation). |
abstract ComplexDataObject |
readObject(Element element)
Reads an object from the the reader or input stream that has been set. |
boolean |
ready()
Tests whether the underlying stream or reader contains more data waiting to be parsed. |
void |
setEncoding(String encoding)
Set the character encoding for a byte stream. |
void |
setInputStream(InputStream stream)
Sets the input stream (optional operation). |
void |
setInputStream(InputStream stream,
URI systemId)
Sets the input stream and system ID (optional operation). |
void |
setParseListener(ParseListener listener)
Sets the parse listener that will be notified of batch processing events. |
void |
setReader(Reader reader)
Sets the reader (optional operation). |
void |
setReader(Reader reader,
URI systemId)
Sets the reader (optional operation). |
void |
setSystemId(URI systemId)
Sets the optional System ID. |
protected InputStream |
stream()
Used by subclasses to get a reference to the input stream object responsible for reading the data. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Source()
public Source(Reader reader)
reader
(optional operation).
reader
- The reader to read the data from.
UnsupportedOperationException
- If this source does not support input from a java.io.Reader, in which case a java.io.InputStream should be used.public Source(InputStream stream)
stream
(optional operation).
stream
- The stream to read the data from.
UnsupportedOperationException
- If this source does not support input from a java.io.InputStream, in which case a java.io.Reader should be used.Method Detail |
---|
public void setReader(Reader reader)
reader
- The new value.
UnsupportedOperationException
- If this source does not support input from a java.io.Reader, in which case a java.io.InputStream should be used.public void setReader(Reader reader, URI systemId)
reader
- The new value.systemId
- The system ID identifying the reader.
UnsupportedOperationException
- If this source does not support input from a java.io.Reader, in which case a java.io.InputStream should be used.public Reader getReader()
UnsupportedOperationException
- If this source does not support input from a java.io.Reader, in which case a java.io.InputStream should be used.public void setInputStream(InputStream stream)
This method will also clear the system ID.
stream
- The new value.
UnsupportedOperationException
- If this source does not support input from a java.io.InputStream, in which case a java.io.Reader should be used.public void setInputStream(InputStream stream, URI systemId)
stream
- The new value.systemId
- The system ID identifying the stream.
UnsupportedOperationException
- If this source does not support input from a java.io.InputStream, in which case a java.io.Reader should be used.public InputStream getInputStream()
UnsupportedOperationException
- If this source does not support input from a java.io.InputStream, in which case a java.io.Reader should be used.public void setEncoding(String encoding)
encoding
- A string describing the character encoding. If null then UTF-8 will be used by default.public String getEncoding()
public URI getSystemId()
null
if none has been set.public void setSystemId(URI systemId)
This gives an optional indication as to the location of the underlying stream being read.
systemId
- The new value.public boolean ready()
Reader.ready()
and InputStream.available()
since it may need to take into account data which has been buffered by the Source implementation.
public ParseListener getParseListener()
ParseListener
public void setParseListener(ParseListener listener)
listener
- the new listener.ParseListener
public abstract void readObject(ComplexDataObject object) throws IOException
object
- The object into which the input data should be parsed.
IOException
- If the complete object could not be read for any reason.
IllegalArgumentException
- If neither a reader nor an input stream has been set.
UnsupportedOperationException
- If this source does not support this method, in which case readObject(Element)
should be used.public abstract ComplexDataObject readObject(Element element) throws IOException
element
- The element declaration to which the input data is expected to adhere.
IOException
- If the complete object could not be read for any reason.
IllegalArgumentException
- If neither a reader nor an input stream has been set.public InputStream getMarkableInputStream()
protected InputStream stream()
protected Reader reader() throws UnsupportedEncodingException
UnsupportedEncodingException
- If the encoding is not supported.protected void checkInit()
IllegalArgumentException
- If neither a reader nor an input stream has been set.public abstract Object clone()
clone
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |