public class Marshaller extends MarshalFramework
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
Marshaller.MarshalState |
static class |
Marshaller.NilObject
A wrapper for a "Nil" object
|
(package private) static class |
Marshaller.WrapperInfo
Inner-class used for handling wrapper elements
and locations
|
MarshalFramework.InheritanceMatch, MarshalFramework.InternalXMLClassDescriptor| Modifier and Type | Field and Description |
|---|---|
(package private) int |
depth
The depth of the sub tree, 0 denotes document level
|
INTERNAL_XML_NAME, JAVA_PREFIX, LANG_ATTR, NIL_ATTR, NO_FIELD_DESCRIPTORS, QNAME_NAME, SPACE_ATTR, TRUE_VALUE, TYPE_ATTR, XML_LANG_ATTR, XML_SPACE_ATTR, XSI_NAMESPACE, XSI_NIL_ATTR, XSI_NO_NAMESPACE_SCHEMA_LOCATION, XSI_SCHEMA_LOCATION| Constructor and Description |
|---|
Marshaller()
Creates a default instance of Marshaller, where the sink needs to be set
separately.
|
Marshaller(org.xml.sax.ContentHandler handler)
Creates a new Marshaller with the given SAX ContentHandler.
|
Marshaller(org.xml.sax.DocumentHandler handler)
Creates a new Marshaller with the given DocumentHandler.
|
Marshaller(org.w3c.dom.Node node)
Creates a new Marshaller for the given DOM Node.
|
Marshaller(java.io.Writer out)
Creates a new Marshaller with the given writer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addProcessingInstruction(java.lang.String target,
java.lang.String data)
Adds the given processing instruction data to the set of
processing instructions to output during marshalling.
|
boolean |
getMarshalExtendedType()
If True the marshaller will use the 'xsi:type' attribute
to marshall a field value that extended the defined field type.
|
boolean |
getNSPrefixAtRoot()
Deprecated.
|
ClassDescriptorResolver |
getResolver()
Returns the ClassDescriptorResolver for use during marshalling
|
java.lang.String |
getRootElement()
Returns the name of the root element to use
|
void |
marshal(java.lang.Object object)
Marshals the given Object as XML using the DocumentHandler
for this Marshaller.
|
static void |
marshal(java.lang.Object object,
org.xml.sax.ContentHandler handler)
Marshals the given Object as XML using the given ContentHandler
to send events to.
|
static void |
marshal(java.lang.Object object,
org.xml.sax.DocumentHandler handler)
Marshals the given Object as XML using the given DocumentHandler
to send events to.
|
static void |
marshal(java.lang.Object object,
org.w3c.dom.Node node)
Marshals the given Object as XML using the given DOM Node
to send events to.
|
static void |
marshal(java.lang.Object object,
java.io.Writer out)
Marshals the given Object as XML using the given writer.
|
void |
setDoctype(java.lang.String publicId,
java.lang.String systemId)
Sets the document type definition for the serializer.
|
void |
setEncoding(java.lang.String encoding)
Sets the encoding for the serializer.
|
void |
setLogWriter(java.io.PrintWriter printWriter)
Sets the PrintWriter used for logging
|
void |
setMapping(Mapping mapping)
Sets the given mapping to be used by the marshalling Framework.
|
void |
setMarshalAsDocument(boolean asDocument)
Sets whether or not to marshal as a document which includes
the XML declaration, and if necessary the DOCTYPE declaration.
|
void |
setMarshalExtendedType(boolean marshalExtendedType)
If True the marshaller will use the 'xsi:type' attribute
to marshall a field value that extended the defined field type.
|
void |
setMarshalListener(MarshalListener listener)
Sets an optional MarshalListener to recieve pre and post
marshal notification for each Object in the tree.
|
void |
setNamespaceMapping(java.lang.String nsPrefix,
java.lang.String nsURI)
Sets the mapping for the given Namespace prefix
|
void |
setNoNamespaceSchemaLocation(java.lang.String schemaLocation)
Sets the value for the xsi:noNamespaceSchemaLocation attribute.
|
void |
setNSPrefixAtRoot(boolean nsPrefixAtRoot)
Deprecated.
|
void |
setResolver(XMLClassDescriptorResolver cdr)
Sets the ClassDescriptorResolver to use during marshalling
Note: This method will nullify any Mapping currently being used by this Marshaller |
void |
setRootElement(java.lang.String rootElement)
Sets the name of the root element to use.
|
void |
setSchemaLocation(java.lang.String schemaLocation)
Sets the value for the xsi:schemaLocation attribute.
|
void |
setSuppressNamespaces(boolean suppressNamespaces)
Sets whether or not namespaces are output.
|
void |
setSuppressXSIType(boolean suppressXSIType)
Sets whether or not the xsi:type attribute should appear
on the marshalled document.
|
void |
setSupressXMLDeclaration(boolean supressXMLDeclaration)
Sets whether or not to marshal as a document which includes
the XML declaration, and if necessary the DOCTYPE declaration.
|
void |
setUseXSITypeAtRoot(boolean useXSITypeAtRoot)
Sets whether or not to output the xsi:type at the root
element.
|
void |
setValidation(boolean validate)
Sets whether or not to validate the object model
before marshalling.
|
void |
setWriter(java.io.Writer out)
Sets the java.io.Writer to be used during marshalling.
|
getCollectionHandler, hasFieldsAtLocation, isCollection, isPrimitive, namespaceEquals, primitiveOrWrapperEquals, searchInheritancepublic Marshaller(org.xml.sax.DocumentHandler handler)
handler - the DocumentHandler to "marshal" to.public Marshaller(org.xml.sax.ContentHandler handler)
throws java.io.IOException
handler - the ContentHandler to "marshal" to.java.io.IOExceptionpublic Marshaller()
public Marshaller(java.io.Writer out)
throws java.io.IOException
out - the Writer to serialize tojava.io.IOExceptionpublic Marshaller(org.w3c.dom.Node node)
node - the DOM node to marshal into.public void setWriter(java.io.Writer out)
throws java.io.IOException
out - The writer to use for marshallingjava.io.IOException - If there's a problem accessing the java.io.Writer providedpublic void addProcessingInstruction(java.lang.String target,
java.lang.String data)
target - the processing instruction targetdata - the processing instruction datapublic void setDoctype(java.lang.String publicId,
java.lang.String systemId)
publicId - the public identifiersystemId - the system identifierpublic void setSupressXMLDeclaration(boolean supressXMLDeclaration)
supressXMLDeclaration - a boolean that when true
includes that generated XML should not contain
the XML declaration.setMarshalAsDocument(boolean)public void setMarshalAsDocument(boolean asDocument)
asDocument - a boolean, when true, indicating to marshal
as a complete XML document.setSupressXMLDeclaration(boolean)public void setMapping(Mapping mapping) throws MappingException
mapping - Mapping to using during marshalling.MappingExceptionpublic void setMarshalListener(MarshalListener listener)
listener - the MarshalListener to set.public void setNamespaceMapping(java.lang.String nsPrefix,
java.lang.String nsURI)
nsPrefix - the namespace prefixnsURI - the namespace that the prefix resolves topublic void setRootElement(java.lang.String rootElement)
rootElement - The name of the root element to use.public java.lang.String getRootElement()
public void setNSPrefixAtRoot(boolean nsPrefixAtRoot)
nsPrefixAtRoot - public boolean getNSPrefixAtRoot()
public ClassDescriptorResolver getResolver()
setResolver(org.exolab.castor.xml.XMLClassDescriptorResolver)public void setResolver(XMLClassDescriptorResolver cdr)
cdr - the ClassDescriptorResolver to usesetMapping(org.exolab.castor.mapping.Mapping),
getResolver()public void setValidation(boolean validate)
validate - the boolean indicating whether or not to
validate the object model before marshalling.public void setMarshalExtendedType(boolean marshalExtendedType)
public boolean getMarshalExtendedType()
public static void marshal(java.lang.Object object,
java.io.Writer out)
throws MarshalException,
ValidationException
object - The Object to marshal.out - The writer to marshal to.MarshalExceptionValidationExceptionpublic static void marshal(java.lang.Object object,
org.xml.sax.DocumentHandler handler)
throws MarshalException,
ValidationException
object - The Object to marshal.handler - The DocumentHandler to marshal to.MarshalExceptionValidationExceptionpublic static void marshal(java.lang.Object object,
org.xml.sax.ContentHandler handler)
throws MarshalException,
ValidationException,
java.io.IOException
object - The Object to marshal.handler - The ContentHandler to marshal to.MarshalExceptionValidationExceptionjava.io.IOExceptionpublic static void marshal(java.lang.Object object,
org.w3c.dom.Node node)
throws MarshalException,
ValidationException
object - The Object to marshal.node - The DOM Node to marshal to.MarshalExceptionValidationExceptionpublic void marshal(java.lang.Object object)
throws MarshalException,
ValidationException
object - The Object to marshal.MarshalExceptionValidationExceptionpublic void setLogWriter(java.io.PrintWriter printWriter)
printWriter - the PrintWriter to use for loggingpublic void setEncoding(java.lang.String encoding)
encoding - the encoding to setpublic void setNoNamespaceSchemaLocation(java.lang.String schemaLocation)
schemaLocation - the URI location of the schema
to which the marshalled document is an instance of.public void setSchemaLocation(java.lang.String schemaLocation)
schemaLocation - the URI location of the schema
to which the marshalled document is an instance of.public void setSuppressNamespaces(boolean suppressNamespaces)
suppressNamespaces - a boolean that when true
will prevent namespaces from being output.public void setSuppressXSIType(boolean suppressXSIType)
suppressXSIType - a boolean that when true will prevent
xsi:type attribute from being used in the marshalling process.public void setUseXSITypeAtRoot(boolean useXSITypeAtRoot)
useXSITypeAtRoot - a boolean that when true indicates
that the xsi:type should be output on the root element.Intalio Inc. (C) 1999-2006. All rights reserved http://www.intalio.com