java.lang.Object javax.xml.bind.helpers.AbstractMarshallerImpl
public abstract class AbstractMarshallerImpl
Partial default Marshaller implementation.
This class provides a partial default implementation for the Marshaller interface.
The only methods that a JAXB Provider has to implement are marshal(Object, javax.xml.transform.Result) , marshal(Object, javax.xml.stream.XMLStreamWriter) , and marshal(Object, javax.xml.stream.XMLEventWriter) .
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface javax.xml.bind. Marshaller |
---|
Marshaller.Listener |
Field Summary |
---|
Fields inherited from interface javax.xml.bind. Marshaller |
---|
JAXB_ENCODING , JAXB_FORMATTED_OUTPUT , JAXB_FRAGMENT , JAXB_NO_NAMESPACE_SCHEMA_LOCATION , JAXB_SCHEMA_LOCATION |
Constructor Summary | |
---|---|
AbstractMarshallerImpl
() |
Method Summary | ||
---|---|---|
|
getAdapter
(
Class
<A> type) Gets the adapter associated with the specified type. |
|
AttachmentMarshaller |
getAttachmentMarshaller
() |
|
protected String |
getEncoding
() Convenience method for getting the current output encoding. |
|
ValidationEventHandler |
getEventHandler
() Return the current event handler or the default event handler if one hasn't been set. |
|
protected String |
getJavaEncoding
(
String
encoding) Gets the corresponding Java encoding name from an IANA name. |
|
Marshaller.Listener |
getListener
() Return Marshaller.Listener registered with this Marshaller . |
|
Node |
getNode
(
Object
obj) By default, the getNode method is unsupported and throw an UnsupportedOperationException . |
|
protected String |
getNoNSSchemaLocation
() Convenience method for getting the current noNamespaceSchemaLocation. |
|
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. |
|
protected String |
getSchemaLocation
() Convenience method for getting the current schemaLocation. |
|
protected boolean |
isFormattedOutput
() Convenience method for getting the formatted output flag. |
|
protected boolean |
isFragment
() Convenience method for getting the fragment flag. |
|
void |
marshal
(
Object
obj,
ContentHandler
Marshal the content tree rooted at jaxbElement |
|
void |
marshal
(
Object
obj,
Node
Marshal the content tree rooted at jaxbElement |
|
void |
marshal
(
Object
obj,
OutputStream
Marshal the content tree rooted at jaxbElement |
|
void |
marshal
(
Object
obj,
Writer
Marshal the content tree rooted at jaxbElement |
|
void |
marshal
(
Object
obj,
XMLEventWriter
Marshal the content tree rooted at jaxbElement |
|
void |
marshal
(
Object
obj,
XMLStreamWriter
Marshal the content tree rooted at jaxbElement |
|
|
setAdapter
(
Class
<A> type, A adapter) Associates a configured instance of XmlAdapter with this marshaller. |
|
void |
setAdapter
(
XmlAdapter
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. |
|
protected void |
setEncoding
(
String
encoding) Convenience method for setting the output encoding. |
|
void |
setEventHandler
(
ValidationEventHandler
handler) Allow an application to register a validation event handler. |
|
protected void |
setFormattedOutput
(boolean v) Convenience method for setting the formatted output flag. |
|
protected void |
setFragment
(boolean v) Convenience method for setting the fragment flag. |
|
void |
setListener
(
Marshaller.Listener
listener) Register marshal event callback Marshaller.Listener with this Marshaller . |
|
protected void |
setNoNSSchemaLocation
(
String
location) Convenience method for setting the noNamespaceSchemaLocation. |
|
void |
setProperty
(
String
name,
Object
value) Default implementation of the setProperty method handles the four defined properties in Marshaller. |
|
void |
setSchema
(
Schema
schema) Specify the JAXP 1.3 Schema object that should be used to validate subsequent marshal operations against. |
|
protected void |
setSchemaLocation
(
String
location) Convenience method for setting the schemaLocation. |
Methods inherited from class java.lang. Object |
---|
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait |
Methods inherited from interface javax.xml.bind. Marshaller |
---|
marshal |
Constructor Detail |
---|
public AbstractMarshallerImpl()
Method Detail |
---|
public final void marshal(Object obj, OutputStream os) throws JAXBException
public final void marshal(Object obj, Writer w) throws JAXBException
public final void marshal(Object obj, ContentHandler handler) throws JAXBException
public final void marshal(Object obj, Node node) throws JAXBException
public Node getNode(Object obj) throws JAXBException
protected String getEncoding()
protected void setEncoding(String encoding)
protected String getSchemaLocation()
protected void setSchemaLocation(String location)
protected String getNoNSSchemaLocation()
protected void setNoNSSchemaLocation(String location)
protected boolean isFormattedOutput()
protected void setFormattedOutput(boolean v)
protected boolean isFragment()
protected void setFragment(boolean v)
protected String getJavaEncoding(String encoding) throws UnsupportedEncodingException
public void setProperty(String name, Object value) throws PropertyException
public Object getProperty(String name) throws PropertyException
public ValidationEventHandler getEventHandler() throws JAXBException
public void setEventHandler(ValidationEventHandler handler) throws JAXBException
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.
public void marshal(Object obj, XMLEventWriter writer) throws JAXBException
public void marshal(Object obj, XMLStreamWriter writer) throws JAXBException
public void setSchema(Schema schema)
This method allows the caller to validate the marshalled XML as it's marshalled.
Initially this property is set to null .
public Schema getSchema()
public void setAdapter(XmlAdapter adapter)
This is a convenience method that invokes setAdapter(adapter.getClass(),adapter);.
public <A extends XmlAdapter> void setAdapter(Class<A> type, A adapter)
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.
public <A extends XmlAdapter> A getAdapter(Class<A> type)
public void setAttachmentMarshaller(AttachmentMarshaller am)
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 setListener(Marshaller.Listener listener)
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 .
public Marshaller.Listener getListener()
Return Marshaller.Listener registered with this Marshaller .