public class TLcdXMLEncoder extends Object implements ILcdOutputStreamFactoryCapable
ILcdXMLMarshaller
's.
This encoder will set up a new XMLStreamWriter for each Java object graph to be marshalled, create
a new document context, look up a marshaller for the root element of the
Java object graph and delegate the marshalling process to this marshaller.
This encoder 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 |
---|
TLcdXMLEncoder()
Create a new, empty
TLcdXMLEncoder . |
TLcdXMLEncoder(ILcdXMLEncoderLibrary aLibrary)
Create a new
TLcdXMLEncoder for the specified encoder library. |
TLcdXMLEncoder(List<ILcdXMLEncoderLibrary> aLibraries)
Create a new
TLcdXMLEncoder for the specified encoder libraries. |
TLcdXMLEncoder(List<ILcdXMLEncoderLibrary> aLibraries,
TLcdXMLMapping aMapping) |
Modifier and Type | Method and Description |
---|---|
ILcdXMLDocumentContext |
createDocumentContext()
Creates a new
ILcdXMLDocumentContext that can be used during encoding of an XML
document. |
void |
encode(Object aObject,
OutputStream aDestination)
Marshals the specified Java object to XML data, written to the specified
OutputStream . |
void |
encode(Object aObject,
OutputStream aDestination,
ILcdXMLDocumentContext aDocumentContext)
Marshals the specified Java object to XML data, written to the specified
OutputStream . |
void |
encode(Object aObject,
QName aRootElementName,
OutputStream aDestination)
Marshals the specified Java object to XML data, written to the specified
OutputStream . |
void |
encode(Object aObject,
QName aRootElementName,
OutputStream aDestination,
ILcdXMLDocumentContext aDocumentContext)
Marshals the specified Java object to XML data, written to the specified
OutputStream . |
void |
encode(Object aObject,
String aDestinationName)
Marshals the specified Java object to XML data, written to the specified destination.
|
TLcdXMLMapping |
getMapping()
Returns the
TLcdXMLMapping associated with this encoder. |
TLcdXMLMarshallerProvider |
getMarshallerProvider()
Returns the marshaller provider for this XML encoder, containing marshallers for
converting Java object graphs to XML data.
|
Set<String> |
getNamespaceURIs()
Returns the set of namespaces which are supported by this encoder.
|
ILcdOutputStreamFactory |
getOutputStreamFactory()
Returns the
com.luciad.io.ILcdOutputStreamFactory that is used by this encoder for
creating output streams. |
XMLOutputFactory |
getXMLOutputFactory()
Returns the
javax.xml.stream.XMLOutputFactory that is used by this encoder for creating
javax.xml.stream.XMLStreamWriter instances. |
void |
registerNamespaceURI(String aNamespaceURI,
String aPrefix)
Registers the specified namespace on this encoder.
|
void |
setOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory)
Sets the
com.luciad.io.ILcdOutputStreamFactory that is to be used by this encoder for
creating output streams. |
void |
setXMLOutputFactory(XMLOutputFactory aXMLOutputFactory)
Sets the
javax.xml.stream.XMLOutputFactory to be used by this encoder for creating
javax.xml.stream.XMLStreamWriter instances. |
public TLcdXMLEncoder()
TLcdXMLEncoder
.public TLcdXMLEncoder(ILcdXMLEncoderLibrary aLibrary)
TLcdXMLEncoder
for the specified encoder library.
This is a convenience constructor, being identical to:
TLcdXMLEncoder encoder = new TLcdXMLEncoder();
aLibrary.configureEncoder(encoder);
aLibrary
- the encoder library for which to create an XML encoder.public TLcdXMLEncoder(List<ILcdXMLEncoderLibrary> aLibraries)
TLcdXMLEncoder
for the specified encoder libraries.
This is a convenience constructor, being identical to:
TLcdXMLEncoder encoder = new TLcdXMLEncoder();
for ( ILcdXMLEncoderLibrary library : aLibraries ) {
library.configureEncoder( this );
}
aLibraries
- the encoder libraries for which to create an XML encoder.public TLcdXMLEncoder(List<ILcdXMLEncoderLibrary> aLibraries, TLcdXMLMapping aMapping)
public ILcdOutputStreamFactory getOutputStreamFactory()
com.luciad.io.ILcdOutputStreamFactory
that is used by this encoder for
creating output streams.getOutputStreamFactory
in interface ILcdOutputStreamFactoryCapable
com.luciad.io.ILcdOutputStreamFactory
that is used by this encoder for
creating output streams.public void setOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory)
com.luciad.io.ILcdOutputStreamFactory
that is to be used by this encoder for
creating output streams.setOutputStreamFactory
in interface ILcdOutputStreamFactoryCapable
aOutputStreamFactory
- the com.luciad.io.ILcdOutputStreamFactory
that is to beused by this encoder for
creating output streams.public XMLOutputFactory getXMLOutputFactory()
javax.xml.stream.XMLOutputFactory
that is used by this encoder for creating
javax.xml.stream.XMLStreamWriter
instances.javax.xml.stream.XMLOutputFactory
that is used by this encoder for creating
javax.xml.stream.XMLStreamWriter
instances.public void setXMLOutputFactory(XMLOutputFactory aXMLOutputFactory)
javax.xml.stream.XMLOutputFactory
to be used by this encoder for creating
javax.xml.stream.XMLStreamWriter
instances.aXMLOutputFactory
- the javax.xml.stream.XMLOutputFactory
to be used by this encoder
for creating javax.xml.stream.XMLStreamWriter
instances.public ILcdXMLDocumentContext createDocumentContext()
ILcdXMLDocumentContext
that can be used during encoding of an XML
document. A document context may only be used for encoding a single XML document and should
be discarded afterwards.ILcdXMLDocumentContext
that can be used during encoding of an XML
document.public void encode(Object aObject, String aDestinationName) throws XMLStreamException, IOException
aObject
- the Java object to be marshalled.aDestinationName
- the data source to which the data should be written; typically a file name.XMLStreamException
- if an unexpected processing exception occurs during marshalling.IOException
- if an java.io.IOException
occurs during marshalling.public void encode(Object aObject, OutputStream aDestination) throws XMLStreamException, IOException
OutputStream
.aObject
- the Java object to be marshalled.aDestination
- the OutputStream
to which the resulting XML data should be
written.XMLStreamException
- if an unexpected processing exception occurs during marshalling.IOException
- if an java.io.IOException
occurs during marshalling.public void encode(Object aObject, QName aRootElementName, OutputStream aDestination) throws XMLStreamException, IOException
OutputStream
.aObject
- the Java object to be marshalled.aRootElementName
- the name of the root element of the resulting XML data.aDestination
- the OutputStream
to which the resulting XML data should be
written.XMLStreamException
- if an unexpected processing exception occurs during marshalling.IOException
- if an java.io.IOException
occurs during marshalling.public void encode(Object aObject, OutputStream aDestination, ILcdXMLDocumentContext aDocumentContext) throws XMLStreamException, IOException
OutputStream
.aObject
- the Java object to be marshalled.aDestination
- the OutputStream
to which the resulting XML data should be
written.aDocumentContext
- the document context to be used during marshalling.XMLStreamException
- if an unexpected processing exception occurs during marshalling.IOException
- if an java.io.IOException
occurs during marshalling.public void encode(Object aObject, QName aRootElementName, OutputStream aDestination, ILcdXMLDocumentContext aDocumentContext) throws XMLStreamException, IOException
OutputStream
.aObject
- the Java object to be marshalled.aRootElementName
- the name of the root element of the resulting XML data.aDestination
- the OutputStream
to which the resulting XML data should be
written.aDocumentContext
- the document context to be used during marshalling.XMLStreamException
- if an unexpected processing exception occurs during marshalling.IOException
- if an java.io.IOException
occurs during marshalling.public TLcdXMLMarshallerProvider getMarshallerProvider()
public TLcdXMLMapping getMapping()
TLcdXMLMapping
associated with this encoder.TLcdXMLMapping
associated with this decoder.public void registerNamespaceURI(String aNamespaceURI, String aPrefix)
aNamespaceURI
- the namespace for which marshallers are registered on
this encoder.aPrefix
- the preferred prefix to be used for encoding elements in the specified
namespace. If aPrefix
was already registered for another namespace, or
aPrefix == null
, the encoder will choose another prefix itself.