org.castor.xml
Class AbstractInternalContext

java.lang.Object
  extended by org.castor.xml.AbstractInternalContext
All Implemented Interfaces:
InternalContext
Direct Known Subclasses:
BackwardCompatibilityContext

public abstract class AbstractInternalContext
extends java.lang.Object
implements InternalContext

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.

Since:
1.1.2
Author:
Joachim Grueneis

Constructor Summary
AbstractInternalContext()
          Creates an instance of AbstractInternalContext.
 
Method Summary
 void addClass(java.lang.Class clazz)
          Loads the class descriptor for the class instance specified.
 void addClasses(java.lang.Class[] clazzes)
          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.
 java.lang.Boolean getBooleanProperty(java.lang.String propertyName)
          Providing access to Boolean properties of the configuration.
 java.lang.ClassLoader getClassLoader()
          To get the ClassLoader to use for loading resources.
 Introspector getIntrospector()
          To get the Introspector assigned to this XMLContext.
 JavaNaming getJavaNaming()
          The JavaNaming instance to be used.
 boolean getLenientIdValidation()
          Get lenient id validation flag.
 boolean getLenientSequenceOrder()
          Get lenient sequence order flag.
 java.lang.Boolean getLoadPackageMapping()
          Get load package mapping flag.
 MappingLoader getMappingLoader()
          To get the MappingLoader specified to be used in this Castor session.
 OutputFormat getOutputFormat()
          Returns the default OutputFormat for use with a Serializer.
 org.xml.sax.Parser getParser()
          Return an XML document parser implementing the feature list specified in the configuration file.
 org.xml.sax.Parser getParser(java.lang.String features)
          Returns an XML document parser implementing the requested set of features.
 NodeType getPrimitiveNodeType()
          Returns the NodeType to use for Java primitives.
 java.lang.Object getProperty(java.lang.String propertyName)
          To get the value of a specific property.
 RegExpEvaluator getRegExpEvaluator()
          Returns a new instance of the specified Regular Expression Evaluator, or null if no validator was specified.
 ResolverStrategy getResolverStrategy()
          To get the XMLClassDescriptor resolver strategy to be used when resolving classes into class descriptors.
 Serializer getSerializer()
          Returns a default serializer for producing an XML document.
 org.xml.sax.DocumentHandler getSerializer(java.io.OutputStream output)
          Returns a default serializer for producing an XML document to the designated output stream using the default serialization format.
 org.xml.sax.DocumentHandler getSerializer(java.io.Writer output)
          Returns a default serializer for producing an XML document to the designated output stream using the default serialization format.
protected  XMLSerializerFactory getSerializerFactory(java.lang.String serializerFactoryName)
          Returns the currently configured XMLSerializerFactory instance.
 java.lang.String getStringProperty(java.lang.String propertyName)
          Providing access to String properties of the configuration.
 java.lang.Boolean getUseIntrospector()
          To get use-introspection flag.
 XMLClassDescriptorResolver getXMLClassDescriptorResolver()
          To get the XMLClassdescriptorResolver instance hold in the context.
 XMLNaming getXMLNaming()
          Returns the naming conventions to use for the XML framework.
 XMLNaming getXMLNaming(java.lang.ClassLoader classLoader)
          Deprecated. Makes no sence!
 org.xml.sax.XMLReader getXMLReader()
          Returns an XML document parser implementing the requested set of features.
 org.xml.sax.XMLReader getXMLReader(java.lang.String features)
          Returns an XML document parser implementing the requested set of features.
 boolean marshallingValidation()
          To get marshalling-validation flag.
 void setClassLoader(java.lang.ClassLoader classLoader)
          To set the class loader to be used in all further marshalling, unmarshalling and other actions.
 void setIntrospector(Introspector introspector)
          To specify which Introspector?is to be used.
 void setJavaNaming(JavaNaming javaNaming)
          To set the JavaNaming?property.
 void setJavaNaming(java.lang.String javaNamingProperty)
           
 void setLoadPackageMapping(java.lang.Boolean loadPackageMapping)
          To set the load package mapping flag.
 void setMappingLoader(MappingLoader mappingLoader)
          To set the MappingLoader to be used in this Castor session.
 void setProperty(java.lang.String propertyName, boolean value)
          To set any boolean property.
 void setProperty(java.lang.String propertyName, java.lang.Object value)
          To set properties for marshalling and unmarshalling behavior.
 void setResolver(XMLClassDescriptorResolver xmlClassDescriptorResolver)
          Sets an application-specific XMLClassDescriptorResolver instance.
 void setResolverStrategy(ResolverStrategy resolverStrategy)
          To set the XMLClassDescriptor resolver strategy to be used.
 void setUseIntrospector(java.lang.Boolean useIntrospector)
          To set use-introspection flag.
 void setXMLClassDescriptorResolver(XMLClassDescriptorResolver xmlClassDescriptorResolver)
          To set the XMLClassDescriptorResolver to be used.
 void setXMLNaming(java.lang.String xmlNamingProperty)
          This XMLNaming setter is meant to be used when working in property style instead of setting an XMLNaming implementation.
 void setXMLNaming(XMLNaming xmlNaming)
          To set the XMLNaming property.
 boolean strictElements()
          To get strict-element flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractInternalContext

