|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.ispsoft.jaxme.jaxb.JMManagerFactoryAttachable de.ispsoft.jaxme.jaxb.MarshallerImpl
The Marshaller is JaxMe's implementation of the
javax.xml.marshal.Marshaller
interface. In other words,
a Marshaller can write an instance of JMAnyElement to a
Writer or a SAX ContentHandler.
JaxMe's Marshallers are built around the concept of
an underlying ResourceBundle. Inimport java.util.ResourceBundle;
other words, the
ResourceBundle specifies JaxMe's behaviour of how an
XML document is formatted. The Marshallers
setProperty()
and getProperty()
calls are more or less directly mapped to similar calls
of the underlying Resou
/**
The Marshaller is JaxMe's implementation of the
javax.xml.marshal.Marshaller
interface. In other words,
a Marshaller can write an instance of JMAnyElement to a
Writer or a SAX ContentHandler.
JaxMe's Marshallers are built around the concept of
an underlying ResourceBundle. In other words, the
ResourceBundle specifies JaxMe's behaviour of how an
XML document is formatted. The Marshallers
setProperty()
and getProperty()
calls are more or less directly mapped to similar calls
of the underlying ResourceBundle.
The following table lists the properties that are recognized by JaxMe.
Name | Type | Bean Property | Description |
---|---|---|---|
jaxb.encoding | String | Encoding | The encoding to choose when serializing into an OutputStream. Defaults to UTF-8, as specified by JAXB. |
jaxb.formatted.output | Boolean | Indentation | Whether generated XML documents should be human readable or not. Defaults to true, as specified by JAXB. |
jaxme.empty.element.style | Integer | EmptyElementStyle | How to format empty elements. Supported values are
|
jaxme.format.date | java.text.DateFormat | DateFormat | A format being used to serialize xs:date elements. Defaults
to new SimpleDateFormat("yyyy-MM-dd") . |
jaxme.format.datetime | java.text.DateFormat | DateTimeFormat | A format being used to serialize xs:datetime elements. Defaults
to new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z") . |
jaxme.format.time | java.text.DateFormat | TimeFormat | A format being used to serialize xs:time elements. Defaults
to new SimpleDateFormat("yyyy-MM-dd") . |
jaxme.formatted.output.level | Integer | IndentationLevel | Number of blanks to indent a new element, if indentation is turned on (property jaxb.formatted.output). The default is 2. |
jaxme.formatted.output.separator | String | IndentationLineSeparator | Line separator to use for new elements, if indentation is turned on (property jaxb.formatted.output). The default is a single line feed ("\n"). Windows users might prefer an additional carriage return before the line feed ("\r\n"). |
jaxme.declaration | Boolean | Declaration DefaultDeclaration |
Whether generated XML documents should have a preceeding XML declaration. |
jaxme.locale | java.util.Locale | The Locale to use for formatting values, defaults to
java.util.Locale.getDefault(). |
|
jaxme.resourcebundle | java.util.ResourceBundle | The ResourceBundle to use for looking up keys. | |
jaxme.startDocument | Boolean | Whether marshal(Object, ContentHandler)
should emit startDocument() and
endDocument() events or not. Defaults
to true. |
|
jaxme.private.* | Object | All properties whose names start with jaxme.private. are simply stored or fetched. JaxMe doesn't interpret them, they are mainly usefull, if you have added own code to the marshalling process. |
Field Summary | |
static int |
BUILTIN_INDENTATION_LEVEL
Builtin default indentation level (2 blanks). |
static java.lang.String |
BUILTIN_INDENTATION_LINE_SEPARATOR
Builtin default line terminator (Line Feed, no Carriage Return). |
static int |
EMPTY_ELEMENT_STYLE_HTML
A constant for formatting empty elements like this: <empty></empty> The builtin default is EMPTY_ELEMENT_STYLE_XML . |
static int |
EMPTY_ELEMENT_STYLE_XML
A constant for formatting empty elements like this: <empty&> This is the builtin default. |
Fields inherited from class de.ispsoft.jaxme.jaxb.JMManagerFactoryAttachable |
BUILTIN_DATE_FORMAT, BUILTIN_DATETIME_FORMAT, BUILTIN_ENCODING, BUILTIN_TIME_FORMAT |
Constructor Summary | |
MarshallerImpl()
Creates a new instance of MarshallerImpl. |
Method Summary | |
boolean |
getDeclaration()
Returns whether an XML declaration should be generated or not. |
int |
getEmptyElementStyle()
Returns the Marshallers style for formatting empty elements. |
boolean |
getIndentation()
Returns the default for using indentation. |
int |
getIndentationLevel()
Return the default indentation level. |
java.lang.String |
getIndentationLineSeparator()
Returns the default line separator for indentation. |
java.lang.Object |
getProperty(java.lang.String pName)
Returns the value of the given property. |
boolean |
getStartDocument()
Returns whether marshal(Object, ContentHandler)
should emit startDocument() and
endDocument() events. |
void |
marshal(java.lang.Object pObj,
org.xml.sax.ContentHandler pHandler)
Marshal the content tree rooted at obj into SAX2 events. |
void |
marshal(java.lang.Object pObj,
java.io.File pFile)
|
void |
marshal(java.lang.Object pObj,
org.w3c.dom.Node pNode)
Marshal the content tree rooted at obj into a DOM tree. |
void |
marshal(java.lang.Object pObj,
java.io.OutputStream pStream)
Marshal the content tree rooted at obj into an output stream. |
void |
marshal(java.lang.Object pObj,
javax.xml.transform.Result pResult)
Marshal the content tree rooted at obj into the specified javax.xml.transform.Result. |
void |
marshal(java.lang.Object pObj,
java.io.Writer pWriter)
Marshal the content tree rooted at obj into a Writer. |
void |
setDeclaration(boolean pDeclaration)
Sets whether an XML declaration should be generated or not. |
void |
setEmptyElementStyle(int pStyle)
Sets the Marshallers style for formatting empty elements. |
void |
setIndentation(boolean pIndentation)
Sets the default for using indentation. |
void |
setIndentationLevel(int pLevel)
Sets the default indentation level. |
void |
setIndentationLineSeparator(java.lang.String pSeparator)
Sets the default line separator for indentation. |
void |
setProperty(java.lang.String pName,
java.lang.Object pValue)
Sets the value of the given property. |
void |
setStartDocument(boolean pStartDocument)
Sets whether marshal(Object, ContentHandler)
should emit startDocument() and
endDocument() events. |
Methods inherited from class de.ispsoft.jaxme.jaxb.JMManagerFactoryAttachable |
getDateFormat, getDateFormat, getDateFormatForPattern, getDateTimeFormat, getDateTimeFormat, getEncoding, getFactory, getLocale, getMessageFormat, getNumberFormat, getPrivateProperty, getResourceBundle, getResourceValue, getTimeFormat, getTimeFormat, setDateFormat, setDateTimeFormat, setEncoding, setFactory, setLocale, setPrivateProperty, setResourceBundle, setTimeFormat |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface de.ispsoft.jaxme.jaxb.Marshaller |
getEncoding, setEncoding |
Field Detail |
public static final int EMPTY_ELEMENT_STYLE_XML
A constant for formatting empty elements like this:
<empty&>This is the builtin default.
setEmptyElementStyle(int)
,
EMPTY_ELEMENT_STYLE_HTML
,
Constant Field Valuespublic static final int EMPTY_ELEMENT_STYLE_HTML
A constant for formatting empty elements like this:
<empty></empty>The builtin default is
EMPTY_ELEMENT_STYLE_XML
.
setEmptyElementStyle(int)
,
EMPTY_ELEMENT_STYLE_XML
,
Constant Field Valuespublic static final int BUILTIN_INDENTATION_LEVEL
Builtin default indentation level (2 blanks). Ignored, if indentation is disabled.
setIndentationLevel(int)
,
Constant Field Valuespublic static final java.lang.String BUILTIN_INDENTATION_LINE_SEPARATOR
Builtin default line terminator (Line Feed, no Carriage Return). Ignored, if indentation is disabled.
setIndentationLineSeparator(java.lang.String)
,
Constant Field ValuesConstructor Detail |
public MarshallerImpl()
Creates a new instance of MarshallerImpl.
Method Detail |
public void setEmptyElementStyle(int pStyle)
Sets the Marshallers style for formatting empty elements.
Defaults to getDefaultEmptyElementStyle()
. Can also
be set with
setProperty("jaxme.empty.element.style",
new Integer(EMPTY_ELEMENT_STYLE_XML))
.
EMPTY_ELEMENT_STYLE_XML
public int getEmptyElementStyle()
Returns the Marshallers style for formatting empty elements.
Defaults to getDefaultEmptyElementStyle()
. Can also
be set with
setProperty("jaxme.empty.element.style")
.
EMPTY_ELEMENT_STYLE_XML
public void setIndentation(boolean pIndentation)
Sets the default for using indentation. The default
is true, according to the JAXB specification. Can also
be set with
setProperty("jaxb.formatted.output", Boolean.TRUE)
.
public boolean getIndentation()
Returns the default for using indentation. The default
is true, according to the JAXB specification. Can also
be fetched with
getProperty("jaxb.formatted.output")
.
public void setIndentationLevel(int pLevel)
Sets the default indentation level. Defaults to
BUILTIN_INDENTATION_LEVEL. Ignored,
if indentation is disabled. By default indentation is on,
due to the JAXB specification. Can also be
set with
setProperty("jaxme.formatted.output.level",
new Integer(pLevel))
.
getIndentationLevel()
,
BUILTIN_INDENTATION_LEVEL
public int getIndentationLevel()
Return the default indentation level. Defaults to
BUILTIN_INDENTATION_LEVEL. Ignored,
if indentation is disabled. By default indentation is on,
due to the JAXB specification. Can also be
fetched with
getProperty("jaxme.formatted.output.level")
.
setIndentationLevel(int)
,
BUILTIN_INDENTATION_LEVEL
public void setIndentationLineSeparator(java.lang.String pSeparator)
Sets the default line separator for indentation.
Defaults to BUILTIN_INDENTATION_LINE_SEPARATOR.
Ignored, if indentation is disabled. Can also be
set with
setProperty("jaxme.formatted.output.separator",
pSeparator)
.
BUILTIN_INDENTATION_LINE_SEPARATOR
,
getIndentationLineSeparator()
,
JMManagerFactoryAttachable.setResourceBundle(java.util.ResourceBundle)
public java.lang.String getIndentationLineSeparator()
Returns the default line separator for indentation.
Defaults to getDefaultIndentationLineSeparator()
.
Ignored, if indentation is disabled. Can also be
fetched with
getProperty("jaxme.formatted.output.separator")
.
BUILTIN_INDENTATION_LINE_SEPARATOR
,
setIndentationLineSeparator(java.lang.String)
,
JMManagerFactoryAttachable.getResourceBundle()
public void setDeclaration(boolean pDeclaration)
Sets whether an XML declaration should be generated or not.
Can also be set with
setProperty("jaxme.declaration",
new Boolean(pDeclaration))
.
getDeclaration()
public boolean getDeclaration()
Returns whether an XML declaration should be generated or not.
Can also be fetched with
getProperty("jaxme.declaration")
.
setDeclaration(boolean)
public void setStartDocument(boolean pStartDocument)
Sets whether marshal(Object, ContentHandler)
should emit startDocument()
and
endDocument()
events. Can also be set with
setProperty("jaxme.startDocument",
new Boolean(pSuppressStartDocument))
.
Defaults to false.
public boolean getStartDocument()
Returns whether marshal(Object, ContentHandler)
should emit startDocument()
and
endDocument()
events. Can also be fetched with
getProperty("jaxme.startDocument")
.
Defaults to false.
public java.lang.Object getProperty(java.lang.String pName) throws JAXBException, UnrecognizedPropertyException, UnsupportedPropertyException
Returns the value of the given property.
getProperty
in interface Marshaller
getProperty
in class JMManagerFactoryAttachable
JAXBException
UnrecognizedPropertyException
UnsupportedPropertyException
public void setProperty(java.lang.String pName, java.lang.Object pValue) throws JAXBException, UnrecognizedPropertyException, UnsupportedPropertyException
Sets the value of the given property.
setProperty
in interface Marshaller
setProperty
in class JMManagerFactoryAttachable
JAXBException
UnrecognizedPropertyException
UnsupportedPropertyException
public void marshal(java.lang.Object pObj, org.xml.sax.ContentHandler pHandler) throws JAXBException
Marshaller
marshal
in interface Marshaller
pObj
- The content tree to be marshalled.pHandler
- XML will be sent to this handler as SAX2 events.
JAXBException
- If any unexpected problem occurs during the marshalling.public void marshal(java.lang.Object pObj, java.io.Writer pWriter) throws JAXBException
Marshaller
marshal
in interface Marshaller
pObj
- The content tree to be marshalled.pWriter
- XML will be sent to this writer.
JAXBException
- If any unexpected problem occurs during the marshalling.public void marshal(java.lang.Object pObj, javax.xml.transform.Result pResult) throws JAXBException
Marshaller
All JAXB Providers must at least support
DOMResult
,
SAXResult
, and
StreamResult
. It can
support other derived classes of Result as well.
marshal
in interface Marshaller
pObj
- The content tree to be marshalled.pResult
- XML will be sent to this Result
JAXBException
- If any unexpected problem occurs during the marshalling.public void marshal(java.lang.Object pObj, java.io.OutputStream pStream) throws JAXBException
Marshaller
marshal
in interface Marshaller
pObj
- The content tree to be marshalled.pStream
- XML will be added to this stream.
JAXBException
- If any unexpected problem occurs during the marshalling.public void marshal(java.lang.Object pObj, java.io.File pFile) throws JAXBException
JAXBException
public void marshal(java.lang.Object pObj, org.w3c.dom.Node pNode) throws JAXBException
Marshaller
marshal
in interface Marshaller
pObj
- The content tree to be marshalled.pNode
- 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.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |