public final class MarshallerImpl extends AbstractMarshallerImpl implements ValidationEventHandler
Marshaller interface for the JAXB RI.
Eventually all the marshal(java.lang.Object, java.io.OutputStream, javax.xml.namespace.NamespaceContext) methods call into
the write(com.sun.xml.bind.v2.runtime.Name, com.sun.xml.bind.v2.runtime.JaxBeanInfo<T>, T, com.sun.xml.bind.v2.runtime.output.XmlOutput, java.lang.Runnable) method.
Marshaller.Listener| Modifier and Type | Field and Description |
|---|---|
protected static String |
C14N |
protected static String |
ENCODING_HANDLER |
protected static String |
ENCODING_HANDLER2 |
protected static String |
INDENT_STRING |
protected static String |
OBJECT_IDENTITY_CYCLE_DETECTION |
protected static String |
PREFIX_MAPPER |
protected XMLSerializer |
serializer |
protected static String |
XML_HEADERS |
protected static String |
XMLDECLARATION |
JAXB_ENCODING, JAXB_FORMATTED_OUTPUT, JAXB_FRAGMENT, JAXB_NO_NAMESPACE_SCHEMA_LOCATION, JAXB_SCHEMA_LOCATION| Constructor and Description |
|---|
MarshallerImpl(JAXBContextImpl c,
AssociationMap assoc) |
| Modifier and Type | Method and Description |
|---|---|
protected CharacterEscapeHandler |
createEscapeHandler(String encoding) |
XmlOutput |
createWriter(OutputStream os) |
XmlOutput |
createWriter(OutputStream os,
String encoding) |
XmlOutput |
createWriter(Writer w) |
XmlOutput |
createWriter(Writer w,
String encoding) |
<A extends XmlAdapter> |
getAdapter(Class<A> type)
Gets the adapter associated with the specified type.
|
AttachmentMarshaller |
getAttachmentMarshaller() |
JAXBContextImpl |
getContext() |
Marshaller.Listener |
getListener()
Return
Marshaller.Listener registered with this Marshaller. |
Object |
getProperty(String name)
Default implementation of the getProperty method handles
the four defined properties in Marshaller.
|
Schema |
getSchema()
Get the JAXP 1.3
Schema object
being used to perform marshal-time validation. |
boolean |
handleEvent(ValidationEvent event)
Default error handling behavior fot
Marshaller. |
void |
marshal(Object obj,
OutputStream out,
NamespaceContext inscopeNamespace)
Marshals to
OutputStream with the given in-scope namespaces
taken into account. |
void |
marshal(Object target,
Result result)
Marshal the content tree rooted at jaxbElement into the specified
javax.xml.transform.Result.
|
void |
marshal(Object obj,
XMLEventWriter writer)
Marshal the content tree rooted at jaxbElement into a
XMLEventWriter. |
void |
marshal(Object obj,
XmlOutput output) |
void |
marshal(Object obj,
XMLStreamWriter writer)
Marshal the content tree rooted at jaxbElement into a
XMLStreamWriter. |
<A extends XmlAdapter> |
setAdapter(Class<A> type,
A adapter)
Associates a configured instance of
XmlAdapter with this marshaller. |
void |
setAttachmentMarshaller(AttachmentMarshaller am)
Associate a context that enables binary data within an XML document
to be transmitted as XML-binary optimized attachment.
|
void |
setListener(Marshaller.Listener listener)
Register marshal event callback
Marshaller.Listener with this Marshaller. |
void |
setProperty(String name,
Object value)
Default implementation of the setProperty method handles
the four defined properties in Marshaller.
|
void |
setSchema(Schema s)
Specify the JAXP 1.3
Schema
object that should be used to validate subsequent marshal operations
against. |
protected <T> void |
write(Name rootTagName,
JaxBeanInfo<T> bi,
T obj,
XmlOutput out,
Runnable postInitAction)
Used by
BridgeImpl to write an arbitrary object as a fragment. |
getEncoding, getEventHandler, getJavaEncoding, getNode, getNoNSSchemaLocation, getSchemaLocation, isFormattedOutput, isFragment, marshal, marshal, marshal, marshal, marshal, setAdapter, setEncoding, setEventHandler, setFormattedOutput, setFragment, setNoNSSchemaLocation, setSchemaLocationprotected final XMLSerializer serializer
protected static final String INDENT_STRING
protected static final String PREFIX_MAPPER
protected static final String ENCODING_HANDLER
protected static final String ENCODING_HANDLER2
protected static final String XMLDECLARATION
protected static final String XML_HEADERS
protected static final String C14N
protected static final String OBJECT_IDENTITY_CYCLE_DETECTION
public MarshallerImpl(JAXBContextImpl c, AssociationMap assoc)
assoc - non-null if the marshaller is working inside BinderImpl.public JAXBContextImpl getContext()
public void marshal(Object obj, OutputStream out, NamespaceContext inscopeNamespace) throws JAXBException
OutputStream with the given in-scope namespaces
taken into account.JAXBExceptionpublic void marshal(Object obj, XMLStreamWriter writer) throws JAXBException
MarshallerXMLStreamWriter.marshal in interface Marshallermarshal in class AbstractMarshallerImplobj - The content tree to be marshalled.writer - XML will be sent to this writer.JAXBException - If any unexpected problem occurs during the marshalling.MarshalException - If the ValidationEventHandler
returns false from its handleEvent method or the
Marshaller is unable to marshal obj (or any
object reachable from obj). See
Marshalling a JAXB element.public void marshal(Object obj, XMLEventWriter writer) throws JAXBException
MarshallerXMLEventWriter.marshal in interface Marshallermarshal in class AbstractMarshallerImplobj - The content tree rooted at jaxbElement to be marshalled.writer - XML will be sent to this writer.JAXBException - If any unexpected problem occurs during the marshalling.MarshalException - If the ValidationEventHandler
returns false from its handleEvent method or the
Marshaller is unable to marshal obj (or any
object reachable from obj). See
Marshalling a JAXB element.public void marshal(Object obj, XmlOutput output) throws JAXBException
JAXBExceptionpublic void marshal(Object target, Result result) throws JAXBException
Marshaller
All JAXB Providers must at least support
DOMResult,
SAXResult, and
StreamResult. It can
support other derived classes of Result as well.
marshal in interface Marshallertarget - The root of content tree to be marshalled.result - XML will be sent to this ResultJAXBException - If any unexpected problem occurs during the marshalling.MarshalException - If the ValidationEventHandler
returns false from its handleEvent method or the
Marshaller is unable to marshal obj (or any
object reachable from obj). See
Marshalling a JAXB element.protected final <T> void write(Name rootTagName, JaxBeanInfo<T> bi, T obj, XmlOutput out, Runnable postInitAction) throws JAXBException
BridgeImpl to write an arbitrary object as a fragment.JAXBExceptionprotected CharacterEscapeHandler createEscapeHandler(String encoding)
public XmlOutput createWriter(OutputStream os) throws JAXBException
JAXBExceptionpublic XmlOutput createWriter(OutputStream os, String encoding) throws JAXBException
JAXBExceptionpublic Object getProperty(String name) throws PropertyException
AbstractMarshallerImplgetProperty in interface MarshallergetProperty in class AbstractMarshallerImplname - the name of the property to retrievePropertyException - when there is an error retrieving the given property or value
property namepublic void setProperty(String name, Object value) throws PropertyException
AbstractMarshallerImplsetProperty in interface MarshallersetProperty in class AbstractMarshallerImplname - the name of the property to be set. This value can either
be specified using one of the constant fields or a user
supplied string.value - the value of the property to be setPropertyException - when there is an error processing the given
property or valuepublic <A extends XmlAdapter> void setAdapter(Class<A> type, A adapter)
MarshallerXmlAdapter with this marshaller.
Every marshaller internally maintains a
Map<Class,XmlAdapter>,
which it uses for marshalling classes whose fields/methods are annotated
with XmlJavaTypeAdapter.
This method allows applications to use a configured instance of XmlAdapter.
When an instance of an adapter is not given, a marshaller will create
one by invoking its default constructor.
setAdapter in interface MarshallersetAdapter in class AbstractMarshallerImpltype - The type of the adapter. The specified instance will be used when
XmlJavaTypeAdapter.value()
refers to this type.adapter - The instance of the adapter to be used. If null, it will un-register
the current adapter set for this type.public <A extends XmlAdapter> A getAdapter(Class<A> type)
MarshallerMarshaller.setAdapter(javax.xml.bind.annotation.adapters.XmlAdapter) method.getAdapter in interface MarshallergetAdapter in class AbstractMarshallerImplpublic void setAttachmentMarshaller(AttachmentMarshaller am)
MarshallerAssociate a context that enables binary data within an XML document to be transmitted as XML-binary optimized attachment. The attachment is referenced from the XML document content model by content-id URIs(cid) references stored within the xml document.
setAttachmentMarshaller in interface MarshallersetAttachmentMarshaller in class AbstractMarshallerImplpublic AttachmentMarshaller getAttachmentMarshaller()
getAttachmentMarshaller in interface MarshallergetAttachmentMarshaller in class AbstractMarshallerImplpublic Schema getSchema()
MarshallerSchema object
being used to perform marshal-time validation. If there is no
Schema set on the marshaller, then this method will return null
indicating that marshal-time validation will not be performed.getSchema in interface MarshallergetSchema in class AbstractMarshallerImplpublic void setSchema(Schema s)
MarshallerSchema
object that should be used to validate subsequent marshal operations
against. Passing null into this method will disable validation.
This method allows the caller to validate the marshalled XML as it's marshalled.
Initially this property is set to null.
setSchema in interface MarshallersetSchema in class AbstractMarshallerImpls - Schema object to validate marshal operations against or null to disable validationpublic boolean handleEvent(ValidationEvent event)
Marshaller.handleEvent in interface ValidationEventHandlerevent - the encapsulated validation event information. It is a
provider error if this parameter is null.public Marshaller.Listener getListener()
MarshallerReturn Marshaller.Listener registered with this Marshaller.
getListener in interface MarshallergetListener in class AbstractMarshallerImplMarshaller.Listener or null if no Listener is registered with this Marshaller.public void setListener(Marshaller.Listener listener)
Marshaller
Register marshal event callback Marshaller.Listener with this Marshaller.
There is only one Listener per Marshaller. Setting a Listener replaces the previous set Listener. One can unregister current Listener by setting listener to null.
setListener in interface MarshallersetListener in class AbstractMarshallerImpllistener - an instance of a class that implements Marshaller.ListenerCopyright © 2017 JBoss by Red Hat. All rights reserved.