public AbstractInternalContext()
Creates an instance of AbstractInternalContext. The internal context is meant to hold the configuration and state informations, but not necessarily retrieving those values...

Method Detail

addMapping

public void addMapping(Mapping mapping)
                throws MappingException
Description copied from interface: InternalContext
Instructs Castor to load class descriptors from the mapping given.

Specified by:
addMapping in interface InternalContext
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.
See Also:
InternalContext.addMapping(org.exolab.castor.mapping.Mapping)

addClass

public void addClass(java.lang.Class clazz)
              throws ResolverException
Description copied from interface: InternalContext
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).

Specified by:
addClass in interface InternalContext
Parameters:
clazz - the class for which the associated descriptor should be loaded.
Throws:
ResolverException - in case that resolving the Class fails fatally
See Also:
InternalContext.addClass(java.lang.Class)

addClasses

public void addClasses(java.lang.Class[] clazzes)
                throws ResolverException
Description copied from interface: InternalContext
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).

Specified by:
addClasses in interface InternalContext
Parameters:
clazzes - the classes for which the associated descriptor should be loaded.
Throws:
ResolverException - in case that resolving the Class fails fatally
See Also:
InternalContext.addClasses(java.lang.Class[])

addPackage

public void addPackage(java.lang.String packageName)
                throws ResolverException
Description copied from interface: InternalContext
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).

Specified by:
addPackage in interface InternalContext
Parameters:
packageName - The package name for the (descriptor) classes
Throws:
ResolverException - If there's a problem loading class descriptors for the given package.
See Also:
InternalContext.addPackage(java.lang.String)

addPackages

public void addPackages(java.lang.String[] packageNames)
                 throws ResolverException
Description copied from interface: InternalContext
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).

Specified by:
addPackages in interface InternalContext
Parameters:
packageNames - The package names for the (descriptor) classes
Throws:
ResolverException - If there's a problem loading class descriptors for the given package.
See Also:
InternalContext.addPackages(java.lang.String[])

setResolver

public void setResolver(XMLClassDescriptorResolver xmlClassDescriptorResolver)
Description copied from interface: InternalContext
Sets an application-specific XMLClassDescriptorResolver instance.

Specified by:
setResolver in interface InternalContext
Parameters:
xmlClassDescriptorResolver - the resolver to use
See Also:
InternalContext.setResolver(org.exolab.castor.xml.XMLClassDescriptorResolver)

setProperty

public void setProperty(java.lang.String propertyName,
                        java.lang.Object value)
To set properties for marshalling and unmarshalling behavior.

Specified by:
setProperty in interface InternalContext
Parameters:
propertyName - name of the property to set
value - the value to set to
See Also:
InternalContext.setProperty(java.lang.String, java.lang.Object)

getProperty

public java.lang.Object getProperty(java.lang.String propertyName)
Description copied from interface: InternalContext
To get the value of a specific property.

Specified by:
getProperty in interface InternalContext
Parameters:
propertyName - name of the Property
Returns:
the value (Object) of the property
See Also:
InternalContext.getProperty(java.lang.String)

getXMLNaming

public XMLNaming getXMLNaming()
Returns the naming conventions to use for the XML framework.

