javax.xml.bind.helpers

Class AbstractMarshallerImpl

public abstract class AbstractMarshallerImpl extends Object implements Marshaller

Default implementation of a Marshaller. The JAXB provider needs to implement only {@link javax.xml.bind.Marshaller#marshal(Object, javax.xml.transform.Result)}.

Since: JAXB1.0

Author: JSR-31

See Also: Marshaller

Constructor Summary
AbstractMarshallerImpl()

Creates a new instance of AbstractMarshallerImpl.

Method Summary
protected StringgetEncoding()

Returns the current output encoding.

ValidationEventHandlergetEventHandler()
protected StringgetJavaEncoding(String pEncoding)

Converts the given IANA encoding name into a Java encoding name.

NodegetNode(Object obj)

This method is unsupported in the default implementation and throws an {@link UnsupportedOperationException}.

protected StringgetNoNSSchemaLocation()

Returns the marshallers "no namespace" schema location.

ObjectgetProperty(String pName)

Public interface to get the properties defined by the {@link javax.xml.bind.Marshaller} interface.

protected StringgetSchemaLocation()

Returns the marshallers schema location.

protected booleanisFormattedOutput()

Returns whether the marshaller will create formatted output or not.

voidmarshal(Object pObject, OutputStream pStream)
voidmarshal(Object pObject, Writer pWriter)
voidmarshal(Object pObject, ContentHandler pHandler)
voidmarshal(Object pObject, Node pNode)
protected voidsetEncoding(String pEncoding)

Sets the current output encoding.

voidsetEventHandler(ValidationEventHandler pHandler)
protected voidsetFormattedOutput(boolean pFormattedOutput)

Sets whether the marshaller will create formatted output or not.

protected voidsetNoNSSchemaLocation(String pNoNSSchemaLocation)

Sets the marshallers "no namespace" schema location.

voidsetProperty(String pName, Object pValue)

Public interface to set the properties defined by the {@link javax.xml.bind.Marshaller} interface.

protected voidsetSchemaLocation(String pSchemaLocation)

Sets the marshallers schema location.

Constructor Detail

AbstractMarshallerImpl

public AbstractMarshallerImpl()

Creates a new instance of AbstractMarshallerImpl.

Method Detail

getEncoding

protected String getEncoding()

Returns the current output encoding.

Returns: The current encoding, by default "UTF-8".

See Also: JAXB_ENCODING

getEventHandler

public ValidationEventHandler getEventHandler()

getJavaEncoding

protected String getJavaEncoding(String pEncoding)

Converts the given IANA encoding name into a Java encoding name. This is a helper method for derived subclasses.

getNode

public Node getNode(Object obj)

This method is unsupported in the default implementation and throws an {@link UnsupportedOperationException}.

Throws: UnsupportedOperationException This method is not available in the default implementation.

getNoNSSchemaLocation

protected String getNoNSSchemaLocation()

Returns the marshallers "no namespace" schema location. Defaults to null.

See Also: JAXB_NO_NAMESPACE_SCHEMA_LOCATION

getProperty

public Object getProperty(String pName)

Public interface to get the properties defined by the {@link javax.xml.bind.Marshaller} interface. Works by invocation of {@link #getEncoding()}, {@link #isFormattedOutput()}, {@link #getNoNSSchemaLocation()}, and {@link #getSchemaLocation()} internally.

If you want to support additional properties, you have to override this method in a subclass.

Throws: PropertyException Unknown property name

getSchemaLocation

protected String getSchemaLocation()

Returns the marshallers schema location. Defaults to null.

See Also: JAXB_SCHEMA_LOCATION

isFormattedOutput

protected boolean isFormattedOutput()

Returns whether the marshaller will create formatted output or not. By default it does.

See Also: JAXB_FORMATTED_OUTPUT

marshal

public final void marshal(Object pObject, OutputStream pStream)

marshal

public final void marshal(Object pObject, Writer pWriter)

marshal

public final void marshal(Object pObject, ContentHandler pHandler)

marshal

public final void marshal(Object pObject, Node pNode)

setEncoding

protected void setEncoding(String pEncoding)

Sets the current output encoding.

See Also: JAXB_ENCODING

setEventHandler

public void setEventHandler(ValidationEventHandler pHandler)

setFormattedOutput

protected void setFormattedOutput(boolean pFormattedOutput)

Sets whether the marshaller will create formatted output or not. By default it does.

See Also: JAXB_FORMATTED_OUTPUT

setNoNSSchemaLocation

protected void setNoNSSchemaLocation(String pNoNSSchemaLocation)

Sets the marshallers "no namespace" schema location. Defaults to null.

See Also: JAXB_NO_NAMESPACE_SCHEMA_LOCATION

setProperty

public void setProperty(String pName, Object pValue)

Public interface to set the properties defined by the {@link javax.xml.bind.Marshaller} interface. Works by invocation of {@link #setEncoding(String)}, {@link #setFormattedOutput(boolean)}, {@link #setNoNSSchemaLocation(String)}, and {@link #setSchemaLocation(String)} internally.

If you want to support additional properties, you have to override this method in a subclass.

Throws: PropertyException Unknown property name

setSchemaLocation

protected void setSchemaLocation(String pSchemaLocation)

Sets the marshallers schema location. Defaults to null.

See Also: JAXB_SCHEMA_LOCATION