org.exolab.castor.xml
Class XMLContext

java.lang.Object
  extended by org.exolab.castor.xml.XMLContext

public class XMLContext
extends java.lang.Object

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.

Since:
1.1.2
Author:
Werner Guttmann

Constructor Summary
XMLContext()
          Creates an instance of XMLContext, preconfigured with class descriptors loaded for the given package name.
 
Method Summary
 void addClass(java.lang.String className)
          Loads the class descriptor for the class instance specified.
 void addClasses(java.lang.String[] classNames)
          Loads the class descriptor for the class instance specified.
 void addMapping(Mapping mapping)
          Instructs Castor to load class descriptors from the mapping given.
 void addPackage(java.lang.String packageName)
          Loads class descriptors from the package specified.
 void addPackages(java.lang.String[] packageNames)
          Loads class descriptors from the packages specified.
static Mapping createMapping()
          Creates an instance of a Castor XML specific Mapping instance.
 Marshaller createMarshaller()
          Creates a new Marshaller instance to be used for marshalling.
 Unmarshaller createUnmarshaller()
          Creates a new Unmarshaller instance to be used for unmarshalling.
 void setResolver(XMLClassDescriptorResolver resolver)
          Sets an application-specific XMLClassDescriptorResolver instance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLContext

public XMLContext()
Creates an instance of XMLContext, preconfigured with class descriptors loaded for the given package name.

Method Detail

addMapping

public void addMapping(Mapping mapping)
                throws MappingException
Instructs Castor to load class descriptors from the mapping given.

Parameters:
mapping - Castor XML mapping (file), from which the required class descriptors will be derived.
Throws:
MappingException - If the Mapping cannot be loaded and analyzed successfully.

addClass

public void addClass(java.lang.String className)
Loads the class descriptor for the class instance specified. The use of this method is useful when no mapping is used, as happens when the domain classes hase been generated using the XML code generator (in which case instead of a mapping file class descriptor files will be generated).

Parameters:
className - Name of the class for which the associated descriptor should be loaded.

addClasses

public void addClasses(java.lang.String[] classNames)
Loads the class descriptor for the class instance specified. The use of this method is useful when no mapping is used, as happens when the domain classes hase been generated using the XML code generator (in which case instead of a mapping file class descriptor files will be generated).

Parameters:
className - Name of the class for which the associated descriptor should be loaded.

addPackage

public void addPackage(java.lang.String packageName)
                throws ResolverException
Loads class descriptors from the package specified. The use of this method is useful when no mapping is used, as happens when the domain classes hase been generated using the XML code generator (in which case instead of a mapping file class descriptor files will be generated).

Please note that this functionality will work only if you provide the .castor.cdr file with your generated classes (as generated by the XML code generator).

Parameters:
packageName - The package name for the (descriptor) classes
Throws:
ResolverException - If there's a problem loading class descriptors for the given package.

addPackages

public void addPackages(java.lang.String[] packageNames)
                 throws ResolverException
Loads class descriptors from the packages specified. The use of this method is useful when no mapping is used, as happens when the domain classes hase been generated using the XML code generator (in which case instead of a mapping file class descriptor files will be generated).

Please note that this functionality will work only if you provide the .castor.cdr files with your generated classes (as generated by the XML code generator).

Parameters:
packageNames - The package names for the (descriptor) classes
Throws:
ResolverException - If there's a problem loading class descriptors for the given package.

createMapping

public static Mapping createMapping()
Creates an instance of a Castor XML specific Mapping instance.

Returns:
a Castor XML specific Mapping instance.

createMarshaller

public Marshaller createMarshaller()
Creates a new Marshaller instance to be used for marshalling.

Returns:
A new Marshaller instance.

createUnmarshaller

public Unmarshaller createUnmarshaller()
Creates a new Unmarshaller instance to be used for unmarshalling.

Returns:
A new Unmarshaller instance, preconfigured with a XMLClassDescriptorResolver instance with the class descriptors cached as loaded above.

setResolver

public void setResolver(XMLClassDescriptorResolver resolver)
Sets an application-specific XMLClassDescriptorResolver instance

Parameters:
resolver -


Intalio Inc. (C) 1999-2007. All rights reserved http://www.intalio.com