Prev Package | Next Package | Frames | No Frames |
Marshaller
marshalls a Java object into an XML document.Interface Summary | |
AttributeSet | A simple interface for handling Attributes in the Marshalling Framework. |
ClassDescriptorEnumeration | An enumeration interface specifically for XMLClassDescriptors. |
ClassDescriptorResolver | An interface for finding or "resolving" XMLClassDescriptor classes. |
ClassValidator | The validation interface used for validating class instances |
EventProducer | A interface which abstracts anything which can produce SAX events. |
IDResolver | A simple interface for doing custom IDREF resolving during Unmarshalling. |
Location | A simple Location class used for fine grained detail of exceptions |
MarshalListener | 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. |
TypeValidator | The basic type validation interface class |
UnmarshalListener | An interface to allow external "listening" to objects when they are being unmarshalled for various tracking purposes and potential modification. |
XMLClassDescriptor | A class descriptor for describing relationships between a Class and an XML element or complexType. |
XMLFieldDescriptor | XML field descriptor. |
Class Summary | |
AccessRights | A class used to indicate access rights |
CastorException | The base exception for Castor (or at least Castor XML) |
DebugHandler | A Simple DocumentHandler that intercepts SAX events and prints them to the console |
DescriptorType | This class represents the Possible Descriptor types used by the marshalling Framework. |
FieldValidator | Handles field validation |
FileLocation | A simple FileLocation class used for finer grained detail of exceptions |
IntrospectedXMLClassDescriptor | A simple extension of XMLClassDescriptor so that we can set the "instrospected" flag. |
Introspector | A Helper class for the Marshaller and Unmarshaller, basically the common code base between the two. |
Introspector.MethodSet | A simple struct for holding a set of accessor methods |
JavaNaming | This class converts XML Names to proper Java names. |
MarshalException | An exception that is used to signal marshalling exceptions. |
MarshalFramework | A core class for common code shared throughout the Marshalling Framework |
MarshalFramework.InheritanceMatch | Used to store the information when we find a possible inheritance. |
MarshalFramework.InternalXMLClassDescriptor | An internal implementation of XMLClassDescriptor used by the Unmarshaller and Marshaller... |
Marshaller | A Marshaller to allowing 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. |
Namespaces | A class for handling Namespace declaration and scoping |
Namespaces.Namespace | An internal class used to represent a namespace |
Namespaces.NamespaceEnumerator | A simple Enumeration for Namespace objects |
NodeType | The possible node types for an XML field. |
ProcessingInstruction | A class that represents an XML processing instruction. |
SimpleTypeValidator | A class for defining simple rules used for validating a content model |
UnmarshalHandler | An unmarshaller to allowing unmarshalling of XML documents to Java Objects. |
UnmarshalHandler.Arguments | Internal class used for passing constructor argument information |
UnmarshalHandler.ArrayHandler | A class for handling Arrays during unmarshalling. |
UnmarshalHandler.IDResolverImpl | Local IDResolver |
UnmarshalHandler.ReferenceInfo | Internal class used to save state for reference resolving |
Unmarshaller | An unmarshaller to allowing unmarshalling of XML documents to Java Objects. |
UnmarshalState | Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. |
ValidationContext | A class which can be used to hold validation information, used by the TypeValidator interface. |
ValidationException | An exception that can be used to signal XML validation errors |
Validator | A class which can perform Validation on an Object model. |
XMLException | An exception that is used to signal an error that has occured during marshalling or unmarshalling. |
XMLFieldHandler | A field handler knows how to perform various operations on the field that require access to the field value. |
XMLMappingLoader | An XML implementation of mapping helper. |
XMLMappingLoader.ContainerElementFieldDescriptor | An extended XMLFieldDescriptor that allows us to change the fieldType, needed for container element support |
XMLMappingLoader.IdentityConvertor | A special TypeConvertor that simply returns the object given. |
XMLNaming | An abstract class to handing XML naming |
XPathLocation | A very simple XPath location class for use with the ValidationException. |
Marshaller
marshalls a Java object into an XML document.
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 );