Package org.castor.xml
Class AbstractInternalContext
java.lang.Object
org.castor.xml.AbstractInternalContext
- All Implemented Interfaces:
InternalContext
- Direct Known Subclasses:
BackwardCompatibilityContext
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Loads the class descriptor for the class instance specified.void
addClasses
(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
(String packageName) Loads class descriptors from the package specified.void
addPackages
(String[] packageNames) Loads class descriptors from the packages specified.getBooleanProperty
(String propertyName) Providing access to Boolean properties of the configuration.To get the ClassLoader to use for loading resources.To get the Introspector assigned to this XMLContext.TheJavaNaming
instance to be used.boolean
Get lenient id validation flag.boolean
Get lenient sequence order flag.Get load package mapping flag.To get theMappingLoader
specified to be used in this Castor session.Returns the default OutputFormat for use with a Serializer.Return an XML document parser implementing the feature list specified in the configuration file.Returns an XML document parser implementing the requested set of features.Returns the NodeType to use for Java primitives.getProperty
(String propertyName) To get the value of a specific property.Returns a new instance of the specified Regular Expression Evaluator, or null if no validator was specified.To get the XMLClassDescriptor resolver strategy to be used when resolving classes into class descriptors.Returns a default serializer for producing an XML document.getSerializer
(OutputStream output) Returns a default serializer for producing an XML document to the designated output stream using the default serialization format.getSerializer
(Writer output) Returns a default serializer for producing an XML document to the designated output stream using the default serialization format.protected XMLSerializerFactory
getSerializerFactory
(String serializerFactoryName) Returns the currently configured XMLSerializerFactory instance.getStringProperty
(String propertyName) Providing access to String properties of the configuration.To get use-introspection flag.To get the XMLClassdescriptorResolver instance hold in the context.Returns the naming conventions to use for the XML framework.getXMLNaming
(ClassLoader classLoader) Deprecated.Makes no sence!Returns an XML document parser implementing the requested set of features.getXMLReader
(String features) Returns an XML document parser implementing the requested set of features.boolean
To get marshalling-validation flag.void
setClassLoader
(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
(String javaNamingProperty) void
setJavaNaming
(JavaNaming javaNaming) To set theJavaNaming
?property.void
setLoadPackageMapping
(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
(String propertyName, boolean value) To set any boolean property.void
setProperty
(String propertyName, 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
(Boolean useIntrospector) To set use-introspection flag.void
setXMLClassDescriptorResolver
(XMLClassDescriptorResolver xmlClassDescriptorResolver) To set theXMLClassDescriptorResolver
to be used.void
setXMLNaming
(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
To get strict-element flag.
-
Constructor Details
-
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 Details
-
addMapping
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:
-
addClass
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:
-
addClasses
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:
-
addPackage
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:
-
addPackages
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:
-
setResolver
Description copied from interface:InternalContext
Sets an application-specificXMLClassDescriptorResolver
instance.- Specified by:
setResolver
in interfaceInternalContext
- Parameters:
xmlClassDescriptorResolver
- the resolver to use- See Also:
-
setProperty
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:
-
getProperty
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:
-
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:
-
getXMLNaming
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:
-
getJavaNaming
Description copied from interface:InternalContext
TheJavaNaming
instance to be used.- Specified by:
getJavaNaming
in interfaceInternalContext
- Returns:
JavaNaming
instance to be used.- See Also:
-
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:
-
getParser
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:
-
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:
-
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
- Parameters:
features
- the name of feature to set- Returns:
- A suitable XML parser
- See Also:
-
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:
-
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:
-
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:
-
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:
-
getSerializerFactory
Returns the currently configured XMLSerializerFactory instance.- Parameters:
serializerFactoryName
- the class name of the serializer factory- Returns:
- XMLSerializerFactory to use by Castor
-
getSerializer
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:
IOException
- if instantiation of the serializer fails- See Also:
-
getSerializer
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:
IOException
- if instantiation of serializer fails- See Also:
-
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:
-
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:
-
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:
-
setResolverStrategy
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:
-
setMappingLoader
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:
-
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:
-
setJavaNaming
Description copied from interface:InternalContext
To set theJavaNaming
?property.- Specified by:
setJavaNaming
in interfaceInternalContext
- Parameters:
javaNaming
- theJavaNaming
to use- See Also:
-
setJavaNaming
-
setXMLNaming
Description copied from interface:InternalContext
To set theXMLNaming
property.- Specified by:
setXMLNaming
in interfaceInternalContext
- Parameters:
xmlNaming
- theXMLNaming
to use- See Also:
-
setXMLNaming
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
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:
-
getBooleanProperty
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:
-
getStringProperty
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:
-
setClassLoader
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:
-
setXMLClassDescriptorResolver
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:
-
setIntrospector
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:
-
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:
-
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:
-
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:
-
getLoadPackageMapping
Description copied from interface:InternalContext
Get load package mapping flag.- Specified by:
getLoadPackageMapping
in interfaceInternalContext
- Returns:
- load package mapping flag
- See Also:
-
setLoadPackageMapping
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:
-
getUseIntrospector
Description copied from interface:InternalContext
To get use-introspection flag.- Specified by:
getUseIntrospector
in interfaceInternalContext
- Returns:
- use-introspection flag
- See Also:
-
setUseIntrospector
Description copied from interface:InternalContext
To set use-introspection flag.- Specified by:
setUseIntrospector
in interfaceInternalContext
- Parameters:
useIntrospector
- use-introspection flag- See Also:
-
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:
-
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:
-