spring-framework / org.springframework.oxm.jibx / JibxMarshaller

JibxMarshaller

open class JibxMarshaller : AbstractMarshaller, InitializingBean

Implementation of the Marshaller and Unmarshaller interfaces for JiBX.

The typical usage will be to set the targetClass and optionally the bindingName property on this bean.

Author
Arjen Poutsma

Since
3.0

See Also
org.jibx.runtime.IMarshallingContextorg.jibx.runtime.IUnmarshallingContext

Constructors

<init>

JibxMarshaller()

Implementation of the Marshaller and Unmarshaller interfaces for JiBX.

The typical usage will be to set the targetClass and optionally the bindingName property on this bean.

Functions

afterPropertiesSet

open fun afterPropertiesSet(): Unit

convertJibxException

open fun convertJibxException(ex: JiBXException, marshalling: Boolean): XmlMappingException

Convert the given 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.

setBindingName

open fun setBindingName(bindingName: String): Unit

Set the optional binding name for this instance.

setDocTypeInternalSubset

open fun setDocTypeInternalSubset(docTypeInternalSubset: String): Unit

Set the internal subset Id for the DTD declaration written when marshalling. By default, this is null. Only used when the root element also has been set.

setDocTypePublicId

open fun setDocTypePublicId(docTypePublicId: String): Unit

Set the public id for the DTD declaration written when marshalling. By default, this is null. Only used when the root element also has been set.

Set either this property or docTypeSystemId, not both.

setDocTypeRootElementName

open fun setDocTypeRootElementName(docTypeRootElementName: String): Unit

Set the root element name for the DTD declaration written when marshalling. By default, this is null (i.e. no DTD declaration is written).

If set to a value, the system ID or public ID also need to be set.

setDocTypeSystemId

open fun setDocTypeSystemId(docTypeSystemId: String): Unit

Set the system id for the DTD declaration written when marshalling. By default, this is null. Only used when the root element also has been set.

Set either this property or docTypePublicId, not both.

setEncoding

open fun setEncoding(encoding: String): Unit

Set the document encoding using for marshalling. Default is UTF-8.

setIndent

open fun setIndent(indent: Int): Unit

Set the number of nesting indent spaces. Default is -1, i.e. no indentation.

setStandalone

open fun setStandalone(standalone: Boolean): Unit

Set the document standalone flag for marshalling. By default, this flag is not present.

setTargetClass

open fun setTargetClass(targetClass: Class<*>): Unit

Set the target class for this instance. Setting either this property or the targetPackage property is required.

If this property is set, targetPackage is ignored.

setTargetPackage

open fun setTargetPackage(targetPackage: String): Unit

Set the target package for this instance. Setting either this property or the targetClass property is required.

If targetClass is set, this property is ignored.

supports

open fun supports(clazz: Class<*>): Boolean

Inherited Functions

isProcessExternalEntities

open fun isProcessExternalEntities(): Boolean

Returns the configured value for whether XML external entities are allowed.

isSupportDtd

open fun isSupportDtd(): Boolean

Whether DTD parsing is supported.

marshal

fun marshal(graph: Any, result: Result): Unit

Marshals the object graph with the given root into the provided javax.xml.transform.Result.

This implementation inspects the given result, and calls marshalDomResult, marshalSaxResult, or marshalStreamResult.

setProcessExternalEntities

open fun setProcessExternalEntities(processExternalEntities: Boolean): Unit

Indicates whether external XML entities are processed when unmarshalling.

Default is false, meaning that external entities are not resolved. Note that processing of external entities will only be enabled/disabled when the Source passed to #unmarshal(Source) is a SAXSource or StreamSource. It has no effect for DOMSource or StAXSource instances.

Note: setting this option to true also automatically sets #setSupportDtd to true.

setSupportDtd

open fun setSupportDtd(supportDtd: Boolean): Unit

Indicates whether DTD parsing should be supported.

Default is false meaning that DTD is disabled.

unmarshal

fun unmarshal(source: Source): Any

Unmarshals the given provided javax.xml.transform.Source into an object graph.

This implementation inspects the given result, and calls unmarshalDomSource, unmarshalSaxSource, or unmarshalStreamSource.