public class TLcdXMLDecoder extends Object implements ILcdInputStreamFactoryCapable
ILcdXMLUnmarshaller
's.
The decoded Java object graph can be any valid Java object: the exact mapping between XML data and
Java objects is fully customizable and depends on how the ILcdXMLUnmarshaller
's
are implemented. It can be anything from a tree-like structure which is very close to the original
XML data structure (like a JDOM tree), to a completely different data structure, for example an ILcdModel
with ILcdShape
objects.
This decoder will set up a new XMLStreamReader for each document to be unmarshalled, create a new
document context, look up an unmarshaller for the root element of the document and delegate the
unmarshalling process to this unmarshaller.
This class is thread-safe and can be shared among multiple threads.
Please refer to the package documentation
for a general
overview of the XML Binding Framework.
Constructor and Description |
---|
TLcdXMLDecoder()
Creates a new, empty
TLcdXMLDecoder . |
TLcdXMLDecoder(ILcdXMLDecoderLibrary aLibrary)
Creates a new
TLcdXMLDecoder for the specified decoder library. |
TLcdXMLDecoder(List<ILcdXMLDecoderLibrary> aLibraries)
Creates a new
TLcdXMLDecoder for the specified decoder libraries. |
TLcdXMLDecoder(List<ILcdXMLDecoderLibrary> aLibraries,
TLcdXMLMapping aMapping) |
Modifier and Type | Method and Description |
---|---|
ILcdXMLDocumentContext |
createDocumentContext()
Creates a new
ILcdXMLDocumentContext that can be used during decoding of an XML
document. |
Object |
decode(String aSourceName)
Unmarshals the specified document to a Java object graph.
|
Object |
decode(String aSourceName,
InputStream aInputStream)
Unmarshals the specified input stream to a Java object graph.
|
<T> T |
decode(String aSourceName,
InputStream aInputStream,
Class<T> aRootJavaClass)
Unmarshals the specified input stream to a Java object graph.
|
<T> T |
decode(String aSourceName,
InputStream aInputStream,
Class<T> aRootJavaClass,
ILcdXMLDocumentContext aDocumentContext)
Unmarshals the specified input stream to a Java object graph.
|
Object |
decode(String aSourceName,
InputStream aInputStream,
ILcdXMLDocumentContext aDocumentContext)
Unmarshals the specified input stream to a Java object graph.
|
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the
com.luciad.io.ILcdInputStreamFactory that is used by this decoder for
creating input streams. |
TLcdXMLMapping |
getMapping() |
Set<String> |
getNamespaceURIs()
Returns the set of namespaces which are supported by this decoder.
|
TLcdXMLUnmarshallerProvider |
getUnmarshallerProvider()
Returns the unmarshaller provider for this XML decoder, containing unmarshallers for
converting XML data into Java object graphs.
|
XMLInputFactory |
getXMLInputFactory()
Returns the
javax.xml.stream.XMLInputFactory that is used by this decoder for creating
javax.xml.stream.XMLStreamReader instances. |
void |
registerNamespaceURI(String aNamespaceURI)
Registers the specified namespace on this decoder.
|
void |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Sets the
com.luciad.io.ILcdInputStreamFactory to be used by this decoder for
creating input streams. |
void |
setXMLInputFactory(XMLInputFactory aXMLInputFactory)
Sets the
javax.xml.stream.XMLInputFactory to be used by this decoder for creating
javax.xml.stream.XMLStreamReader instances. |
public TLcdXMLDecoder()
TLcdXMLDecoder
.public TLcdXMLDecoder(ILcdXMLDecoderLibrary aLibrary)
TLcdXMLDecoder
for the specified decoder library.
This is a convenience constructor, identical to:
TLcdXMLDecoder decoder = new TLcdXMLDecoder();
aLibrary.configureDecoder(decoder);
aLibrary
- the decoder library for which to create an XML decoder.public TLcdXMLDecoder(List<ILcdXMLDecoderLibrary> aLibraries)
TLcdXMLDecoder
for the specified decoder libraries.
This is a convenience constructor, being identical to:
TLcdXMLDecoder decoder = new TLcdXMLDecoder();
for ( ILcdXMLDecoderLibrary library : aLibraries) {
library.configureDecoder(decoder);
}
aLibraries
- the decoder libraries for which to create an XML decoder.public TLcdXMLDecoder(List<ILcdXMLDecoderLibrary> aLibraries, TLcdXMLMapping aMapping)
public ILcdInputStreamFactory getInputStreamFactory()
com.luciad.io.ILcdInputStreamFactory
that is used by this decoder for
creating input streams.getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
com.luciad.io.ILcdInputStreamFactory
that is used by this decoder for
creating input streams.public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
com.luciad.io.ILcdInputStreamFactory
to be used by this decoder for
creating input streams.setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the com.luciad.io.ILcdInputStreamFactory
that is used by
this decoder for creating input streams.public XMLInputFactory getXMLInputFactory()
javax.xml.stream.XMLInputFactory
that is used by this decoder for creating
javax.xml.stream.XMLStreamReader
instances.javax.xml.stream.XMLInputFactory
that is used by this decoder for creating
javax.xml.stream.XMLStreamReader
instances.public void setXMLInputFactory(XMLInputFactory aXMLInputFactory)
javax.xml.stream.XMLInputFactory
to be used by this decoder for creating
javax.xml.stream.XMLStreamReader
instances.aXMLInputFactory
- the javax.xml.stream.XMLInputFactory
to be used by this decoder
for creating javax.xml.stream.XMLStreamReader
instances.public ILcdXMLDocumentContext createDocumentContext()
ILcdXMLDocumentContext
that can be used during decoding of an XML
document. A document context may only be used for decoding a single XML document and should
be discarded afterwards.ILcdXMLDocumentContext
that can be used during decoding of an XML
document.public Object decode(String aSourceName) throws XMLStreamException, IOException
aSourceName
- the data source from which the data should be read; typically a file name
or a URL.XMLStreamException
- if an unexpected processing exception occurs during unmarshalling.IOException
- if an java.io.IOException
occurs during unmarshalling.public Object decode(String aSourceName, InputStream aInputStream) throws XMLStreamException, IOException
aSourceName
- the data source from which the data should be read; typically a file name
or a URL. This should be the same as the source name of the input stream.aInputStream
- the InputStream
containing XML data to be unmarshalled.XMLStreamException
- if an unexpected processing exception occurs during unmarshalling.IOException
- if an java.io.IOException
occurs during unmarshalling.public <T> T decode(String aSourceName, InputStream aInputStream, Class<T> aRootJavaClass) throws XMLStreamException, IOException
aSourceName
- the data source from which the data should be read; typically a file name
or a URL. This should be the same as the source name of the input stream.aInputStream
- the InputStream
containing XML data to be unmarshalled.aRootJavaClass
- the class of the root Object in the returned Java object graph.XMLStreamException
- if an unexpected processing exception occurs during unmarshalling.IOException
- if an java.io.IOException
occurs during unmarshalling.public Object decode(String aSourceName, InputStream aInputStream, ILcdXMLDocumentContext aDocumentContext) throws XMLStreamException, IOException
aSourceName
- the data source from which the data should be read; typically a file name
or a URL. This should be the same as the source name of the input stream.aInputStream
- the InputStream
containing XML data to be unmarshalled.aDocumentContext
- the document context to be used during unmarshalling.XMLStreamException
- if an unexpected processing exception occurs during unmarshalling.IOException
- if an java.io.IOException
occurs during unmarshalling.public <T> T decode(String aSourceName, InputStream aInputStream, Class<T> aRootJavaClass, ILcdXMLDocumentContext aDocumentContext) throws XMLStreamException, IOException
aSourceName
- the data source from which the data should be read; typically a file name
or a URL. This should be the same as the source name of the input stream.aInputStream
- the InputStream
containing XML data to be unmarshalled.aRootJavaClass
- the class of the root Object in the returned Java object graph.aDocumentContext
- the document context to be used during unmarshalling.XMLStreamException
- if an unexpected processing exception occurs during unmarshalling.IOException
- if an java.io.IOException
occurs during unmarshalling.public TLcdXMLUnmarshallerProvider getUnmarshallerProvider()
public Set<String> getNamespaceURIs()
public TLcdXMLMapping getMapping()
public void registerNamespaceURI(String aNamespaceURI)
aNamespaceURI
- the namespace for which unmarshallers are registered on
this decoder.