Package org.castor.xml
Class AbstractInternalContext
- java.lang.Object
-
- 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 byXMLContext
. 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
Constructors Constructor Description AbstractInternalContext()
Creates an instance ofAbstractInternalContext
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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()
TheJavaNaming
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 theMappingLoader
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 whichIntrospector
?is to be used.void
setJavaNaming(java.lang.String javaNamingProperty)
void
setJavaNaming(JavaNaming javaNaming)
To set theJavaNaming
?property.void
setLoadPackageMapping(java.lang.Boolean loadPackageMapping)
To set the load package mapping flag.void
setMappingLoader(MappingLoader mappingLoader)
To set theMappingLoader
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-specificXMLClassDescriptorResolver
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 theXMLClassDescriptorResolver
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 theXMLNaming
property.boolean
strictElements()
To get strict-element flag.
-
-
-
Constructor Detail
-
AbstractInternalContext
public AbstractInternalContext()
Creates an instance ofAbstractInternalContext
. 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 interfaceInternalContext
- Parameters:
mapping
- Castor XML mapping (file), from which the required class descriptors will be derived.- Throws:
MappingException
- If theMapping
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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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-specificXMLClassDescriptorResolver
instance.- Specified by:
setResolver
in interfaceInternalContext
- 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 interfaceInternalContext
- Parameters:
propertyName
- name of the property to setvalue
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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
TheJavaNaming
instance to be used.- Specified by:
getJavaNaming
in interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 theMappingLoader
to be used in this Castor session.- Specified by:
setMappingLoader
in interfaceInternalContext
- Parameters:
mappingLoader
- theMappingLoader
to use- See Also:
InternalContext.setMappingLoader(org.exolab.castor.mapping.MappingLoader)
-
getMappingLoader
public MappingLoader getMappingLoader()
Description copied from interface:InternalContext
To get theMappingLoader
specified to be used in this Castor session.- Specified by:
getMappingLoader
in interfaceInternalContext
- Returns:
- the
MappingLoader
to use - See Also:
InternalContext.getMappingLoader()
-
setJavaNaming
public void setJavaNaming(JavaNaming javaNaming)
Description copied from interface:InternalContext
To set theJavaNaming
?property.- Specified by:
setJavaNaming
in interfaceInternalContext
- Parameters:
javaNaming
- theJavaNaming
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 theXMLNaming
property.- Specified by:
setXMLNaming
in interfaceInternalContext
- Parameters:
xmlNaming
- theXMLNaming
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 interfaceInternalContext
- Parameters:
propertyName
- name of the property to setvalue
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 theXMLClassDescriptorResolver
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 interfaceInternalContext
- Parameters:
xmlClassDescriptorResolver
- theXMLClassDescriptorResolver
to use- See Also:
InternalContext.setXMLClassDescriptorResolver(org.exolab.castor.xml.XMLClassDescriptorResolver)
-
setIntrospector
public void setIntrospector(Introspector introspector)
Description copied from interface:InternalContext
To specify whichIntrospector
?is to be used.- Specified by:
setIntrospector
in interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- 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 interfaceInternalContext
- Returns:
- strict-element flag
- See Also:
InternalContext.strictElements()
-
-