The internal context is meant as center piece providing (and keeping) all
information that is required by Marshaller, Unmarshaller, SourceGenerator,
MappingTool, SchemaReader and SchemaWriter. It is created, filled with
initial data and put into all other parts of Castor by XMLContext
.
It is NOT meant to be directly instantiated by user implementations!
For all other objects it provides access to Castor state information
(e.g. known descriptors) and configuration values.
addClass
public abstract void addClass(Class clazz)
throws ResolverException
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 has been generated
using the XML code generator (in which case instead of a mapping file class
descriptor files will be generated).
clazz
- the class for which the associated descriptor should be loaded.
addClasses
public abstract void addClasses(Class[] clazzes)
throws ResolverException
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).
clazzes
- the classes for which the associated descriptor should be loaded.
addMapping
public abstract void addMapping(Mapping mapping)
throws MappingException
Instructs Castor to load class descriptors from the mapping given.
mapping
- Castor XML mapping (file), from which the required class
descriptors will be derived.
addPackage
public abstract void addPackage(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).
packageName
- The package name for the (descriptor) classes
ResolverException
- If there's a problem loading class descriptors for the given package.
addPackages
public abstract void addPackages(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).
packageNames
- The package names for the (descriptor) classes
ResolverException
- If there's a problem loading class descriptors for the given package.
getBooleanProperty
public abstract Boolean getBooleanProperty(String propertyName)
Providing access to Boolean properties of the configuration.
propertyName
- name of the property
- null if property is not set or whichever value is set
getClassLoader
public abstract ClassLoader getClassLoader()
To get the ClassLoader to use for loading resources.
getIntrospector
public abstract Introspector getIntrospector()
To get the Introspector assigned to this XMLContext.
- the Introspector assigned to this XMLContext
getJavaNaming
public abstract JavaNaming getJavaNaming()
getLenientIdValidation
public abstract boolean getLenientIdValidation()
Get lenient id validation flag.
- lenient id validation flag
getLenientSequenceOrder
public abstract boolean getLenientSequenceOrder()
Get lenient sequence order flag.
- lenient sequence order flag
getLoadPackageMapping
public abstract Boolean getLoadPackageMapping()
Get load package mapping flag.
- load package mapping flag
getMappingLoader
public abstract MappingLoader getMappingLoader()
To get the
MappingLoader
specified to be used in this Castor session.
getOutputFormat
public abstract OutputFormat getOutputFormat()
Returns the default OutputFormat for use with a Serializer.
getParser
public abstract Parser getParser()
Return an XML document parser implementing the feature list
specified in the configuration file.
getParser
public abstract Parser getParser(String features)
Returns an XML document parser implementing the requested
set of features. The feature list is a comma separated list
of features that parser may or may not support. No errors are
generated for unsupported features. If the feature list is not
null, it overrides the default feature list specified in the
configuration file, including validation and Namespaces.
features
- The requested feature list, null for the
defaults
getPrimitiveNodeType
public abstract NodeType getPrimitiveNodeType()
Returns the NodeType to use for Java primitives.
A null value will be returned if no NodeType was specified,
indicating the default NodeType should be used.
- the NodeType assigned to Java primitives, or null
if no NodeType was specified.
getProperty
public abstract Object getProperty(String propertyName)
To get the value of a specific property.
propertyName
- name of the Property
- the value (Object) of the property
getRegExpEvaluator
public abstract RegExpEvaluator getRegExpEvaluator()
Returns a new instance of the specified Regular Expression
Evaluator, or null if no validator was specified.
- the regular expression evaluator,
getResolverStrategy
public abstract ResolverStrategy getResolverStrategy()
To get the XMLClassDescriptor resolver strategy to be used when
resolving classes into class descriptors.
- the ResolverStrategy to use
getSerializer
public abstract Serializer getSerializer()
Returns a default serializer for producing an XML document. The caller
can specify an alternative output format, may reuse this serializer
across several streams, and may serialize both DOM and SAX events. If
such control is not required, it is recommended to call one of the other
two methods.
getSerializer
public abstract DocumentHandler getSerializer(OutputStream output)
throws IOException
Returns a default serializer for producing an XML document to
the designated output stream using the default serialization
format.
output
- The output stream
getSerializer
public abstract DocumentHandler getSerializer(Writer output)
throws IOException
Returns a default serializer for producing an XML document to the
designated output stream using the default serialization format.
output
- The output stream
getStringProperty
public abstract String getStringProperty(String propertyName)
Providing access to String properties of the configuration.
propertyName
- name of the property
- null if the property is not set or whichever value is set
getUseIntrospector
public abstract Boolean getUseIntrospector()
To get use-introspection flag.
getXMLClassDescriptorResolver
public abstract XMLClassDescriptorResolver getXMLClassDescriptorResolver()
To get the XMLClassdescriptorResolver instance hold in the context.
- the XMLClassdescriptorResolver instance hold in the context
getXMLNaming
public abstract XMLNaming getXMLNaming()
Returns the naming conventions to use for the XML framework.
- the naming conventions to use for the XML framework
getXMLNaming
public abstract XMLNaming getXMLNaming(ClassLoader classLoader)
Returns the naming conventions to use for the XML framework.
classLoader
- the class loader to be used when instantiating a new naming instance
- the naming conventions to use for the XML framework
getXMLReader
public abstract XMLReader getXMLReader()
Returns an XML document parser implementing the requested set of
features. The feature list is a comma separated list of features that
parser may or may not support. No errors are generated for unsupported
features. If the feature list is not null, it overrides the default
feature list specified in the configuration file, including validation
and Namespaces.
getXMLReader
public abstract XMLReader getXMLReader(String features)
Returns an XML document parser implementing the requested
set of features. The feature list is a comma separated list
of features that parser may or may not support. No errors are
generated for unsupported features. If the feature list is not
null, it overrides the default feature list specified in the
configuration file, including validation and Namespaces.
features
- the name of feature to set
marshallingValidation
public abstract boolean marshallingValidation()
To get marshalling-validation flag.
- marshalling-validation flag
setClassLoader
public abstract void setClassLoader(ClassLoader classLoader)
To set the class loader to be used in all further marshalling, unmarshalling
and other actions.
classLoader
- the ClassLoader instance to use
setIntrospector
public abstract void setIntrospector(Introspector introspector)
setJavaNaming
public abstract void setJavaNaming(JavaNaming javaNaming)
setLoadPackageMapping
public abstract void setLoadPackageMapping(Boolean loadPackageMapping)
To set the load package mapping flag.
loadPackageMapping
- the load package mapping flag
setMappingLoader
public abstract void setMappingLoader(MappingLoader mappingLoader)
setProperty
public abstract void setProperty(String propertyName,
Object value)
To set properties for marshalling and unmarshalling behavior.
propertyName
- name of the property to setvalue
- the value to set to
setProperty
public abstract void setProperty(String propertyName,
boolean value)
To set any boolean property.
propertyName
- name of the property to setvalue
- boolean value to set
setResolver
public abstract void setResolver(XMLClassDescriptorResolver xmlClassDescriptorResolver)
xmlClassDescriptorResolver
- the resolver to use
setResolverStrategy
public abstract void setResolverStrategy(ResolverStrategy resolverStrategy)
To set the XMLClassDescriptor resolver strategy to be used.
resolverStrategy
- the ResolverStrategy to use
setUseIntrospector
public abstract void setUseIntrospector(Boolean useIntrospector)
To set use-introspection flag.
useIntrospector
- use-introspection flag
setXMLClassDescriptorResolver
public abstract void setXMLClassDescriptorResolver(XMLClassDescriptorResolver xmlClassDescriptorResolver)
To set the
XMLClassDescriptorResolver
to be used. Be aware, that the
XMLClassDescriptorResolver instance holds a descriptor cache!! Maybe change it
to have the descriptor cache as part of the context?
setXMLNaming
public abstract void setXMLNaming(XMLNaming xmlNaming)
strictElements
public abstract boolean strictElements()
To get strict-element flag.