|
Préférences
Moteurs de recherche
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
JavaTM Platform, Enterprise Edition, v 5.0
javax.xml.bind
|
Nested Class Summary | |
---|---|
static class |
Marshaller.Listener
Register an instance of an implementation of this class with a Marshaller to externally listen
for marshal events. |
Field Summary | |
---|---|
static String |
JAXB_ENCODING
The name of the property used to specify the output encoding in the marshalled XML data. |
static String |
JAXB_FORMATTED_OUTPUT
The name of the property used to specify whether or not the marshalled XML data is formatted with linefeeds and indentation. |
static String |
JAXB_FRAGMENT
The name of the property used to specify whether or not the marshaller will generate document level events (ie calling startDocument or endDocument). |
static String |
JAXB_NO_NAMESPACE_SCHEMA_LOCATION
The name of the property used to specify the xsi:noNamespaceSchemaLocation attribute value to place in the marshalled XML output. |
static String |
JAXB_SCHEMA_LOCATION
The name of the property used to specify the xsi:schemaLocation attribute value to place in the marshalled XML output. |
Method Summary | ||
---|---|---|
|
getAdapter(Class<A> type)
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 contentTree)
Get a DOM tree view of the content tree(Optional). |
|
Object |
getProperty(String name)
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 jaxbElement,
ContentHandler handler)
Marshal the content tree rooted at jaxbElement into SAX2 events. |
|
void |
marshal(Object jaxbElement,
Node node)
Marshal the content tree rooted at jaxbElement into a DOM tree. |
|
void |
marshal(Object jaxbElement,
OutputStream os)
Marshal the content tree rooted at jaxbElement into an output stream. |
|
void |
marshal(Object jaxbElement,
Result result)
Marshal the content tree rooted at jaxbElement into the specified javax.xml.transform.Result. |
|
void |
marshal(Object jaxbElement,
Writer writer)
Marshal the content tree rooted at jaxbElement into a Writer. |
|
void |
marshal(Object jaxbElement,
XMLEventWriter writer)
Marshal the content tree rooted at jaxbElement into a XMLEventWriter . |
|
void |
marshal(Object jaxbElement,
XMLStreamWriter writer)
Marshal the content tree rooted at jaxbElement into a XMLStreamWriter . |
|
|
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. |
|
void |
setEventHandler(ValidationEventHandler handler)
Allow an application to register a validation event handler. |
|
void |
setListener(Marshaller.Listener listener)
Register marshal event callback Marshaller.Listener with this Marshaller . |
|
void |
setProperty(String name,
Object value)
Set the particular property in the underlying implementation of Marshaller. |
|
void |
setSchema(Schema schema)
Specify the JAXP 1.3 Schema
object that should be used to validate subsequent marshal operations
against. |
Field Detail |
---|
static final String JAXB_ENCODING
static final String JAXB_FORMATTED_OUTPUT
static final String JAXB_SCHEMA_LOCATION
static final String JAXB_NO_NAMESPACE_SCHEMA_LOCATION
static final String JAXB_FRAGMENT
Method Detail |
---|
void marshal(Object jaxbElement, Result result) throws JAXBException
All JAXB Providers must at least support
DOMResult
,
SAXResult
, and
StreamResult
. It can
support other derived classes of Result as well.
jaxbElement
- The root of content tree to be marshalled.result
- XML will be sent to this Result
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.
IllegalArgumentException
- If any of the method parameters are nullvoid marshal(Object jaxbElement, OutputStream os) throws JAXBException
jaxbElement
- The root of content tree to be marshalled.os
- XML will be added to this stream.
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.
IllegalArgumentException
- If any of the method parameters are nullvoid marshal(Object jaxbElement, Writer writer) throws JAXBException
jaxbElement
- 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.
IllegalArgumentException
- If any of the method parameters are nullvoid marshal(Object jaxbElement, ContentHandler handler) throws JAXBException
jaxbElement
- The root of content tree to be marshalled.handler
- 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.
IllegalArgumentException
- If any of the method parameters are nullvoid marshal(Object jaxbElement, Node node) throws JAXBException
jaxbElement
- 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.
IllegalArgumentException
- If any of the method parameters are nullvoid marshal(Object jaxbElement, XMLStreamWriter writer) throws JAXBException
XMLStreamWriter
.
jaxbElement
- 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.
IllegalArgumentException
- If any of the method parameters are nullvoid marshal(Object jaxbElement, XMLEventWriter writer) throws JAXBException
XMLEventWriter
.
jaxbElement
- 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.
IllegalArgumentException
- If any of the method parameters are nullNode getNode(Object contentTree) throws JAXBException
marshal(Object, org.w3c.dom.Node)
to force
a deep copy of the content tree to a DOM representation.
contentTree
- - JAXB Java representation of XML content
UnsupportedOperationException
- If the JAXB provider implementation does not support a
DOM view of the content tree
IllegalArgumentException
- If any of the method parameters are null
JAXBException
- If any unexpected problem occursvoid setProperty(String name, Object value) throws PropertyException
name
- 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 set
PropertyException
- when there is an error processing the given
property or value
IllegalArgumentException
- If the name parameter is nullObject getProperty(String name) throws PropertyException
name
- the name of the property to retrieve
PropertyException
- when there is an error retrieving the given property or value
property name
IllegalArgumentException
- If the name parameter is nullvoid 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.
handler
- the validation event handler
JAXBException
- if an error was encountered while setting the
event handlerValidationEventHandler getEventHandler() throws JAXBException
JAXBException
- if an error was encountered while getting the
current event handlervoid setAdapter(XmlAdapter adapter)
XmlAdapter
with this marshaller.
This is a convenience method that invokes setAdapter(adapter.getClass(),adapter);
.
IllegalArgumentException
- if the adapter parameter is null.
UnsupportedOperationException
- if invoked agains a JAXB 1.0 implementation.setAdapter(Class,XmlAdapter)
<A extends XmlAdapter> void setAdapter(Class<A> type, A adapter)
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.
type
- 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.
IllegalArgumentException
- if the type parameter is null.
UnsupportedOperationException
- if invoked agains a JAXB 1.0 implementation.<A extends XmlAdapter> A getAdapter(Class<A> type)
setAdapter(javax.xml.bind.annotation.adapters.XmlAdapter)
method.
IllegalArgumentException
- if the type parameter is null.
UnsupportedOperationException
- if invoked agains a JAXB 1.0 implementation.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.
IllegalStateException
- if attempt to concurrently call this
method during a marshal operation.AttachmentMarshaller getAttachmentMarshaller()
void setSchema(Schema schema)
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 validation
UnsupportedOperationException
- could be thrown if this method is
invoked on an Marshaller created from a JAXBContext referencing
JAXB 1.0 mapped classesSchema getSchema()
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.
UnsupportedOperationException
- could be thrown if this method is
invoked on an Marshaller created from a JAXBContext referencing
JAXB 1.0 mapped classesvoid 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.
listener
- an instance of a class that implements Marshaller.Listener
Marshaller.Listener getListener()
Return Marshaller.Listener
registered with this Marshaller
.
Marshaller.Listener
or null
if no Listener is registered with this Marshaller.