org.exolab.castor.xml |
The XML Marshaller API
- Version:
- $Revision: 6213 $ $Date: 2003-03-03 00:05:44 -0700 (Mon, 03 Mar 2003) $
- Author:
- Keith Visco
{@link org.exolab.castor.xml.Marshaller} marshalls a Java object into an XML document.
{@link org.exolab.castor.xml.Unmarshaller} unmarshalls an XML document back into a Java
object.
The following example unmarshals the XML document product.xml into a
Product object, performs simple changes to the object and then marshals it
back into an XML document.
Product prod;
File file;
file = new File( "product.xml" );
// Unmarshal the document into an object
prod = (Product) Unmarshaller.unmarshal( Product.class, new FileReader( file ) );
// A 25% mark down for each product and mark as sale
prod.markDown( 0.25 );
prod.setOnSale( true );
// Marshal the object into a document
Marshaller.marshal( Product, new FileWriter( file ) );
In addition to static methods, marshaller objects can be created and set with a variety
of options affecting how they will operation. The above example adapted to use a specific
mapping file:
Mapping map;
Unmarshaller umr;
Marshaller mar;
// Load the specified mapping file
map = new Mapping();
map.loadMapping( "mapping.xml" );
// Unmarshal the document into an object
umr = new Unmarshaller( Product.class );
umr.setMapping( mapping );
prod = (Product) umr.unmarshal( new FileReader( file ) );
: : :
// Marshal the object into a document
mar = new Marshaller( new FileWriter( file ) );
mar.setMapping( mapping );
mar.marshal( Product );
|
Java Source File Name | Type | Comment |
AccessRights.java | Class | |
AttributeSet.java | Interface | A simple interface for handling Attributes in the Marshalling
Framework. |
CastorException.java | Class | |
ClassDescriptorResolver.java | Interface | An interface for finding or "resolving" ClassDescriptor classes. |
ClassDescriptorResolverFactory.java | Class | |
DebugHandler.java | Class | A Simple SAX1 DocumentHandler that intercepts SAX events and prints them to
the console. |
DescriptorType.java | Class | This class represents the Possible Descriptor types used
by the marshalling Framework. |
EventProducer.java | Interface | A interface which abstracts anything which can produce SAX events. |
FieldValidator.java | Class | Handles field validation. |
IDResolver.java | Interface | A simple interface for doing custom IDREF resolving
during Unmarshalling. |
IDResolverImpl.java | Class | Default
IDResolver for Castor XML during (un)marshaling. |
Introspector.java | Class | A Helper class for the Marshaller and Unmarshaller,
basically the common code base between the two. |
JavaNaming.java | Class | This class converts XML Names to proper Java names. |
MarshalException.java | Class | An exception that is used to signal marshalling exceptions. |
MarshalFramework.java | Class | |
Marshaller.java | Class | 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. |
MarshalListener.java | Interface | An interface to allow external "listening" to objects when
they are being marshalled for various tracking purposes and
potential modification, and to prevent an object from
being marshalled if necessary. |
Namespaces.java | Class | |
NodeType.java | Class | The possible node types for an XML field. |
OutputFormat.java | Interface | Output format contract for XML serialization. |
ProcessingInstruction.java | Class | An immutable class that represents an XML processing instruction. |
ReferenceInfo.java | Class | Internal class used to save state for reference resolving. |
ResolverException.java | Class | |
SAX2EventProducer.java | Interface | A interface which abstracts anything which can produce SAX 2 events. |
Serializer.java | Interface | Interface contract for XML serialization business. |
TestUnmarshaller.java | Class | Test case for testing various pieces of functionality of
Unmarshaller . |
TypeValidator.java | Interface | The basic type validation interface class. |
UnmarshalHandler.java | Class | An unmarshaller to allowing unmarshaling of XML documents to
Java Objects. |
Unmarshaller.java | Class | An unmarshaller to allowing unmarshalling of XML documents to
Java Objects. |
UnmarshalListener.java | Interface | An interface to allow external "listening" to objects when
they are being unmarshalled for various tracking purposes and
potential modification. |
UnmarshalState.java | Class | |
ValidationContext.java | Class | A class which can be used to hold validation information, used
by the TypeValidator interface. |
ValidationException.java | Class | An Exception that can be used to signal XML validation errors. |
Validator.java | Class | A class which can perform Validation on an Object model. |
XercesJDK5OutputFormat.java | Class | Xerces-specific OutputFormat instance, used with JDK 5.0 only. |
XercesJDK5Serializer.java | Class | Xerces-specific implementation of the Serializer interface, used for
JDK 5 only where Xerecs has been integrated with the core code base. |
XercesJDK5XMLSerializerFactory.java | Class | Xerces-specific implementation of the
XMLSerializerFactory interface. |
XercesOutputFormat.java | Class | Xerces-specific OutputFormat instance. |
XercesSerializer.java | Class | Xerces-specific implementation of the Serializer interface. |
XercesXMLSerializerFactory.java | Class | Xerces-specific implementation of the
XMLSerializerFactory interface. |
XMLClassDescriptor.java | Interface | A class descriptor for describing relationships between a Class
and an XML element or complexType. |
XMLClassDescriptorResolver.java | Interface | An interface for finding or "resolving" XMLClassDescriptor classes. |
XMLConstants.java | Interface | Constants used by all of Castor-XML are defined here. |
XMLContext.java | Class | Bootstrap class for Castor XML that allows you to load information about the
domain objects used with Castor XML (marshallers and unmarshallers) by various means. |
XMLContextTest.java | Class | |
XMLException.java | Class | An exception that is used to signal an error that has occured during
marshaling or unmarshaling. |
XMLFieldDescriptor.java | Interface | XML field descriptor. |
XMLFieldHandler.java | Class | This FieldHandler is used in the generated descriptors. |
XMLMappingLoader.java | Class | An XML implementation of mapping helper. |
XMLNaming.java | Class | |
XMLSerializerFactory.java | Interface | Configurable factory object for XML serialization. |