Home » Castor-1.3-src » org.exolab.castor » xml » [javadoc | source]
org.exolab.castor.xml
public class: Marshaller [javadoc | source]
java.lang.Object
   org.exolab.castor.xml.MarshalFramework
      org.exolab.castor.xml.Marshaller
A Marshaller that serializes Java Object's to XML Note: This class is not thread safe, and not intended to be, so please create a new Marshaller for each thread if it is to be used in a multithreaded environment.
Nested Class Summary:
static class  Marshaller.WrapperInfo  Inner-class used for handling wrapper elements and locations. 
static class  Marshaller.MarshalState   
public static class  Marshaller.NilObject  A wrapper for a "Nil" object 
Field Summary
 int depth    The depth of the sub tree, 0 denotes document level. * 
Fields inherited from org.exolab.castor.xml.MarshalFramework:
XSI_NAMESPACE,  XSI_SCHEMA_LOCATION,  XSI_NO_NAMESPACE_SCHEMA_LOCATION,  XML_LANG_ATTR,  LANG_ATTR,  NIL_ATTR,  XSI_NIL_ATTR,  XML_SPACE_ATTR,  SPACE_ATTR,  TYPE_ATTR,  TRUE_VALUE,  INTERNAL_XML_NAME,  JAVA_PREFIX,  QNAME_NAME,  NO_FIELD_DESCRIPTORS
Constructor:
 public Marshaller() 
 public Marshaller(DocumentHandler handler) 
 public Marshaller(ContentHandler contentHandler) 
 public Marshaller(InternalContext internalContext) 
 public Marshaller(Writer out) throws IOException 
    Creates a new Marshaller with the given writer.
 public Marshaller(Node node) 
Method from org.exolab.castor.xml.Marshaller Summary:
addProcessingInstruction,   getMarshalExtendedType,   getNSPrefixAtRoot,   getProperty,   getResolver,   getRootElement,   getValidation,   marshal,   marshal,   marshal,   marshal,   marshal,   setContentHandler,   setDoctype,   setDocumentHandler,   setEncoding,   setInternalContext,   setLogWriter,   setMapping,   setMarshalAsDocument,   setMarshalExtendedType,   setMarshalListener,   setNSPrefixAtRoot,   setNamespaceMapping,   setNoNamespaceSchemaLocation,   setNode,   setProperty,   setResolver,   setRootElement,   setSchemaLocation,   setSuppressNamespaces,   setSuppressXSIType,   setSupressXMLDeclaration,   setUseXSITypeAtRoot,   setValidation,   setWriter
Methods from org.exolab.castor.xml.MarshalFramework:
getCollectionHandler,   getInternalContext,   getJavaNaming,   hasFieldsAtLocation,   isCollection,   isEnum,   isPrimitive,   namespaceEquals,   primitiveOrWrapperEquals,   searchInheritance,   setInternalContext
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.exolab.castor.xml.Marshaller Detail:
 public  void addProcessingInstruction(String target,
    String data) 
    Adds the given processing instruction data to the set of processing instructions to output during marshalling.
 public boolean getMarshalExtendedType() 
    If True the marshaller will use the 'xsi:type' attribute to marshall a field value that extended the defined field type. Default is True.
 public boolean getNSPrefixAtRoot() 
Deprecated!
    Returns True if the given namespace mappings will be declared at the root node.
 public String getProperty(String name) 
    Returns the value of the given Castor XML-specific property.
 public XMLClassDescriptorResolver getResolver() 
    Returns the ClassDescriptorResolver for use during marshalling
 public String getRootElement() 
    Returns the name of the root element to use
 public boolean getValidation() 
 public  void marshal(Object object) throws MarshalException, ValidationException 
    Marshals the given Object as XML using the DocumentHandler for this Marshaller.
 public static  void marshal(Object object,
    Writer out) throws MarshalException, ValidationException 
    Marshals the given Object as XML using the given writer.
 public static  void marshal(Object object,
    DocumentHandler handler) throws MarshalException, ValidationException 
    Marshals the given Object as XML using the given DocumentHandler to send events to.
 public static  void marshal(Object object,
    ContentHandler handler) throws MarshalException, ValidationException, IOException 
    Marshals the given Object as XML using the given ContentHandler to send events to.
 public static  void marshal(Object object,
    Node node) throws MarshalException, ValidationException 
    Marshals the given Object as XML using the given DOM Node to send events to.
 public  void setContentHandler(ContentHandler contentHandler) 
    To set the SAX ContentHandler which is used as destination at marshalling.
 public  void setDoctype(String publicId,
    String systemId) 
    Sets the document type definition for the serializer. Note that this method cannot be called if you've passed in your own DocumentHandler.
 public  void setDocumentHandler(DocumentHandler handler) 
 public  void setEncoding(String encoding) 
    Sets the encoding for the serializer. Note that this method cannot be called if you've passed in your own DocumentHandler.
 public  void setInternalContext(InternalContext internalContext) 
 public  void setLogWriter(PrintWriter printWriter) 
    Sets the PrintWriter used for logging
 public  void setMapping(Mapping mapping) throws MappingException 
    Sets the given mapping to be used by the marshalling Framework. If a resolver exists this mapping will be added to the existing ClassDescriptorResolver. Otherwise a new ClassDescriptorResolver will be created.
 public  void setMarshalAsDocument(boolean asDocument) 
    Sets whether or not to marshal as a document which includes the XML declaration, and if necessary the DOCTYPE declaration. By default the Marshaller will marshal as a well formed XML document including the XML Declaration. If the given boolean is false, the Marshaller will marshal as a well formed XML fragment (no XML declaration or DOCTYPE). This method is basically the same as calling #setSupressXMLDeclaration(true);
 public  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. Default is True.
 public  void setMarshalListener(MarshalListener listener) 
    Sets an optional MarshalListener to recieve pre and post marshal notification for each Object in the tree. MarshalListener is only for complex objects that map into elements, simpleTypes and types that map into attributes do not cause any pre and post event notifications. Current only one (1) listener is allowed. If you need register multiple listeners, you will have to create your own master listener that will forward the event notifications and manage the multiple listeners.
 public  void setNSPrefixAtRoot(boolean nsPrefixAtRoot) 
Deprecated!
    Set to True to declare the given namespace mappings at the root node. Default is False.
 public  void setNamespaceMapping(String nsPrefix,
    String nsURI) 
    Sets the mapping for the given Namespace prefix
 public  void setNoNamespaceSchemaLocation(String schemaLocation) 
    Sets the value for the xsi:noNamespaceSchemaLocation attribute. When set, this attribute will appear on the root element of the marshalled document.
 public  void setNode(Node node) 
    Sets the W3C Node instance to marshal to.
 public  void setProperty(String name,
    String value) 
    Sets a custom value of a given Castor XML-specific property.
 public  void setResolver(XMLClassDescriptorResolver cdr) 
    Sets the ClassDescriptorResolver to use during marshalling.
    Note: This method will nullify any Mapping currently being used by this Marshaller
 public  void setRootElement(String rootElement) 
    Sets the name of the root element to use.
 public  void setSchemaLocation(String schemaLocation) 
    Sets the value for the xsi:schemaLocation attribute. When set, this attribute will appear on the root element of the marshalled document.
 public  void setSuppressNamespaces(boolean suppressNamespaces) 
    Sets whether or not namespaces are output. By default the Marshaller will output namespace declarations and prefix elements and attributes with their respective namespace prefix. This method can be used to prevent the usage of namespaces.
 public  void setSuppressXSIType(boolean suppressXSIType) 
    Sets whether or not the xsi:type attribute should appear on the marshalled document.
 public  void setSupressXMLDeclaration(boolean supressXMLDeclaration) 
    Sets whether or not to marshal as a document which includes the XML declaration, and if necessary the DOCTYPE declaration. By default the Marshaller will marshal as a well formed XML document including the XML Declaration. If the given boolean is true, the Marshaller will marshal as a well formed XML fragment (no XML declaration or DOCTYPE). This method is basically the same as calling #setMarshalAsDocument(false);
 public  void setUseXSITypeAtRoot(boolean useXSITypeAtRoot) 
    Sets whether or not to output the xsi:type at the root element. This is usually needed when the root element type cannot be determined by the element name alone. By default xsi:type will not be output on the root element.
 public  void setValidation(boolean validate) 
    Sets whether or not to validate the object model before marshalling. By default validation is enabled. This method is really for debugging. I do not recommend turning off validation, since you could marshal a document, which you can then not unmarshal. If you know the object model is guaranteed to be valid, disabling validation will improve performace.
 public  void setWriter(Writer out) throws IOException 
    Sets the java.io.Writer to be used during marshalling.