Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Package Attributes

org.exolab.castor.xml.Marshaller Class Reference

Inheritance diagram for org.exolab.castor.xml.Marshaller:
org.exolab.castor.xml.MarshalFramework

List of all members.

Classes

class  NilObject
class  WrapperInfo

Public Member Functions

 Marshaller (DocumentHandler handler)
 Marshaller (ContentHandler handler) throws IOException
 Marshaller (Writer out) throws IOException
 Marshaller (Node node)
void addProcessingInstruction (String target, String data)
void setDoctype (String publicId, String systemId)
void setSupressXMLDeclaration (boolean supressXMLDeclaration)
void setMarshalAsDocument (boolean asDocument)
void setMapping (Mapping mapping) throws MappingException
void setMarshalListener (MarshalListener listener)
void setNamespaceMapping (String nsPrefix, String nsURI)
void setRootElement (String rootElement)
String getRootElement ()
void setNSPrefixAtRoot (boolean nsPrefixAtRoot)
boolean getNSPrefixAtRoot ()
void setResolver (ClassDescriptorResolver cdr)
void setValidation (boolean validate)
void setMarshalExtendedType (boolean marshalExtendedType)
boolean getMarshalExtendedType ()
void marshal (Object object) throws MarshalException, ValidationException
void setDebug (boolean debug)
void setLogWriter (PrintWriter printWriter)
void setEncoding (String encoding)
void setNoNamespaceSchemaLocation (String schemaLocation)
void setSchemaLocation (String schemaLocation)
void setSuppressNamespaces (boolean suppressNamespaces)
void setSuppressXSIType (boolean suppressXSIType)

Static Public Member Functions

static void marshal (Object object, Writer out) throws MarshalException, ValidationException
static void marshal (Object object, DocumentHandler handler) throws MarshalException, ValidationException
static void marshal (Object object, ContentHandler handler) throws MarshalException, ValidationException, IOException
static void marshal (Object object, Node node) throws MarshalException, ValidationException

Static Public Attributes

static boolean enableDebug = false

Package Attributes

int depth = 0

Detailed Description

A Marshaller to allow serializing 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.

Author:
Keith Visco
Version:
Revision:
1.21
Date:
2004/12/17 07:30:34

Constructor & Destructor Documentation

org.exolab.castor.xml.Marshaller.Marshaller ( DocumentHandler  handler  ) 

Creates a new Marshaller with the given DocumentHandler.

Parameters:
handler the DocumentHandler to "marshal" to.

Referenced by org.exolab.castor.xml.Marshaller.marshal().

org.exolab.castor.xml.Marshaller.Marshaller ( ContentHandler  handler  )  throws IOException

Creates a new Marshaller with the given SAX ContentHandler.

Parameters:
handler the ContentHandler to "marshal" to.
org.exolab.castor.xml.Marshaller.Marshaller ( Writer  out  )  throws IOException

Creates a new Marshaller with the given writer.

Parameters:
out the Writer to serialize to

References org.exolab.castor.util.Configuration.getSerializer().

org.exolab.castor.xml.Marshaller.Marshaller ( Node  node  ) 

Creates a new Marshaller for the given DOM Node.

Parameters:
node the DOM node to marshal into.

Member Function Documentation

void org.exolab.castor.xml.Marshaller.addProcessingInstruction ( String  target,
String  data 
)

Adds the given processing instruction data to the set of processing instructions to output during marshalling.

Parameters:
target the processing instruction target
data the processing instruction data

References org.exolab.castor.util.List.add().

boolean org.exolab.castor.xml.Marshaller.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.

Returns:
If True the marshaller will use the 'xsi:type' attribute to marshall a field value that extended the defined field type. Default is True.
boolean org.exolab.castor.xml.Marshaller.getNSPrefixAtRoot (  ) 

Returns True if the given namespace mappings will be declared at the root node.

Returns:
Returns True if the given namespace mappings will be declared at the root node.
Deprecated:
String org.exolab.castor.xml.Marshaller.getRootElement (  ) 

Returns the name of the root element to use

Returns:
Returns the name of the root element to use
static void org.exolab.castor.xml.Marshaller.marshal ( Object  object,
DocumentHandler  handler 
) throws MarshalException, ValidationException [static]

Marshals the given Object as XML using the given DocumentHandler to send events to.

Parameters:
obj the Object to marshal
handler the DocumentHandler to marshal to
Exceptions:
org.exolab.castor.xml.MarshalException 
org.exolab.castor.xml.ValidationException 

References org.exolab.castor.xml.Marshaller.enableDebug, org.exolab.castor.xml.Marshaller.marshal(), and org.exolab.castor.xml.Marshaller.Marshaller().

static void org.exolab.castor.xml.Marshaller.marshal ( Object  object,
ContentHandler  handler 
) throws MarshalException, ValidationException, IOException [static]

Marshals the given Object as XML using the given ContentHandler to send events to.

Parameters:
obj the Object to marshal
handler the ContentHandler to marshal to
Exceptions:
org.exolab.castor.xml.MarshalException 
org.exolab.castor.xml.ValidationException 

References org.exolab.castor.xml.Marshaller.enableDebug, org.exolab.castor.xml.Marshaller.marshal(), and org.exolab.castor.xml.Marshaller.Marshaller().

static void org.exolab.castor.xml.Marshaller.marshal ( Object  object,
Node  node 
) throws MarshalException, ValidationException [static]

Marshals the given Object as XML using the given DOM Node to send events to.

Parameters:
obj the Object to marshal
node the DOM Node to marshal to
Exceptions:
org.exolab.castor.xml.MarshalException 
org.exolab.castor.xml.ValidationException 