Specified by:
getXMLNaming in interface InternalContext
Returns:
the naming conventions to use for the XML framework
See Also:
InternalContext.getXMLNaming()

getXMLNaming

public XMLNaming getXMLNaming(java.lang.ClassLoader classLoader)
Deprecated. Makes no sence!

Returns the naming conventions to use for the XML framework.

Specified by:
getXMLNaming in interface InternalContext
Parameters:
classLoader - the class loader to be used when instantiating a new naming instance
Returns:
the naming conventions to use for the XML framework
See Also:
InternalContext.getXMLNaming(java.lang.ClassLoader)

getJavaNaming

public JavaNaming getJavaNaming()
Description copied from interface: InternalContext
The JavaNaming instance to be used.

Specified by:
getJavaNaming in interface InternalContext
Returns:
JavaNaming instance to be used.
See Also:
InternalContext.getJavaNaming()

getParser

public org.xml.sax.Parser getParser()
Description copied from interface: InternalContext
Return an XML document parser implementing the feature list specified in the configuration file.

Specified by:
getParser in interface InternalContext
Returns:
A suitable XML parser
See Also:
InternalContext.getParser()

getParser

public org.xml.sax.Parser getParser(java.lang.String features)
Description copied from interface: InternalContext
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.

Specified by:
getParser in interface InternalContext
Parameters:
features - The requested feature list, null for the defaults
Returns:
A suitable XML parser
See Also:
InternalContext.getParser(java.lang.String)

getXMLReader

public org.xml.sax.XMLReader getXMLReader()
Description copied from interface: InternalContext
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.

Specified by:
getXMLReader in interface InternalContext
Returns:
A suitable XML parser
See Also:
InternalContext.getXMLReader()

getXMLReader

public org.xml.sax.XMLReader getXMLReader(java.lang.String features)
Description copied from interface: InternalContext
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.

Specified by:
getXMLReader in interface InternalContext
Parameters:
features - the name of feature to set
Returns:
A suitable XML parser
See Also:
InternalContext.getXMLReader(java.lang.String)

getPrimitiveNodeType

public NodeType getPrimitiveNodeType()
Description copied from interface: InternalContext
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.

Specified by:
getPrimitiveNodeType in interface InternalContext
Returns:
the NodeType assigned to Java primitives, or null if no NodeType was specified.
See Also:
InternalContext.getPrimitiveNodeType()

getRegExpEvaluator

public RegExpEvaluator getRegExpEvaluator()
Returns a new instance of the specified Regular Expression Evaluator, or null if no validator was specified.

Specified by:
getRegExpEvaluator in interface InternalContext
Returns:
the regular expression evaluator,
See Also:
InternalContext.getRegExpEvaluator()

getSerializer

public Serializer getSerializer()
Description copied from interface: InternalContext
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.

Specified by:
getSerializer in interface InternalContext
Returns:
A suitable serializer
See Also:
InternalContext.getSerializer()

getOutputFormat

public OutputFormat getOutputFormat()
Description copied from interface: InternalContext
Returns the default OutputFormat for use with a Serializer.

Specified by:
getOutputFormat in interface InternalContext
Returns:
the default OutputFormat
See Also:
InternalContext.getOutputFormat()

getSerializerFactory

protected XMLSerializerFactory getSerializerFactory(java.lang.String serializerFactoryName)
Returns the currently configured XMLSerializerFactory instance.

Parameters:
serializerFactoryName - the class name of the serializer factory
Returns:
XMLSerializerFactory to use by Castor

getSerializer

public org.xml.sax.DocumentHandler getSerializer(java.io.OutputStream output)
                                          throws java.io.IOException
Description copied from interface: InternalContext
Returns a default serializer for producing an XML document to the designated output stream using the default serialization format.

Specified by:
getSerializer in interface InternalContext
Parameters:
output - The output stream
Returns:
A suitable serializer
Throws:
java.io.IOException - if instantiation of the serializer fails
See Also:
InternalContext.getSerializer(java.io.OutputStream)

getSerializer

public org.xml.sax.DocumentHandler getSerializer(java.io.Writer output)
                                          throws java.io.IOException
Description copied from interface: InternalContext
Returns a default serializer for producing an XML document to the designated output stream using the default serialization format.

Specified by:
getSerializer in interface InternalContext
Parameters:
output - The output stream
Returns:
A suitable serializer
Throws:
java.io.IOException - if instantiation of serializer fails
See Also:
InternalContext.getSerializer(java.io.Writer)

getXMLClassDescriptorResolver

public XMLClassDescriptorResolver getXMLClassDescriptorResolver()
Description copied from interface: InternalContext
To get the XMLClassdescriptorResolver instance hold in the context.

Specified by:
getXMLClassDescriptorResolver in interface InternalContext
Returns:
the XMLClassdescriptorResolver instance hold in the context
See Also:
InternalContext.getXMLClassDescriptorResolver()

getIntrospector

public Introspector getIntrospector()
Description copied from interface: InternalContext
To get the Introspector assigned to this XMLContext.

Specified by:
getIntrospector in interface InternalContext
Returns:
the Introspector assigned to this XMLContext
See Also:
InternalContext.getIntrospector()

getResolverStrategy

public ResolverStrategy getResolverStrategy()
Description copied from interface: InternalContext
To get the XMLClassDescriptor resolver strategy to be used when resolving classes into class descriptors.

Specified by:
getResolverStrategy in interface InternalContext
Returns:
the ResolverStrategy to use
See Also:
InternalContext.getResolverStrategy()

setResolverStrategy

public void setResolverStrategy(ResolverStrategy resolverStrategy)
Description copied from interface: InternalContext
To set the XMLClassDescriptor resolver strategy to be used.

Specified by:
setResolverStrategy in interface InternalContext
Parameters:
resolverStrategy - the ResolverStrategy to use
See Also:
InternalContext.setResolverStrategy(org.exolab.castor.xml.util.ResolverStrategy)

setMappingLoader

public void setMappingLoader(MappingLoader mappingLoader)
Description copied from interface: InternalContext
To set the MappingLoader to be used in this Castor session.

Specified by:
setMappingLoader in interface InternalContext
Parameters:
mappingLoader - the MappingLoader to use
See Also:
InternalContext.setMappingLoader(org.exolab.castor.mapping.MappingLoader)

getMappingLoader

public MappingLoader getMappingLoader()
Description copied from interface: InternalContext
To get the MappingLoader specified to be used in this Castor session.

Specified by:
getMappingLoader in interface InternalContext
Returns:
the MappingLoader to use
See Also:
InternalContext.getMappingLoader()

setJavaNaming

public void setJavaNaming(JavaNaming javaNaming)
Description copied from interface: InternalContext
To set the JavaNaming?property.

Specified by:
setJavaNaming in interface InternalContext
Parameters:
javaNaming - the JavaNaming to use
See Also:
InternalContext.setJavaNaming(org.castor.xml.JavaNaming)

setJavaNaming

public void setJavaNaming(java.lang.String javaNamingProperty)

setXMLNaming

public void setXMLNaming(XMLNaming xmlNaming)
Description copied from interface: InternalContext
To set the XMLNaming property.

Specified by:
setXMLNaming in interface InternalContext
Parameters:
xmlNaming - the XMLNaming to use
See Also:
InternalContext.setXMLNaming(org.castor.xml.XMLNaming)

setXMLNaming

public void setXMLNaming(java.lang.String xmlNamingProperty)
This XMLNaming setter is meant to be used when working in property style instead of setting an XMLNaming implementation.

Parameters:
xmlNamingProperty - to set the XMLNaming property as read from configuration

setProperty

public void setProperty(java.lang.String propertyName,
                        boolean value)
Description copied from interface: InternalContext
To set any boolean property.

Specified by:
setProperty in interface InternalContext
Parameters:
propertyName - name of the property to set
value - boolean value to set
See Also:
InternalContext.setProperty(java.lang.String, boolean)

getBooleanProperty

public java.lang.Boolean getBooleanProperty(java.lang.String propertyName)
Description copied from interface: InternalContext
Providing access to Boolean properties of the configuration.

Specified by:
getBooleanProperty in interface InternalContext
Parameters:
propertyName - name of the property
Returns:
null if property is not set or whichever value is set
See Also:
InternalContext.getBooleanProperty(java.lang.String)

getStringProperty

public java.lang.String getStringProperty(java.lang.String propertyName)
Description copied from interface: InternalContext
Providing access to String properties of the configuration.

Specified by:
getStringProperty in interface InternalContext
Parameters:
propertyName - name of the property
Returns:
null if the property is not set or whichever value is set
See Also:
InternalContext.getStringProperty(java.lang.String)

setClassLoader

public void setClassLoader(java.lang.ClassLoader classLoader)
Description copied from interface: InternalContext
To set the class loader to be used in all further marshalling, unmarshalling and other actions.

Specified by:
setClassLoader in interface InternalContext
Parameters:
classLoader - the ClassLoader instance to use
See Also:
InternalContext.setClassLoader(java.lang.ClassLoader)

setXMLClassDescriptorResolver

public void setXMLClassDescriptorResolver(XMLClassDescriptorResolver xmlClassDescriptorResolver)
Description copied from interface: InternalContext
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?

Specified by:
setXMLClassDescriptorResolver in interface InternalContext
Parameters:
xmlClassDescriptorResolver - the XMLClassDescriptorResolver to use
See Also:
InternalContext.setXMLClassDescriptorResolver(org.exolab.castor.xml.XMLClassDescriptorResolver)

setIntrospector

public void setIntrospector(Introspector introspector)
Description copied from interface: InternalContext
To specify which Introspector?is to be used.

Specified by:
setIntrospector in interface InternalContext
Parameters:
introspector - Introspector to be used
See Also:
InternalContext.setIntrospector(org.exolab.castor.xml.Introspector)

getClassLoader

public java.lang.ClassLoader getClassLoader()
Description copied from interface: InternalContext
To get the ClassLoader to use for loading resources.

Specified by:
getClassLoader in interface InternalContext
Returns:
the ClassLoader to use
See Also:
InternalContext.getClassLoader()

getLenientIdValidation

public boolean getLenientIdValidation()
Description copied from interface: InternalContext
Get lenient id validation flag.

Specified by:
getLenientIdValidation in interface InternalContext
Returns:
lenient id validation flag
See Also:
InternalContext.getLenientIdValidation()

getLenientSequenceOrder

public boolean getLenientSequenceOrder()
Description copied from interface: InternalContext
Get lenient sequence order flag.

Specified by:
getLenientSequenceOrder in interface InternalContext
Returns:
lenient sequence order flag
See Also:
InternalContext.getLenientSequenceOrder()

getLoadPackageMapping

public java.lang.Boolean getLoadPackageMapping()
Description copied from interface: InternalContext
Get load package mapping flag.

Specified by:
getLoadPackageMapping in interface InternalContext
Returns:
load package mapping flag
See Also:
InternalContext.getLoadPackageMapping()

setLoadPackageMapping

public void setLoadPackageMapping(java.lang.Boolean loadPackageMapping)
Description copied from interface: InternalContext
To set the load package mapping flag.

Specified by:
setLoadPackageMapping in interface InternalContext
Parameters:
loadPackageMapping - the load package mapping flag
See Also:
InternalContext.setLoadPackageMapping(java.lang.Boolean)

getUseIntrospector

public java.lang.Boolean getUseIntrospector()
Description copied from interface: InternalContext
To get use-introspection flag.

Specified by:
getUseIntrospector in interface InternalContext
Returns:
use-introspection flag
See Also:
InternalContext.getUseIntrospector()

setUseIntrospector

public void setUseIntrospector(java.lang.Boolean useIntrospector)
Description copied from interface: InternalContext
To set use-introspection flag.

Specified by:
setUseIntrospector in interface InternalContext
Parameters:
useIntrospector - use-introspection flag
See Also:
InternalContext.setUseIntrospector(java.lang.Boolean)

marshallingValidation

public boolean marshallingValidation()
Description copied from interface: InternalContext
To get marshalling-validation flag.

Specified by:
marshallingValidation in interface InternalContext
Returns:
marshalling-validation flag
See Also:
InternalContext.marshallingValidation()

strictElements

public boolean strictElements()
Description copied from interface: InternalContext
To get strict-element flag.

Specified by:
strictElements in interface InternalContext
Returns:
strict-element flag
See Also:
InternalContext.strictElements()


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