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 TypeMethodDescriptionvoidLoads the class descriptor for the class instance specified.voidaddClasses(Class[] clazzes) Loads the class descriptor for the class instance specified.voidaddMapping(Mapping mapping) Instructs Castor to load class descriptors from the mapping given.voidaddPackage(String packageName) Loads class descriptors from the package specified.voidaddPackages(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.TheJavaNaminginstance to be used.booleanGet lenient id validation flag.booleanGet lenient sequence order flag.Get load package mapping flag.To get theMappingLoaderspecified 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 XMLSerializerFactorygetSerializerFactory(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.booleanTo get marshalling-validation flag.voidsetClassLoader(ClassLoader classLoader) To set the class loader to be used in all further marshalling, unmarshalling and other actions.voidsetIntrospector(Introspector introspector) To specify whichIntrospector?is to be used.voidsetJavaNaming(String javaNamingProperty) voidsetJavaNaming(JavaNaming javaNaming) To set theJavaNaming?property.voidsetLoadPackageMapping(Boolean loadPackageMapping) To set the load package mapping flag.voidsetMappingLoader(MappingLoader mappingLoader) To set theMappingLoaderto be used in this Castor session.voidsetProperty(String propertyName, boolean value) To set any boolean property.voidsetProperty(String propertyName, Object value) To set properties for marshalling and unmarshalling behavior.voidsetResolver(XMLClassDescriptorResolver xmlClassDescriptorResolver) Sets an application-specificXMLClassDescriptorResolverinstance.voidsetResolverStrategy(ResolverStrategy resolverStrategy) To set the XMLClassDescriptor resolver strategy to be used.voidsetUseIntrospector(Boolean useIntrospector) To set use-introspection flag.voidsetXMLClassDescriptorResolver(XMLClassDescriptorResolver xmlClassDescriptorResolver) To set theXMLClassDescriptorResolverto be used.voidsetXMLNaming(String xmlNamingProperty) This XMLNaming setter is meant to be used when working in property style instead of setting an XMLNaming implementation.voidsetXMLNaming(XMLNaming xmlNaming) To set theXMLNamingproperty.booleanTo 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:InternalContextInstructs Castor to load class descriptors from the mapping given.- Specified by:
addMappingin interfaceInternalContext- Parameters:
mapping- Castor XML mapping (file), from which the required class descriptors will be derived.- Throws:
MappingException- If theMappingcannot be loaded and analyzed successfully.- See Also:
-
addClass
Description copied from interface:InternalContextLoads 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:
addClassin 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:InternalContextLoads 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:
addClassesin 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:InternalContextLoads 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:
addPackagein 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:InternalContextLoads 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:
addPackagesin 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:InternalContextSets an application-specificXMLClassDescriptorResolverinstance.- Specified by:
setResolverin interfaceInternalContext- Parameters:
xmlClassDescriptorResolver- the resolver to use- See Also:
-
setProperty
To set properties for marshalling and unmarshalling behavior.- Specified by:
setPropertyin interfaceInternalContext- Parameters:
propertyName- name of the property to setvalue- the value to set to- See Also:
-
getProperty
Description copied from interface:InternalContextTo get the value of a specific property.- Specified by:
getPropertyin 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:
getXMLNamingin 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:
getXMLNamingin 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:InternalContextTheJavaNaminginstance to be used.- Specified by:
getJavaNamingin interfaceInternalContext- Returns:
JavaNaminginstance to be used.- See Also:
-
getParser
Description copied from interface:InternalContextReturn an XML document parser implementing the feature list specified in the configuration file.- Specified by:
getParserin interfaceInternalContext- Returns:
- A suitable XML parser
- See Also:
-
getParser
Description copied from interface:InternalContextReturns 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:
getParserin interfaceInternalContext- Parameters:
features- The requested feature list, null for the defaults- Returns:
- A suitable XML parser
- See Also:
-
getXMLReader
Description copied from interface:InternalContextReturns 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:
getXMLReaderin interfaceInternalContext- Returns:
- A suitable XML parser
- See Also:
-
getXMLReader
Description copied from interface:InternalContextReturns 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:
getXMLReaderin interfaceInternalContext- Parameters:
features- the name of feature to set- Returns:
- A suitable XML parser
- See Also:
-
getPrimitiveNodeType
Description copied from interface:InternalContextReturns 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:
getPrimitiveNodeTypein 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:
getRegExpEvaluatorin interfaceInternalContext- Returns:
- the regular expression evaluator,
- See Also:
-
getSerializer
Description copied from interface:InternalContextReturns 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:
getSerializerin interfaceInternalContext- Returns:
- A suitable serializer
- See Also:
-
getOutputFormat
Description copied from interface:InternalContextReturns the default OutputFormat for use with a Serializer.- Specified by:
getOutputFormatin 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:InternalContextReturns a default serializer for producing an XML document to the designated output stream using the default serialization format.- Specified by:
getSerializerin 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:InternalContextReturns a default serializer for producing an XML document to the designated output stream using the default serialization format.- Specified by:
getSerializerin interfaceInternalContext- Parameters:
output- The output stream- Returns:
- A suitable serializer
- Throws:
IOException- if instantiation of serializer fails- See Also:
-
getXMLClassDescriptorResolver
Description copied from interface:InternalContextTo get the XMLClassdescriptorResolver instance hold in the context.- Specified by:
getXMLClassDescriptorResolverin interfaceInternalContext- Returns:
- the XMLClassdescriptorResolver instance hold in the context
- See Also:
-
getIntrospector
Description copied from interface:InternalContextTo get the Introspector assigned to this XMLContext.- Specified by:
getIntrospectorin interfaceInternalContext- Returns:
- the Introspector assigned to this XMLContext
- See Also:
-
getResolverStrategy
Description copied from interface:InternalContextTo get the XMLClassDescriptor resolver strategy to be used when resolving classes into class descriptors.- Specified by:
getResolverStrategyin interfaceInternalContext- Returns:
- the ResolverStrategy to use
- See Also:
-
setResolverStrategy
Description copied from interface:InternalContextTo set the XMLClassDescriptor resolver strategy to be used.- Specified by:
setResolverStrategyin interfaceInternalContext- Parameters:
resolverStrategy- the ResolverStrategy to use- See Also:
-
setMappingLoader
Description copied from interface:InternalContextTo set theMappingLoaderto be used in this Castor session.- Specified by:
setMappingLoaderin interfaceInternalContext- Parameters:
mappingLoader- theMappingLoaderto use- See Also:
-
getMappingLoader
Description copied from interface:InternalContextTo get theMappingLoaderspecified to be used in this Castor session.- Specified by:
getMappingLoaderin interfaceInternalContext- Returns:
- the
MappingLoaderto use - See Also:
-
setJavaNaming
Description copied from interface:InternalContextTo set theJavaNaming?property.- Specified by:
setJavaNamingin interfaceInternalContext- Parameters:
javaNaming- theJavaNamingto use- See Also:
-
setJavaNaming
-
setXMLNaming
Description copied from interface:InternalContextTo set theXMLNamingproperty.- Specified by:
setXMLNamingin interfaceInternalContext- Parameters:
xmlNaming- theXMLNamingto 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:InternalContextTo set any boolean property.- Specified by:
setPropertyin interfaceInternalContext- Parameters:
propertyName- name of the property to setvalue- boolean value to set- See Also:
-
getBooleanProperty
Description copied from interface:InternalContextProviding access to Boolean properties of the configuration.- Specified by:
getBooleanPropertyin 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:InternalContextProviding access to String properties of the configuration.- Specified by:
getStringPropertyin 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:InternalContextTo set the class loader to be used in all further marshalling, unmarshalling and other actions.- Specified by:
setClassLoaderin interfaceInternalContext- Parameters:
classLoader- the ClassLoader instance to use- See Also:
-
setXMLClassDescriptorResolver
Description copied from interface:InternalContextTo set theXMLClassDescriptorResolverto 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:
setXMLClassDescriptorResolverin interfaceInternalContext- Parameters:
xmlClassDescriptorResolver- theXMLClassDescriptorResolverto use- See Also:
-
setIntrospector
Description copied from interface:InternalContextTo specify whichIntrospector?is to be used.- Specified by:
setIntrospectorin interfaceInternalContext- Parameters:
introspector-Introspectorto be used- See Also:
-
getClassLoader
Description copied from interface:InternalContextTo get the ClassLoader to use for loading resources.- Specified by:
getClassLoaderin interfaceInternalContext- Returns:
- the ClassLoader to use
- See Also:
-
getLenientIdValidation
public boolean getLenientIdValidation()Description copied from interface:InternalContextGet lenient id validation flag.- Specified by:
getLenientIdValidationin interfaceInternalContext- Returns:
- lenient id validation flag
- See Also:
-
getLenientSequenceOrder
public boolean getLenientSequenceOrder()Description copied from interface:InternalContextGet lenient sequence order flag.- Specified by:
getLenientSequenceOrderin interfaceInternalContext- Returns:
- lenient sequence order flag
- See Also:
-
getLoadPackageMapping
Description copied from interface:InternalContextGet load package mapping flag.- Specified by:
getLoadPackageMappingin interfaceInternalContext- Returns:
- load package mapping flag
- See Also:
-
setLoadPackageMapping
Description copied from interface:InternalContextTo set the load package mapping flag.- Specified by:
setLoadPackageMappingin interfaceInternalContext- Parameters:
loadPackageMapping- the load package mapping flag- See Also:
-
getUseIntrospector
Description copied from interface:InternalContextTo get use-introspection flag.- Specified by:
getUseIntrospectorin interfaceInternalContext- Returns:
- use-introspection flag
- See Also:
-
setUseIntrospector
Description copied from interface:InternalContextTo set use-introspection flag.- Specified by:
setUseIntrospectorin interfaceInternalContext- Parameters:
useIntrospector- use-introspection flag- See Also:
-
marshallingValidation
public boolean marshallingValidation()Description copied from interface:InternalContextTo get marshalling-validation flag.- Specified by:
marshallingValidationin interfaceInternalContext- Returns:
- marshalling-validation flag
- See Also:
-
strictElements
public boolean strictElements()Description copied from interface:InternalContextTo get strict-element flag.- Specified by:
strictElementsin interfaceInternalContext- Returns:
- strict-element flag
- See Also:
-