References org.exolab.castor.xml.Marshaller.enableDebug, org.exolab.castor.xml.Marshaller.marshal(), and org.exolab.castor.xml.Marshaller.Marshaller().

void org.exolab.castor.xml.Marshaller.marshal ( Object  object  )  throws MarshalException, ValidationException
void org.exolab.castor.xml.Marshaller.setDebug ( boolean  debug  ) 

Sets the flag to turn on and off debugging

Parameters:
debug the flag indicating whether or not debug information should be generated
void org.exolab.castor.xml.Marshaller.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.

Parameters:
publicId the public identifier
systemId the system identifier

References org.exolab.castor.util.Configuration.getOutputFormat().

void org.exolab.castor.xml.Marshaller.setEncoding ( String  encoding  ) 

Sets the encoding for the serializer. Note that this method cannot be called if you've passed in your own DocumentHandler.

Parameters:
encoding the encoding to set

References org.exolab.castor.util.Configuration.getOutputFormat().

void org.exolab.castor.xml.Marshaller.setLogWriter ( PrintWriter  printWriter  ) 

Sets the PrintWriter used for logging

Parameters:
printWriter the PrintWriter to use for logging
void org.exolab.castor.xml.Marshaller.setMapping ( Mapping  mapping  )  throws MappingException

Sets the given mapping to be used by the marshalling Framework. If a ClassDescriptorResolver exists This mapping will be added to the existing Resolver. Otherwise a new ClassDescriptorResolver will be created.

Parameters:
mapping the mapping to using during marshalling

References org.exolab.castor.xml.ClassDescriptorResolver.setMappingLoader().

void org.exolab.castor.xml.Marshaller.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);

Parameters:
asDocument a boolean, when true, indicating to marshal as a complete XML document.
See also:
setSupressXMLDeclaration

References org.exolab.castor.util.Configuration.getOutputFormat().

Referenced by org.exolab.castor.xml.Marshaller.setSupressXMLDeclaration().

void org.exolab.castor.xml.Marshaller.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.

void org.exolab.castor.xml.Marshaller.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.

Parameters:
listener the MarshalListener to set.
void org.exolab.castor.xml.Marshaller.setNamespaceMapping ( String  nsPrefix,
String  nsURI 
)

Sets the mapping for the given Namespace prefix

Parameters:
nsPrefix the namespace prefix
nsURI the namespace that the prefix resolves to

References org.exolab.castor.xml.Namespaces.addNamespace().

Referenced by org.exolab.castor.tools.MappingTool.write().

void org.exolab.castor.xml.Marshaller.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.

Parameters:
schemaLocation the URI location of the schema to which the marshalled document is an instance of.

References org.exolab.castor.xml.util.AttributeSetImpl.setAttribute(), org.exolab.castor.xml.MarshalFramework.XSI_NAMESPACE, and org.exolab.castor.xml.MarshalFramework.XSI_NO_NAMESPACE_SCHEMA_LOCATION.

void org.exolab.castor.xml.Marshaller.setNSPrefixAtRoot ( boolean  nsPrefixAtRoot  ) 

Set to True to declare the given namespace mappings at the root node. Default is False.

Parameters:
nsPrefixAtRoot 
Deprecated:
void org.exolab.castor.xml.Marshaller.setResolver ( ClassDescriptorResolver  cdr  ) 

Sets the ClassDescriptorResolver to use during unmarshalling

Parameters:
cdr the ClassDescriptorResolver to use
See also:
setMapping
Note: This method will nullify any Mapping currently being used by this Marshaller
void org.exolab.castor.xml.Marshaller.setRootElement ( String  rootElement  ) 

Sets the name of the root element to use

Parameters:
The name of the root element to use

Referenced by org.exolab.castor.util.ChangeLog2XML.main().

void org.exolab.castor.xml.Marshaller.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.

Parameters:
schemaLocation the URI location of the schema to which the marshalled document is an instance of.

References org.exolab.castor.xml.util.AttributeSetImpl.setAttribute(), org.exolab.castor.xml.MarshalFramework.XSI_NAMESPACE, and org.exolab.castor.xml.MarshalFramework.XSI_SCHEMA_LOCATION.

void org.exolab.castor.xml.Marshaller.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.

Parameters:
suppressNamespaces a boolean that when true will prevent namespaces from being output.
void org.exolab.castor.xml.Marshaller.setSuppressXSIType ( boolean  suppressXSIType  ) 

Sets whether or not the xsi:type attribute should appear on the marshalled document.

Parameters:
suppressXSIType a boolean that when true will prevent xsi:type attribute from being used in the marshalling process.

Referenced by org.exolab.castor.util.ChangeLog2XML.main().

void org.exolab.castor.xml.Marshaller.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);

Parameters:
supressXMLDeclaration a boolean that when true includes that generated XML should not contain the XML declaration.
See also:
setMarshalAsDocument

References org.exolab.castor.xml.Marshaller.setMarshalAsDocument().

void org.exolab.castor.xml.Marshaller.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.

Parameters:
validate the boolean indicating whether or not to validate the object model before marshalling.

Referenced by cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl.addFaultFamily(), cl.utfsm.acs.acg.dao.ACSCategoryDAOImpl.flushCategories(), cl.utfsm.acs.acg.dao.ACSAlarmSystemDAOImpl.flushConfiguration(), cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl.flushReductionRules(), alma.acs.entityutil.EntitySerializer.serializeEntityPart(), alma.acs.component.dynwrapper.CastorMarshalMapper.translate(), and cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl.updateFaultFamily().


Member Data Documentation

The depth of the sub tree, 0 denotes document level

A static flag used to enable debugging when using the static marshal methods.

Referenced by org.exolab.castor.xml.Marshaller.marshal().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties