Package com.luciad.format.xml.bind
Class TLcdXMLDecoder
java.lang.Object
com.luciad.format.xml.bind.TLcdXMLDecoder
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable
Main class for unmarshalling an XML document into a Java object graph, using
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.
- Since:
- 9.0
-
Constructor Summary
ConstructorDescriptionCreates a new, emptyTLcdXMLDecoder
.TLcdXMLDecoder
(ILcdXMLDecoderLibrary aLibrary) Creates a newTLcdXMLDecoder
for the specified decoder library.TLcdXMLDecoder
(List<ILcdXMLDecoderLibrary> aLibraries) Creates a newTLcdXMLDecoder
for the specified decoder libraries.TLcdXMLDecoder
(List<ILcdXMLDecoderLibrary> aLibraries, TLcdXMLMapping aMapping) -
Method Summary
Modifier and TypeMethodDescriptionCreates a newILcdXMLDocumentContext
that can be used during decoding of an XML document.Unmarshals the specified document to a Java object graph.decode
(String aSourceName, InputStream aInputStream) Unmarshals the specified input stream to a Java object graph.decode
(String aSourceName, InputStream aInputStream, ILcdXMLDocumentContext aDocumentContext) 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.Returns thecom.luciad.io.ILcdInputStreamFactory
that is used by this decoder for creating input streams.Returns the set of namespaces which are supported by this decoder.Returns the unmarshaller provider for this XML decoder, containing unmarshallers for converting XML data into Java object graphs.Returns thejavax.xml.stream.XMLInputFactory
that is used by this decoder for creatingjavax.xml.stream.XMLStreamReader
instances.void
registerNamespaceURI
(String aNamespaceURI) Registers the specified namespace on this decoder.void
setInputStreamFactory
(ILcdInputStreamFactory aInputStreamFactory) Sets thecom.luciad.io.ILcdInputStreamFactory
to be used by this decoder for creating input streams.void
setXMLInputFactory
(XMLInputFactory aXMLInputFactory) Sets thejavax.xml.stream.XMLInputFactory
to be used by this decoder for creatingjavax.xml.stream.XMLStreamReader
instances.
-
Constructor Details
-
TLcdXMLDecoder
public TLcdXMLDecoder()Creates a new, emptyTLcdXMLDecoder
. -
TLcdXMLDecoder
Creates a newTLcdXMLDecoder
for the specified decoder library. This is a convenience constructor, identical to:TLcdXMLDecoder decoder = new TLcdXMLDecoder(); aLibrary.configureDecoder(decoder);
- Parameters:
aLibrary
- the decoder library for which to create an XML decoder.
-
TLcdXMLDecoder
Creates a newTLcdXMLDecoder
for the specified decoder libraries. This is a convenience constructor, being identical to:TLcdXMLDecoder decoder = new TLcdXMLDecoder(); for ( ILcdXMLDecoderLibrary library : aLibraries) { library.configureDecoder(decoder); }
- Parameters:
aLibraries
- the decoder libraries for which to create an XML decoder.
-
TLcdXMLDecoder
-
-
Method Details
-
getInputStreamFactory
Returns thecom.luciad.io.ILcdInputStreamFactory
that is used by this decoder for creating input streams.- Specified by:
getInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Returns:
- the
com.luciad.io.ILcdInputStreamFactory
that is used by this decoder for creating input streams.
-
setInputStreamFactory
Sets thecom.luciad.io.ILcdInputStreamFactory
to be used by this decoder for creating input streams.- Specified by:
setInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Parameters:
aInputStreamFactory
- thecom.luciad.io.ILcdInputStreamFactory
that is used by this decoder for creating input streams.
-
getXMLInputFactory
Returns thejavax.xml.stream.XMLInputFactory
that is used by this decoder for creatingjavax.xml.stream.XMLStreamReader
instances.- Returns:
- the
javax.xml.stream.XMLInputFactory
that is used by this decoder for creatingjavax.xml.stream.XMLStreamReader
instances.
-
setXMLInputFactory
Sets thejavax.xml.stream.XMLInputFactory
to be used by this decoder for creatingjavax.xml.stream.XMLStreamReader
instances.- Parameters:
aXMLInputFactory
- thejavax.xml.stream.XMLInputFactory
to be used by this decoder for creatingjavax.xml.stream.XMLStreamReader
instances.
-
createDocumentContext
Creates a newILcdXMLDocumentContext
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.- Returns:
- a new
ILcdXMLDocumentContext
that can be used during decoding of an XML document.
-
decode
Unmarshals the specified document to a Java object graph.- Parameters:
aSourceName
- the data source from which the data should be read; typically a file name or a URL.- Returns:
- the unmarshaller Java object graph.
- Throws:
XMLStreamException
- if an unexpected processing exception occurs during unmarshalling.IOException
- if anjava.io.IOException
occurs during unmarshalling.
-
decode
public Object decode(String aSourceName, InputStream aInputStream) throws XMLStreamException, IOException Unmarshals the specified input stream to a Java object graph.- Parameters:
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
- theInputStream
containing XML data to be unmarshalled.- Returns:
- the unmarshalled Java object graph.
- Throws:
XMLStreamException
- if an unexpected processing exception occurs during unmarshalling.IOException
- if anjava.io.IOException
occurs during unmarshalling.
-
decode
public <T> T decode(String aSourceName, InputStream aInputStream, Class<T> aRootJavaClass) throws XMLStreamException, IOException Unmarshals the specified input stream to a Java object graph.- Parameters:
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
- theInputStream
containing XML data to be unmarshalled.aRootJavaClass
- the class of the root Object in the returned Java object graph.- Returns:
- the unmarshalled Java object graph.
- Throws:
XMLStreamException
- if an unexpected processing exception occurs during unmarshalling.IOException
- if anjava.io.IOException
occurs during unmarshalling.
-
decode
public Object decode(String aSourceName, InputStream aInputStream, ILcdXMLDocumentContext aDocumentContext) throws XMLStreamException, IOException Unmarshals the specified input stream to a Java object graph.- Parameters:
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
- theInputStream
containing XML data to be unmarshalled.aDocumentContext
- the document context to be used during unmarshalling.- Returns:
- the unmarshalled Java object graph.
- Throws:
XMLStreamException
- if an unexpected processing exception occurs during unmarshalling.IOException
- if anjava.io.IOException
occurs during unmarshalling.
-
decode
public <T> T decode(String aSourceName, InputStream aInputStream, Class<T> aRootJavaClass, ILcdXMLDocumentContext aDocumentContext) throws XMLStreamException, IOException Unmarshals the specified input stream to a Java object graph.- Parameters:
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
- theInputStream
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.- Returns:
- the unmarshalled Java object graph.
- Throws:
XMLStreamException
- if an unexpected processing exception occurs during unmarshalling.IOException
- if anjava.io.IOException
occurs during unmarshalling.
-
getUnmarshallerProvider
Returns the unmarshaller provider for this XML decoder, containing unmarshallers for converting XML data into Java object graphs.- Returns:
- the unmarshaller provider for this XML decoder.
-
getNamespaceURIs
Returns the set of namespaces which are supported by this decoder.- Returns:
- the set of namespaces supported by this decoder.
-
getMapping
-
registerNamespaceURI
Registers the specified namespace on this decoder. Namespaces should be registered to indicate that they are supported by this decoder.- Parameters:
aNamespaceURI
- the namespace for which unmarshallers are registered on this decoder.
-