@Deprecated public class JibxMarshaller extends AbstractMarshaller implements InitializingBean
Marshaller
and Unmarshaller
interfaces for JiBX.
The typical usage will be to set the targetClass
and optionally the
bindingName
property on this bean.
org.jibx.runtime.IMarshallingContext
,
org.jibx.runtime.IUnmarshallingContext
Modifier and Type | Field and Description |
---|---|
private IBindingFactory |
bindingFactory
Deprecated.
|
private java.lang.String |
bindingName
Deprecated.
|
private static java.lang.String |
DEFAULT_BINDING_NAME
Deprecated.
|
private java.lang.String |
docTypeInternalSubset
Deprecated.
|
private java.lang.String |
docTypePublicId
Deprecated.
|
private java.lang.String |
docTypeRootElementName
Deprecated.
|
private java.lang.String |
docTypeSystemId
Deprecated.
|
private java.lang.String |
encoding
Deprecated.
|
private int |
indent
Deprecated.
|
private java.lang.Boolean |
standalone
Deprecated.
|
private java.lang.Class<?> |
targetClass
Deprecated.
|
private java.lang.String |
targetPackage
Deprecated.
|
private javax.xml.transform.TransformerFactory |
transformerFactory
Deprecated.
|
logger
Constructor and Description |
---|
JibxMarshaller()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Deprecated.
Invoked by the containing
BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware , ApplicationContextAware etc. |
XmlMappingException |
convertJibxException(JiBXException ex,
boolean marshalling)
Deprecated.
Convert the given
JiBXException to an appropriate exception from the
org.springframework.oxm hierarchy. |
protected IMarshallingContext |
createMarshallingContext()
Deprecated.
Create a new
IMarshallingContext , configured with the correct indentation. |
protected IUnmarshallingContext |
createUnmarshallingContext()
Deprecated.
Create a new
IUnmarshallingContext . |
protected java.lang.String |
getDefaultEncoding()
Deprecated.
Determine the default encoding to use for marshalling or unmarshalling from
a byte stream, or
null if none. |
private void |
marshalDocument(IMarshallingContext marshallingContext,
java.lang.Object graph)
Deprecated.
|
protected void |
marshalDomNode(java.lang.Object graph,
org.w3c.dom.Node node)
Deprecated.
Abstract template method for marshalling the given object graph to a DOM
Node . |
protected void |
marshalOutputStream(java.lang.Object graph,
java.io.OutputStream outputStream)
Deprecated.
Abstract template method for marshalling the given object graph to a
OutputStream . |
protected void |
marshalSaxHandlers(java.lang.Object graph,
org.xml.sax.ContentHandler contentHandler,
org.xml.sax.ext.LexicalHandler lexicalHandler)
Deprecated.
Abstract template method for marshalling the given object graph to a SAX
ContentHandler . |
protected void |
marshalWriter(java.lang.Object graph,
java.io.Writer writer)
Deprecated.
Abstract template method for marshalling the given object graph to a
Writer . |
protected void |
marshalXmlEventWriter(java.lang.Object graph,
javax.xml.stream.XMLEventWriter eventWriter)
Deprecated.
Abstract template method for marshalling the given object to a StAX
XMLEventWriter . |
protected void |
marshalXmlStreamWriter(java.lang.Object graph,
javax.xml.stream.XMLStreamWriter streamWriter)
Deprecated.
Abstract template method for marshalling the given object to a StAX
XMLStreamWriter . |
void |
setBindingName(java.lang.String bindingName)
Deprecated.
Set the optional binding name for this instance.
|
void |
setDocTypeInternalSubset(java.lang.String docTypeInternalSubset)
Deprecated.
Set the internal subset Id for the DTD declaration written when marshalling.
|
void |
setDocTypePublicId(java.lang.String docTypePublicId)
Deprecated.
Set the public id for the DTD declaration written when marshalling.
|
void |
setDocTypeRootElementName(java.lang.String docTypeRootElementName)
Deprecated.
Set the root element name for the DTD declaration written when marshalling.
|
void |
setDocTypeSystemId(java.lang.String docTypeSystemId)
Deprecated.
Set the system id for the DTD declaration written when marshalling.
|
void |
setEncoding(java.lang.String encoding)
Deprecated.
Set the document encoding using for marshalling.
|
void |
setIndent(int indent)
Deprecated.
Set the number of nesting indent spaces.
|
void |
setStandalone(java.lang.Boolean standalone)
Deprecated.
Set the document standalone flag for marshalling.
|
void |
setTargetClass(java.lang.Class<?> targetClass)
Deprecated.
Set the target class for this instance.
|
void |
setTargetPackage(java.lang.String targetPackage)
Deprecated.
Set the target package for this instance.
|
boolean |
supports(java.lang.Class<?> clazz)
Deprecated.
Indicate whether this marshaller can marshal instances of the supplied type.
|
private void |
transformAndMarshal(java.lang.Object graph,
javax.xml.transform.Result result)
Deprecated.
|
private java.lang.Object |
transformAndUnmarshal(javax.xml.transform.Source source,
java.lang.String encoding)
Deprecated.
|
protected java.lang.Object |
unmarshalDomNode(org.w3c.dom.Node node)
Deprecated.
Abstract template method for unmarshalling from a given DOM
Node . |
protected java.lang.Object |
unmarshalInputStream(java.io.InputStream inputStream)
Deprecated.
Abstract template method for unmarshalling from a given
InputStream . |
protected java.lang.Object |
unmarshalReader(java.io.Reader reader)
Deprecated.
Abstract template method for unmarshalling from a given
Reader . |
protected java.lang.Object |
unmarshalSaxReader(org.xml.sax.XMLReader xmlReader,
org.xml.sax.InputSource inputSource)
Deprecated.
Abstract template method for unmarshalling using a given SAX
XMLReader
and InputSource . |
protected java.lang.Object |
unmarshalXmlEventReader(javax.xml.stream.XMLEventReader eventReader)
Deprecated.
Abstract template method for unmarshalling from a given Stax
XMLEventReader . |
protected java.lang.Object |
unmarshalXmlStreamReader(javax.xml.stream.XMLStreamReader streamReader)
Deprecated.
Abstract template method for unmarshalling from a given Stax
XMLStreamReader . |
buildDocument, createDocumentBuilder, createDocumentBuilderFactory, createXmlReader, isProcessExternalEntities, isSupportDtd, marshal, marshalDomResult, marshalSaxResult, marshalStaxResult, marshalStreamResult, setProcessExternalEntities, setSupportDtd, unmarshal, unmarshalDomSource, unmarshalSaxSource, unmarshalStaxSource, unmarshalStreamSource
private static final java.lang.String DEFAULT_BINDING_NAME
@Nullable private java.lang.Class<?> targetClass
@Nullable private java.lang.String targetPackage
@Nullable private java.lang.String bindingName
private int indent
private java.lang.String encoding
@Nullable private java.lang.Boolean standalone
@Nullable private java.lang.String docTypeRootElementName
@Nullable private java.lang.String docTypeSystemId
@Nullable private java.lang.String docTypePublicId
@Nullable private java.lang.String docTypeInternalSubset
@Nullable private IBindingFactory bindingFactory
private final javax.xml.transform.TransformerFactory transformerFactory
public void setTargetClass(java.lang.Class<?> targetClass)
targetPackage
property is required.
If this property is set, targetPackage
is ignored.
public void setTargetPackage(java.lang.String targetPackage)
targetClass
property is required.
If targetClass
is set, this property is ignored.
public void setBindingName(java.lang.String bindingName)
public void setIndent(int indent)
-1
, i.e. no indentation.public void setEncoding(java.lang.String encoding)
protected java.lang.String getDefaultEncoding()
AbstractMarshaller
null
if none.
The default implementation returns null
.
getDefaultEncoding
in class AbstractMarshaller
public void setStandalone(java.lang.Boolean standalone)
public void setDocTypeRootElementName(java.lang.String docTypeRootElementName)
null
(i.e. no DTD declaration is written).
If set to a value, the system ID or public ID also need to be set.
public void setDocTypeSystemId(java.lang.String docTypeSystemId)
null
. Only used when the root element also has been set.
Set either this property or docTypePublicId
, not both.
setDocTypeRootElementName(String)
public void setDocTypePublicId(java.lang.String docTypePublicId)
null
. Only used when the root element also has been set.
Set either this property or docTypeSystemId
, not both.
setDocTypeRootElementName(String)
public void setDocTypeInternalSubset(java.lang.String docTypeInternalSubset)
null
. Only used when the root element also has been set.setDocTypeRootElementName(String)
public void afterPropertiesSet() throws JiBXException
InitializingBean
BeanFactory
after it has set all bean properties
and satisfied BeanFactoryAware
, ApplicationContextAware
etc.
This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
afterPropertiesSet
in interface InitializingBean
JiBXException
public boolean supports(java.lang.Class<?> clazz)
Marshaller
supports
in interface Marshaller
supports
in interface Unmarshaller
clazz
- the class that this marshaller is being asked if it can marshaltrue
if this marshaller can indeed marshal instances of the supplied class;
false
otherwiseprotected void marshalOutputStream(java.lang.Object graph, java.io.OutputStream outputStream) throws XmlMappingException, java.io.IOException
AbstractMarshaller
OutputStream
.marshalOutputStream
in class AbstractMarshaller
graph
- the root of the object graph to marshaloutputStream
- the OutputStream
to write toXmlMappingException
- if the given object cannot be marshalled to the writerjava.io.IOException
- if an I/O exception occursprotected void marshalWriter(java.lang.Object graph, java.io.Writer writer) throws XmlMappingException, java.io.IOException
AbstractMarshaller
Writer
.marshalWriter
in class AbstractMarshaller
graph
- the root of the object graph to marshalwriter
- the Writer
to write toXmlMappingException
- if the given object cannot be marshalled to the writerjava.io.IOException
- if an I/O exception occursprivate void marshalDocument(IMarshallingContext marshallingContext, java.lang.Object graph) throws java.io.IOException, JiBXException
java.io.IOException
JiBXException
protected void marshalDomNode(java.lang.Object graph, org.w3c.dom.Node node) throws XmlMappingException
AbstractMarshaller
Node
.
In practice, node is be a Document
node, a DocumentFragment
node,
or a Element
node. In other words, a node that accepts children.
marshalDomNode
in class AbstractMarshaller
graph
- the root of the object graph to marshalnode
- the DOM node that will contain the result treeXmlMappingException
- if the given object cannot be marshalled to the DOM nodeDocument
,
DocumentFragment
,
Element
protected void marshalXmlEventWriter(java.lang.Object graph, javax.xml.stream.XMLEventWriter eventWriter)
AbstractMarshaller
XMLEventWriter
.marshalXmlEventWriter
in class AbstractMarshaller
graph
- the root of the object graph to marshaleventWriter
- the XMLEventWriter
to write toprotected void marshalXmlStreamWriter(java.lang.Object graph, javax.xml.stream.XMLStreamWriter streamWriter) throws XmlMappingException
AbstractMarshaller
XMLStreamWriter
.marshalXmlStreamWriter
in class AbstractMarshaller
graph
- the root of the object graph to marshalstreamWriter
- the XMLStreamWriter
to write toXmlMappingException
- if the given object cannot be marshalled to the DOM nodeprotected void marshalSaxHandlers(java.lang.Object graph, org.xml.sax.ContentHandler contentHandler, @Nullable org.xml.sax.ext.LexicalHandler lexicalHandler) throws XmlMappingException
AbstractMarshaller
ContentHandler
.marshalSaxHandlers
in class AbstractMarshaller
graph
- the root of the object graph to marshalcontentHandler
- the SAX ContentHandler
lexicalHandler
- the SAX2 LexicalHandler
. Can be null
.XmlMappingException
- if the given object cannot be marshalled to the handlersprivate void transformAndMarshal(java.lang.Object graph, javax.xml.transform.Result result) throws java.io.IOException
java.io.IOException
protected java.lang.Object unmarshalXmlEventReader(javax.xml.stream.XMLEventReader eventReader)
AbstractMarshaller
XMLEventReader
.unmarshalXmlEventReader
in class AbstractMarshaller
eventReader
- the XMLEventReader
to read fromprotected java.lang.Object unmarshalXmlStreamReader(javax.xml.stream.XMLStreamReader streamReader)
AbstractMarshaller
XMLStreamReader
.unmarshalXmlStreamReader
in class AbstractMarshaller
streamReader
- the XMLStreamReader
to read fromprotected java.lang.Object unmarshalInputStream(java.io.InputStream inputStream) throws XmlMappingException, java.io.IOException
AbstractMarshaller
InputStream
.unmarshalInputStream
in class AbstractMarshaller
inputStream
- the InputStreamStream
to read fromXmlMappingException
- if the given stream cannot be converted to an objectjava.io.IOException
- if an I/O exception occursprotected java.lang.Object unmarshalReader(java.io.Reader reader) throws XmlMappingException, java.io.IOException
AbstractMarshaller
Reader
.unmarshalReader
in class AbstractMarshaller
reader
- the Reader
to read fromXmlMappingException
- if the given reader cannot be converted to an objectjava.io.IOException
- if an I/O exception occursprotected java.lang.Object unmarshalDomNode(org.w3c.dom.Node node) throws XmlMappingException
AbstractMarshaller
Node
.unmarshalDomNode
in class AbstractMarshaller
node
- the DOM node that contains the objects to be unmarshalledXmlMappingException
- if the given DOM node cannot be mapped to an objectprotected java.lang.Object unmarshalSaxReader(org.xml.sax.XMLReader xmlReader, org.xml.sax.InputSource inputSource) throws XmlMappingException, java.io.IOException
AbstractMarshaller
XMLReader
and InputSource
.unmarshalSaxReader
in class AbstractMarshaller
xmlReader
- the SAX XMLReader
to parse withinputSource
- the input source to parse fromXmlMappingException
- if the given reader and input source cannot be converted to an objectjava.io.IOException
- if an I/O exception occursprivate java.lang.Object transformAndUnmarshal(javax.xml.transform.Source source, @Nullable java.lang.String encoding) throws java.io.IOException
java.io.IOException
protected IMarshallingContext createMarshallingContext() throws JiBXException
IMarshallingContext
, configured with the correct indentation.JiBXException
- in case of errorsprotected IUnmarshallingContext createUnmarshallingContext() throws JiBXException
IUnmarshallingContext
.JiBXException
- in case of errorspublic XmlMappingException convertJibxException(JiBXException ex, boolean marshalling)
JiBXException
to an appropriate exception from the
org.springframework.oxm
hierarchy.
A boolean flag is used to indicate whether this exception occurs during marshalling or unmarshalling, since JiBX itself does not make this distinction in its exception hierarchy.
ex
- JiBXException
that occurredmarshalling
- indicates whether the exception occurs during marshalling (true
),
or unmarshalling (false
)XmlMappingException