public class BadgerMarshaller extends BaseMarshaller
Marshaller.Listener
charset, marshaller
JAXB_ENCODING, JAXB_FORMATTED_OUTPUT, JAXB_FRAGMENT, JAXB_NO_NAMESPACE_SCHEMA_LOCATION, JAXB_SCHEMA_LOCATION
Constructor and Description |
---|
BadgerMarshaller(JAXBContext context) |
Modifier and Type | Method and Description |
---|---|
<A extends XmlAdapter> |
getAdapter(Class<A> aClass)
Gets the adapter associated with the specified type.
|
AttachmentMarshaller |
getAttachmentMarshaller() |
ValidationEventHandler |
getEventHandler()
Return the current event handler or the default event handler if one
hasn't been set.
|
Marshaller.Listener |
getListener()
Return
Marshaller.Listener registered with this Marshaller . |
Node |
getNode(Object o)
Get a DOM tree view of the content tree(Optional).
|
Object |
getProperty(String s)
Get the particular property in the underlying implementation of
Marshaller.
|
Schema |
getSchema()
Get the JAXP 1.3
Schema object
being used to perform marshal-time validation. |
void |
marshal(Object o,
ContentHandler contentHandler)
Marshal the content tree rooted at jaxbElement into SAX2 events.
|
void |
marshal(Object o,
File file)
Marshal the content tree rooted at jaxbElement into a file.
|
void |
marshal(Object o,
Node node)
Marshal the content tree rooted at jaxbElement into a DOM tree.
|
void |
marshal(Object o,
Result result)
Marshal the content tree rooted at jaxbElement into the specified
javax.xml.transform.Result.
|
void |
marshal(Object o,
Writer writer)
Marshal the content tree rooted at jaxbElement into a Writer.
|
void |
marshal(Object o,
XMLEventWriter xmlEventWriter)
Marshal the content tree rooted at jaxbElement into a
XMLEventWriter . |
void |
marshal(Object o,
XMLStreamWriter xmlStreamWriter)
Marshal the content tree rooted at jaxbElement into a
XMLStreamWriter . |
<A extends XmlAdapter> |
setAdapter(Class<A> aClass,
A a)
Associates a configured instance of
XmlAdapter with this marshaller. |
void |
setAdapter(XmlAdapter xmlAdapter)
Associates a configured instance of
XmlAdapter with this marshaller. |
void |
setAttachmentMarshaller(AttachmentMarshaller attachmentMarshaller)
Associate a context that enables binary data within an XML document
to be transmitted as XML-binary optimized attachment.
|
void |
setEventHandler(ValidationEventHandler validationEventHandler)
Allow an application to register a validation event handler.
|
void |
setListener(Marshaller.Listener listener)
Register marshal event callback
Marshaller.Listener with this Marshaller . |
void |
setSchema(Schema schema)
Specify the JAXP 1.3
Schema
object that should be used to validate subsequent marshal operations
against. |
marshal, setProperty
public BadgerMarshaller(JAXBContext context) throws JAXBException
JAXBException
public void marshal(Object o, 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.
o
- 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.public void marshal(Object o, File file) throws JAXBException
Marshaller
o
- The root of content tree to be marshalled.file
- File to be written. If this file already exists, it will be overwritten.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 o, Writer writer) throws JAXBException
Marshaller
o
- The root of 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 o, ContentHandler contentHandler) throws JAXBException
Marshaller
o
- The root of content tree to be marshalled.contentHandler
- XML will be sent to this handler as SAX2 events.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 o, Node node) throws JAXBException
Marshaller
o
- The content tree to be marshalled.node
- DOM nodes will be added as children of this node.
This parameter must be a Node that accepts children
(Document
,
DocumentFragment
, or
Element
)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 jaxbElement (or any
object reachable from jaxbElement). See
Marshalling a JAXB element.public void marshal(Object o, XMLStreamWriter xmlStreamWriter) throws JAXBException
Marshaller
XMLStreamWriter
.o
- The content tree to be marshalled.xmlStreamWriter
- 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 o, XMLEventWriter xmlEventWriter) throws JAXBException
Marshaller
XMLEventWriter
.o
- The content tree rooted at jaxbElement to be marshalled.xmlEventWriter
- 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 Node getNode(Object o) throws JAXBException
Marshaller
Marshaller.marshal(Object, org.w3c.dom.Node)
to force
a deep copy of the content tree to a DOM representation.o
- - JAXB Java representation of XML contentJAXBException
- If any unexpected problem occurspublic Object getProperty(String s) throws PropertyException
Marshaller
s
- the name of the property to retrievePropertyException
- when there is an error retrieving the given property or value
property namepublic void setEventHandler(ValidationEventHandler validationEventHandler) throws JAXBException
Marshaller
The validation event handler will be called by the JAXB Provider if any validation errors are encountered during calls to any of the marshal API's. If the client application does not register a validation event handler before invoking one of the marshal methods, then validation events will be handled by the default event handler which will terminate the marshal operation after the first error or fatal error is encountered.
Calling this method with a null parameter will cause the Marshaller to revert back to the default default event handler.
validationEventHandler
- the validation event handlerJAXBException
- if an error was encountered while setting the
event handlerpublic ValidationEventHandler getEventHandler() throws JAXBException
Marshaller
JAXBException
- if an error was encountered while getting the
current event handlerpublic void setAdapter(XmlAdapter xmlAdapter)
Marshaller
XmlAdapter
with this marshaller.
This is a convenience method that invokes setAdapter(adapter.getClass(),adapter);
.
Marshaller.setAdapter(Class,XmlAdapter)
public <A extends XmlAdapter> void setAdapter(Class<A> aClass, A a)
Marshaller
XmlAdapter
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.
aClass
- The type of the adapter. The specified instance will be used when
XmlJavaTypeAdapter.value()
refers to this type.a
- 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> aClass)
Marshaller
Marshaller.setAdapter(javax.xml.bind.annotation.adapters.XmlAdapter)
method.public void setAttachmentMarshaller(AttachmentMarshaller attachmentMarshaller)
Marshaller
Associate 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.
public AttachmentMarshaller getAttachmentMarshaller()
public void setSchema(Schema schema)
Marshaller
Schema
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.
schema
- Schema object to validate marshal operations against or null to disable validationpublic Schema getSchema()
Marshaller
Schema
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.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.
listener
- an instance of a class that implements Marshaller.Listener
public Marshaller.Listener getListener()
Marshaller
Return Marshaller.Listener
registered with this Marshaller
.
Marshaller.Listener
or null
if no Listener is registered with this Marshaller.Copyright © 2016 JBoss by Red Hat. All rights reserved.