Package com.luciad.format.xml.bind
Class TLcdXMLEncoder
java.lang.Object
com.luciad.format.xml.bind.TLcdXMLEncoder
- All Implemented Interfaces:
ILcdOutputStreamFactoryCapable
Utility class for marshalling Java object graphs into XML documents, using
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.
- Since:
- 9.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new, emptyTLcdXMLEncoder.TLcdXMLEncoder(ILcdXMLEncoderLibrary aLibrary) Create a newTLcdXMLEncoderfor the specified encoder library.TLcdXMLEncoder(List<ILcdXMLEncoderLibrary> aLibraries) Create a newTLcdXMLEncoderfor the specified encoder libraries.TLcdXMLEncoder(List<ILcdXMLEncoderLibrary> aLibraries, TLcdXMLMapping aMapping) -
Method Summary
Modifier and TypeMethodDescriptionCreates a newILcdXMLDocumentContextthat can be used during encoding of an XML document.voidencode(Object aObject, OutputStream aDestination) Marshals the specified Java object to XML data, written to the specifiedOutputStream.voidencode(Object aObject, OutputStream aDestination, ILcdXMLDocumentContext aDocumentContext) Marshals the specified Java object to XML data, written to the specifiedOutputStream.voidMarshals the specified Java object to XML data, written to the specified destination.voidencode(Object aObject, QName aRootElementName, OutputStream aDestination) Marshals the specified Java object to XML data, written to the specifiedOutputStream.voidencode(Object aObject, QName aRootElementName, OutputStream aDestination, ILcdXMLDocumentContext aDocumentContext) Marshals the specified Java object to XML data, written to the specifiedOutputStream.Returns theTLcdXMLMappingassociated with this encoder.Returns the marshaller provider for this XML encoder, containing marshallers for converting Java object graphs to XML data.Returns the set of namespaces which are supported by this encoder.Returns thecom.luciad.io.ILcdOutputStreamFactorythat is used by this encoder for creating output streams.Returns thejavax.xml.stream.XMLOutputFactorythat is used by this encoder for creatingjavax.xml.stream.XMLStreamWriterinstances.voidregisterNamespaceURI(String aNamespaceURI, String aPrefix) Registers the specified namespace on this encoder.voidsetOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory) Sets thecom.luciad.io.ILcdOutputStreamFactorythat is to be used by this encoder for creating output streams.voidsetXMLOutputFactory(XMLOutputFactory aXMLOutputFactory) Sets thejavax.xml.stream.XMLOutputFactoryto be used by this encoder for creatingjavax.xml.stream.XMLStreamWriterinstances.
-
Constructor Details
-
TLcdXMLEncoder
public TLcdXMLEncoder()Create a new, emptyTLcdXMLEncoder. -
TLcdXMLEncoder
Create a newTLcdXMLEncoderfor the specified encoder library. This is a convenience constructor, being identical to:TLcdXMLEncoder encoder = new TLcdXMLEncoder(); aLibrary.configureEncoder(encoder);- Parameters:
aLibrary- the encoder library for which to create an XML encoder.
-
TLcdXMLEncoder
Create a newTLcdXMLEncoderfor the specified encoder libraries. This is a convenience constructor, being identical to:TLcdXMLEncoder encoder = new TLcdXMLEncoder(); for ( ILcdXMLEncoderLibrary library : aLibraries ) { library.configureEncoder( this ); }- Parameters:
aLibraries- the encoder libraries for which to create an XML encoder.
-
TLcdXMLEncoder
-
-
Method Details
-
getOutputStreamFactory
Returns thecom.luciad.io.ILcdOutputStreamFactorythat is used by this encoder for creating output streams.- Specified by:
getOutputStreamFactoryin interfaceILcdOutputStreamFactoryCapable- Returns:
- the
com.luciad.io.ILcdOutputStreamFactorythat is used by this encoder for creating output streams.
-
setOutputStreamFactory
Sets thecom.luciad.io.ILcdOutputStreamFactorythat is to be used by this encoder for creating output streams.- Specified by:
setOutputStreamFactoryin interfaceILcdOutputStreamFactoryCapable- Parameters:
aOutputStreamFactory- thecom.luciad.io.ILcdOutputStreamFactorythat is to beused by this encoder for creating output streams.
-
getXMLOutputFactory
Returns thejavax.xml.stream.XMLOutputFactorythat is used by this encoder for creatingjavax.xml.stream.XMLStreamWriterinstances.- Returns:
- the
javax.xml.stream.XMLOutputFactorythat is used by this encoder for creatingjavax.xml.stream.XMLStreamWriterinstances.
-
setXMLOutputFactory
Sets thejavax.xml.stream.XMLOutputFactoryto be used by this encoder for creatingjavax.xml.stream.XMLStreamWriterinstances.- Parameters:
aXMLOutputFactory- thejavax.xml.stream.XMLOutputFactoryto be used by this encoder for creatingjavax.xml.stream.XMLStreamWriterinstances.
-
createDocumentContext
Creates a newILcdXMLDocumentContextthat 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.- Returns:
- a new
ILcdXMLDocumentContextthat can be used during encoding of an XML document.
-
encode
Marshals the specified Java object to XML data, written to the specified destination.- Parameters:
aObject- the Java object to be marshalled.aDestinationName- the data source to which the data should be written; typically a file name.- Throws:
XMLStreamException- if an unexpected processing exception occurs during marshalling.IOException- if anjava.io.IOExceptionoccurs during marshalling.
-
encode
public void encode(Object aObject, OutputStream aDestination) throws XMLStreamException, IOException Marshals the specified Java object to XML data, written to the specifiedOutputStream.- Parameters:
aObject- the Java object to be marshalled.aDestination- theOutputStreamto which the resulting XML data should be written.- Throws:
XMLStreamException- if an unexpected processing exception occurs during marshalling.IOException- if anjava.io.IOExceptionoccurs during marshalling.
-
encode
public void encode(Object aObject, QName aRootElementName, OutputStream aDestination) throws XMLStreamException, IOException Marshals the specified Java object to XML data, written to the specifiedOutputStream.- Parameters:
aObject- the Java object to be marshalled.aRootElementName- the name of the root element of the resulting XML data.aDestination- theOutputStreamto which the resulting XML data should be written.- Throws:
XMLStreamException- if an unexpected processing exception occurs during marshalling.IOException- if anjava.io.IOExceptionoccurs during marshalling.
-
encode
public void encode(Object aObject, OutputStream aDestination, ILcdXMLDocumentContext aDocumentContext) throws XMLStreamException, IOException Marshals the specified Java object to XML data, written to the specifiedOutputStream.- Parameters:
aObject- the Java object to be marshalled.aDestination- theOutputStreamto which the resulting XML data should be written.aDocumentContext- the document context to be used during marshalling.- Throws:
XMLStreamException- if an unexpected processing exception occurs during marshalling.IOException- if anjava.io.IOExceptionoccurs during marshalling.
-
encode
public void encode(Object aObject, QName aRootElementName, OutputStream aDestination, ILcdXMLDocumentContext aDocumentContext) throws XMLStreamException, IOException Marshals the specified Java object to XML data, written to the specifiedOutputStream.- Parameters:
aObject- the Java object to be marshalled.aRootElementName- the name of the root element of the resulting XML data.aDestination- theOutputStreamto which the resulting XML data should be written.aDocumentContext- the document context to be used during marshalling.- Throws:
XMLStreamException- if an unexpected processing exception occurs during marshalling.IOException- if anjava.io.IOExceptionoccurs during marshalling.
-
getMarshallerProvider
Returns the marshaller provider for this XML encoder, containing marshallers for converting Java object graphs to XML data.- Returns:
- the marshaller provider for this XML encoder.
-
getMapping
Returns theTLcdXMLMappingassociated with this encoder.- Returns:
- the
TLcdXMLMappingassociated with this decoder.
-
registerNamespaceURI
Registers the specified namespace on this encoder. Namespaces should be registered to indicate that they are supported by this encoder.- Parameters:
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. IfaPrefixwas already registered for another namespace, oraPrefix == null, the encoder will choose another prefix itself.
-
getNamespaceURIs
Returns the set of namespaces which are supported by this encoder.- Returns:
- the set of namespaces which aresupported by this encoder.
-