The Class Mapping API
- Version:
- $Revision: 1.1.1.1 $ $Date: 2003/03/03 07:08:28 $
- Author:
- Assaf Arkin
- Author:
- Keith Visco
This package provides a common base for the class mapping descriptors and tools to
generate mapping descriptors from a mapping file. The Java objects for the XML-based
mapping file are contained in the sub-package
xml and the DTD and XML schema
originate in this package. The sub-package
loader implements a mapping loader.
Mapping
serves as a generic mapping loader that can
be used to load multiple mapping files and feed them to the XML marshaller, JDO engine,
and DAX engine.
ClassDescriptor
is a mapping descriptor for a Java class,
consisting of any number of fields.
FieldDescriptor
is a
mapping descriptor for a Java field within that class. Access to the field value is granted
through a
FieldHandler
, obtained from the field descriptor.
MappingResolver
is an interface to a collection of class
mapping that can provide the mapping descriptor for a particular Java class. A
MappingResolver
is constructed using a mapping loader, see the
loader package.
The following example illustrates how to load a mapping file with the current class
loader and use it to marshal an object:
Mapping map;
Marshaller mar;
// Load the specified mapping file
map = new Mapping( getClass().getClassLoader() );
map.loadMapping( "mapping.xml" );
// Marshal the object into a document
mar = new Marshaller( output );
mar.setMapping( mapping );
mar.marshal( object );