|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.xml.bind.helpers.AbstractMarshallerImpl
public abstract class AbstractMarshallerImpl
Default implementation of a Marshaller. The JAXB provider needs
to implement only
Marshaller.marshal(Object, javax.xml.transform.Result)
.
Marshaller
Field Summary |
---|
Fields inherited from interface javax.xml.bind.Marshaller |
---|
JAXB_ENCODING, JAXB_FORMATTED_OUTPUT, JAXB_NO_NAMESPACE_SCHEMA_LOCATION, JAXB_SCHEMA_LOCATION |
Constructor Summary | |
---|---|
AbstractMarshallerImpl()
Creates a new instance of AbstractMarshallerImpl . |
Method Summary | |
---|---|
protected java.lang.String |
getEncoding()
Returns the current output encoding. |
ValidationEventHandler |
getEventHandler()
Returns an event handler previously registered by the application. |
protected java.lang.String |
getJavaEncoding(java.lang.String pEncoding)
Converts the given IANA encoding name into a Java encoding name. |
org.w3c.dom.Node |
getNode(java.lang.Object obj)
This method is unsupported in the default implementation and throws an UnsupportedOperationException . |
protected java.lang.String |
getNoNSSchemaLocation()
Returns the marshallers "no namespace" schema location. |
java.lang.Object |
getProperty(java.lang.String pName)
Public interface to get the properties defined by the Marshaller interface. |
protected java.lang.String |
getSchemaLocation()
Returns the marshallers schema location. |
protected boolean |
isFormattedOutput()
Returns whether the marshaller will create formatted output or not. |
void |
marshal(java.lang.Object pObject,
org.xml.sax.ContentHandler pHandler)
Marshals the given JAXB object by emitting SAX events into into the given SAX ContentHandler . |
void |
marshal(java.lang.Object pObject,
org.w3c.dom.Node pNode)
Marshals the given JAXB object by creating a DOM tree below the given node. |
void |
marshal(java.lang.Object pObject,
java.io.OutputStream pStream)
Marshals the given JAXB object pObject and
serializes it into the byte stream pTarget . |
void |
marshal(java.lang.Object pObject,
java.io.Writer pWriter)
Marshals the given JAXB object pObject and
serializes it into the character stream pTarget . |
protected void |
setEncoding(java.lang.String pEncoding)
Sets the current output encoding. |
void |
setEventHandler(ValidationEventHandler pHandler)
Allows the application to set an event handler. |
protected void |
setFormattedOutput(boolean pFormattedOutput)
Sets whether the marshaller will create formatted output or not. |
protected void |
setNoNSSchemaLocation(java.lang.String pNoNSSchemaLocation)
Sets the marshallers "no namespace" schema location. |
void |
setProperty(java.lang.String pName,
java.lang.Object pValue)
Public interface to set the properties defined by the Marshaller interface. |
protected void |
setSchemaLocation(java.lang.String pSchemaLocation)
Sets the marshallers schema location. |
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()
Creates a new instance of AbstractMarshallerImpl
.
Method Detail |
---|
public void setEventHandler(ValidationEventHandler pHandler) throws JAXBException
Marshaller
Allows the application to set an event handler. The event handler will be invoked in case of a validation event.
Note: The ability to register an event handler does not
indicate that a JAXB provider is required to validate the objects
being marshalled. If you want to ensure, that only valid objects
are marshalled, you should perform an explicit validation using a
Validator
.
setEventHandler
in interface Marshaller
pHandler
- An application specific event handler or null to
revert to the default event handler. The default handler is
throwing an exception in case of errors.
JAXBException
public ValidationEventHandler getEventHandler() throws JAXBException
Marshaller
Returns an event handler previously registered by the application. The event handler will be invoked in case of a validation event.
Note: The ability to register an event handler does not
indicate that a JAXB provider is required to validate the objects
being marshalled. If you want to ensure, that only valid objects
are marshalled, you should perform an explicit validation using a
Validator
.
getEventHandler
in interface Marshaller
JAXBException
- An error occurred while getting the event
handler.public void setProperty(java.lang.String pName, java.lang.Object pValue) throws PropertyException
Public interface to set the properties defined
by the Marshaller
interface.
Works by invocation of setEncoding(String)
,
setFormattedOutput(boolean)
,
setNoNSSchemaLocation(String)
, and
setSchemaLocation(String)
internally.
If you want to support additional properties, you have to override this method in a subclass.
setProperty
in interface Marshaller
pName
- The property name.
PropertyException
- Unknown property namepublic java.lang.Object getProperty(java.lang.String pName) throws PropertyException
Public interface to get the properties defined
by the Marshaller
interface.
Works by invocation of getEncoding()
,
isFormattedOutput()
,
getNoNSSchemaLocation()
, and
getSchemaLocation()
internally.
If you want to support additional properties, you have to override this method in a subclass.
getProperty
in interface Marshaller
pName
- The property name.
PropertyException
- Unknown property nameprotected java.lang.String getEncoding()
Returns the current output encoding.
Marshaller.JAXB_ENCODING
protected java.lang.String getJavaEncoding(java.lang.String pEncoding) throws java.io.UnsupportedEncodingException
Converts the given IANA encoding name into a Java encoding name. This is a helper method for derived subclasses.
java.io.UnsupportedEncodingException
protected void setEncoding(java.lang.String pEncoding)
Sets the current output encoding.
Marshaller.JAXB_ENCODING
protected void setSchemaLocation(java.lang.String pSchemaLocation)
Sets the marshallers schema location. Defaults to null.
Marshaller.JAXB_SCHEMA_LOCATION
protected java.lang.String getSchemaLocation()
Returns the marshallers schema location. Defaults to null.
Marshaller.JAXB_SCHEMA_LOCATION
protected void setNoNSSchemaLocation(java.lang.String pNoNSSchemaLocation)
Sets the marshallers "no namespace" schema location. Defaults to null.
Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION
protected java.lang.String getNoNSSchemaLocation()
Returns the marshallers "no namespace" schema location. Defaults to null.
Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION
protected void setFormattedOutput(boolean pFormattedOutput)
Sets whether the marshaller will create formatted output or not. By default it does.
Marshaller.JAXB_FORMATTED_OUTPUT
protected boolean isFormattedOutput()
Returns whether the marshaller will create formatted output or not. By default it does.
Marshaller.JAXB_FORMATTED_OUTPUT
public final void marshal(java.lang.Object pObject, java.io.OutputStream pStream) throws JAXBException
Marshaller
Marshals the given JAXB object pObject
and
serializes it into the byte stream pTarget
. Note,
that serialization into a byte stream demands the use of an
encoding. It may be required to set the parameter
Marshaller.JAXB_ENCODING
. By default the created output is
formatted, which may be turned off using
Marshaller.JAXB_FORMATTED_OUTPUT
.
marshal
in interface Marshaller
pObject
- The JAXB object being marshalled.pStream
- The output byte stream.
JAXBException
- An unexpected problem occurred. This may be used,
for example, to throw a nested IOException
.
MarshalException
- Whereever possible, one should prefer the
MarshalException
over the JAXBException
.Marshaller.JAXB_ENCODING
,
Marshaller.JAXB_FORMATTED_OUTPUT
,
Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION
,
Marshaller.JAXB_SCHEMA_LOCATION
public final void marshal(java.lang.Object pObject, java.io.Writer pWriter) throws JAXBException
Marshaller
Marshals the given JAXB object pObject
and
serializes it into the character stream pTarget
.
Unlike serialization to a byte stream, an encoding is not
required, but a Marshaller
may use the encoding
whether to escape a character or not. Use of the
Marshaller.JAXB_ENCODING
property is still recommended. By
default the created output is
formatted, which may be turned off using
Marshaller.JAXB_FORMATTED_OUTPUT
.
marshal
in interface Marshaller
pObject
- The JAXB object being marshalled.pWriter
- The output character stream.
JAXBException
- An unexpected problem occurred. This may be used,
for example, to throw a nested IOException
.
MarshalException
- Whereever possible, one should prefer the
MarshalException
over the JAXBException
.Marshaller.JAXB_ENCODING
,
Marshaller.JAXB_FORMATTED_OUTPUT
,
Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION
,
Marshaller.JAXB_SCHEMA_LOCATION
public final void marshal(java.lang.Object pObject, org.xml.sax.ContentHandler pHandler) throws JAXBException
Marshaller
Marshals the given JAXB object by emitting SAX events into
into the given SAX ContentHandler
. This
includes the events ContentHandler.startDocument()
and ContentHandler.endDocument()
.
marshal
in interface Marshaller
pObject
- The JAXB Object being marshalled.pHandler
- The target event handler.
JAXBException
- An unexpected problem occurred. This may be used,
for example, to throw a nested SAXException
.
MarshalException
- Whereever possible, one should prefer the
MarshalException
over the JAXBException
.Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION
,
Marshaller.JAXB_SCHEMA_LOCATION
public final void marshal(java.lang.Object pObject, org.w3c.dom.Node pNode) throws JAXBException
Marshaller
Marshals the given JAXB object by creating a DOM tree below the given node.
marshal
in interface Marshaller
pObject
- The JAXB object being marshalled.pNode
- The target node. This node must be ready to accept a
child element. For example, it may be a Document
,
a DocumentFragment
, or an
Element
.
JAXBException
- An unexpected problem occurred. This may be used,
for example, to throw a nested DOMException
.
MarshalException
- Whereever possible, one should prefer the
MarshalException
over the JAXBException
.Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION
,
Marshaller.JAXB_SCHEMA_LOCATION
public org.w3c.dom.Node getNode(java.lang.Object obj) throws JAXBException
This method is unsupported in the default implementation
and throws an UnsupportedOperationException
.
getNode
in interface Marshaller
obj
- The JAXB object being viewed.
java.lang.UnsupportedOperationException
- This method is not available in the
default implementation.
JAXBException
- An unexpected problem occurred. This may be used,
for example, to throw a nested DOMException
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |