|
J avolution v5.5 (J2SE 1.6+) | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavolution.xml.XMLObjectReader
public class XMLObjectReader
This class restores objects which have been serialized in XML
format using an XMLObjectWriter
.
When the XML document is parsed, each elements are recursively
processed and Java objects are created using the XMLFormat
of the class as identified by the XMLBinding
.
Multiple objects can be read from the same XML input.
For example:
XMLObjectReader reader = XMLObjectReader.newInstance(inputStream);
while (reader.hasNext()) {
Message message = reader.read("Message", Message.class);
}
reader.close(); // Reader is recycled, the underlying stream is closed.
Constructor Summary | |
---|---|
XMLObjectReader()
Default constructor. |
Method Summary | ||
---|---|---|
void |
close()
Closes this reader and its underlying input then reset
this reader for potential reuse. |
|
XMLStreamReader |
getStreamReader()
Returns the stream reader being used by this reader (it can be used to set prefix, read prologs, etc). |
|
boolean |
hasNext()
Indicates if more elements can be read. |
|
static XMLObjectReader |
newInstance(java.io.InputStream in)
Returns a XML object reader (potentially recycled) having the specified input stream as input. |
|
static XMLObjectReader |
newInstance(java.io.InputStream in,
java.lang.String encoding)
Returns a XML object reader (potentially recycled) having the specified input stream/encoding as input. |
|
static XMLObjectReader |
newInstance(java.io.Reader in)
Returns a XML object reader (potentially recycled) having the specified reader as input. |
|
|
read()
Returns the object corresponding to the next element/data. |
|
|
read(java.lang.String name)
Returns the object corresponding to the next nested element only if it has the specified local name. |
|
|
read(java.lang.String name,
java.lang.Class<T> cls)
Returns the object corresponding to the next nested element only if it has the specified local name; the actual object type is identified by the specified class parameter. |
|
|
read(java.lang.String localName,
java.lang.String uri)
Returns the object corresponding to the next nested element only if it has the specified local name and namespace URI. |
|
|
read(java.lang.String localName,
java.lang.String uri,
java.lang.Class<T> cls)
Returns the object corresponding to the next nested element only if it has the specified local name and namespace URI; the actual object type is identified by the specified class parameter. |
|
static void |
recycle(XMLObjectReader that)
Recycles the specified XMLObjectReader. |
|
void |
reset()
Resets this object reader for reuse. |
|
XMLObjectReader |
setBinding(XMLBinding binding)
Sets the XML binding to use with this object reader. |
|
XMLObjectReader |
setInput(java.io.InputStream in)
Sets the input stream source for this XML object reader (encoding retrieved from XML prolog if any). |
|
XMLObjectReader |
setInput(java.io.InputStream in,
java.lang.String encoding)
Sets the input stream source and encoding for this XML object reader. |
|
XMLObjectReader |
setInput(java.io.Reader in)
Sets the reader input source for this XML stream reader. |
|
XMLObjectReader |
setReferenceResolver(XMLReferenceResolver referenceResolver)
Sets the XML reference resolver to use with this object reader (the same resolver can be used accross multiple readers). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XMLObjectReader()
Method Detail |
---|
public static XMLObjectReader newInstance(java.io.InputStream in) throws XMLStreamException
in
- the input stream.
XMLStreamException
public static XMLObjectReader newInstance(java.io.InputStream in, java.lang.String encoding) throws XMLStreamException
in
- the input stream.encoding
- the input stream encoding
XMLStreamException
public static XMLObjectReader newInstance(java.io.Reader in) throws XMLStreamException
in
- the reader source.
XMLStreamException
public static void recycle(XMLObjectReader that)
that
- the instance to recycle.public XMLStreamReader getStreamReader()
public XMLObjectReader setInput(java.io.InputStream in) throws XMLStreamException
in
- the source input stream.
this
XMLStreamException
XMLStreamReaderImpl.setInput(InputStream)
public XMLObjectReader setInput(java.io.InputStream in, java.lang.String encoding) throws XMLStreamException
in
- the input source.encoding
- the associated encoding.
this
XMLStreamException
XMLStreamReaderImpl.setInput(InputStream, String)
public XMLObjectReader setInput(java.io.Reader in) throws XMLStreamException
in
- the source reader.
this
XMLStreamException
XMLStreamReaderImpl.setInput(Reader)
public XMLObjectReader setBinding(XMLBinding binding)
binding
- the XML binding to use.
this
public XMLObjectReader setReferenceResolver(XMLReferenceResolver referenceResolver)
referenceResolver
- the XML reference resolver.
this
public boolean hasNext() throws XMLStreamException
true
if more element/data to be read;
false
otherwise.
XMLStreamException
XMLFormat.InputElement.hasNext()
public <T> T read() throws XMLStreamException
null
)
XMLStreamException
- if hasNext() == false
XMLFormat.InputElement.getNext()
public <T> T read(java.lang.String name) throws XMLStreamException
name
- the local name of the next element.
null
if the
local name does not match.
XMLStreamException
XMLFormat.InputElement.get(String)
public <T> T read(java.lang.String localName, java.lang.String uri) throws XMLStreamException
localName
- the local name.uri
- the namespace URI.
null
if the
name/uri does not match.
XMLStreamException
XMLFormat.InputElement.get(String, String)
public <T> T read(java.lang.String name, java.lang.Class<T> cls) throws XMLStreamException
name
- the name of the element to match.cls
- the non-abstract class identifying the object to return.
read(name, null, cls)
XMLStreamException
public <T> T read(java.lang.String localName, java.lang.String uri, java.lang.Class<T> cls) throws XMLStreamException
localName
- the local name.uri
- the namespace URI.cls
- the non-abstract class identifying the object to return.
null
if no match.
XMLStreamException
public void close() throws XMLStreamException
reset
this reader for potential reuse.
XMLStreamException
public void reset()
reset
in interface Reusable
|
J avolution v5.5 (J2SE 1.6+) | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |