Package org.castor.xml
Interface InternalContext
-
- All Known Implementing Classes:
AbstractInternalContext,BackwardCompatibilityContext
public interface InternalContextThe 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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddClass(java.lang.Class clazz)Loads the class descriptor for the class instance specified.voidaddClasses(java.lang.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(java.lang.String packageName)Loads class descriptors from the package specified.voidaddPackages(java.lang.String[] packageNames)Loads class descriptors from the packages specified.java.lang.BooleangetBooleanProperty(java.lang.String propertyName)Providing access to Boolean properties of the configuration.java.lang.ClassLoadergetClassLoader()To get the ClassLoader to use for loading resources.IntrospectorgetIntrospector()To get the Introspector assigned to this XMLContext.JavaNaminggetJavaNaming()TheJavaNaminginstance to be used.booleangetLenientIdValidation()Get lenient id validation flag.booleangetLenientSequenceOrder()Get lenient sequence order flag.java.lang.BooleangetLoadPackageMapping()Get load package mapping flag.MappingLoadergetMappingLoader()To get theMappingLoaderspecified to be used in this Castor session.OutputFormatgetOutputFormat()Returns the default OutputFormat for use with a Serializer.org.xml.sax.ParsergetParser()Return an XML document parser implementing the feature list specified in the configuration file.org.xml.sax.ParsergetParser(java.lang.String features)Returns an XML document parser implementing the requested set of features.NodeTypegetPrimitiveNodeType()Returns the NodeType to use for Java primitives.java.lang.ObjectgetProperty(java.lang.String propertyName)To get the value of a specific property.RegExpEvaluatorgetRegExpEvaluator()Returns a new instance of the specified Regular Expression Evaluator, or null if no validator was specified.ResolverStrategygetResolverStrategy()To get the XMLClassDescriptor resolver strategy to be used when resolving classes into class descriptors.SerializergetSerializer()Returns a default serializer for producing an XML document.org.xml.sax.DocumentHandlergetSerializer(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.DocumentHandlergetSerializer(java.io.Writer output)Returns a default serializer for producing an XML document to the designated output stream using the default serialization format.java.lang.StringgetStringProperty(java.lang.String propertyName)Providing access to String properties of the configuration.java.lang.BooleangetUseIntrospector()To get use-introspection flag.XMLClassDescriptorResolvergetXMLClassDescriptorResolver()To get the XMLClassdescriptorResolver instance hold in the context.XMLNaminggetXMLNaming()Returns the naming conventions to use for the XML framework.XMLNaminggetXMLNaming(java.lang.ClassLoader classLoader)Returns the naming conventions to use for the XML framework.org.xml.sax.XMLReadergetXMLReader()Returns an XML document parser implementing the requested set of features.org.xml.sax.XMLReadergetXMLReader(java.lang.String features)Returns an XML document parser implementing the requested set of features.booleanmarshallingValidation()To get marshalling-validation flag.voidsetClassLoader(java.lang.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(JavaNaming javaNaming)To set theJavaNaming?property.voidsetLoadPackageMapping(java.lang.Boolean loadPackageMapping)To set the load package mapping flag.voidsetMappingLoader(MappingLoader mappingLoader)To set theMappingLoaderto be used in this Castor session.voidsetProperty(java.lang.String propertyName, boolean value)To set any boolean property.voidsetProperty(java.lang.String propertyName, java.lang.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(java.lang.Boolean useIntrospector)To set use-introspection flag.voidsetXMLClassDescriptorResolver(XMLClassDescriptorResolver xmlClassDescriptorResolver)To set theXMLClassDescriptorResolverto be used.voidsetXMLNaming(XMLNaming xmlNaming)To set theXMLNamingproperty.booleanstrictElements()To get strict-element flag.
-
-
-
Method Detail
-
addMapping
void addMapping(Mapping mapping) throws MappingException
Instructs Castor to load class descriptors from the mapping given.- Parameters:
mapping- Castor XML mapping (file), from which the required class descriptors will be derived.- Throws:
MappingException- If theMappingcannot be loaded and analyzed successfully.
-
addClass
void addClass(java.lang.Class clazz) throws ResolverExceptionLoads 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).- Parameters:
clazz- the class for which the associated descriptor should be loaded.- Throws:
ResolverException- in case that resolving the Class fails fatally
-
addClasses
void addClasses(java.lang.Class[] clazzes) throws ResolverExceptionLoads 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).- Parameters:
clazzes- the classes for which the associated descriptor should be loaded.- Throws:
ResolverException- in case that resolving the Class fails fatally
-
addPackage
void addPackage(java.lang.String packageName) throws ResolverExceptionLoads 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).
- Parameters:
packageName- The package name for the (descriptor) classes- Throws:
ResolverException- If there's a problem loading class descriptors for the given package.
-
addPackages
void addPackages(java.lang.String[] packageNames) throws ResolverExceptionLoads 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).
- Parameters:
packageNames- The package names for the (descriptor) classes- Throws:
ResolverException- If there's a problem loading class descriptors for the given package.
-
setResolver
void setResolver(XMLClassDescriptorResolver xmlClassDescriptorResolver)
Sets an application-specificXMLClassDescriptorResolverinstance.- Parameters:
xmlClassDescriptorResolver- the resolver to use
-
setProperty
void setProperty(java.lang.String propertyName, java.lang.Object value)To set properties for marshalling and unmarshalling behavior.- Parameters:
propertyName- name of the property to setvalue- the value to set to
-
getProperty
java.lang.Object getProperty(java.lang.String propertyName)
To get the value of a specific property.- Parameters:
propertyName- name of the Property- Returns:
- the value (Object) of the property
-
getXMLNaming
XMLNaming getXMLNaming()
Returns the naming conventions to use for the XML framework.- Returns:
- the naming conventions to use for the XML framework
-
getXMLNaming
XMLNaming getXMLNaming(java.lang.ClassLoader classLoader)
Returns the naming conventions to use for the XML framework.- Parameters:
classLoader- the class loader to be used when instantiating a new naming instance- Returns:
- the naming conventions to use for the XML framework
-
getJavaNaming
JavaNaming getJavaNaming()
TheJavaNaminginstance to be used.- Returns:
JavaNaminginstance to be used.
-
getParser
org.xml.sax.Parser getParser()
Return an XML document parser implementing the feature list specified in the configuration file.- Returns:
- A suitable XML parser
-
getParser
org.xml.sax.Parser getParser(java.lang.String features)
Returns an XML document parser implementing the requested set of features. The feature list is a comma separated list of features that parser may or may not support. No errors are generated for unsupported features. If the feature list is not null, it overrides the default feature list specified in the configuration file, including validation and Namespaces.- Parameters:
features- The requested feature list, null for the defaults- Returns:
- A suitable XML parser
-
getXMLReader
org.xml.sax.XMLReader getXMLReader()
Returns an XML document parser implementing the requested set of features. The feature list is a comma separated list of features that parser may or may not support. No errors are generated for unsupported features. If the feature list is not null, it overrides the default feature list specified in the configuration file, including validation and Namespaces.- Returns:
- A suitable XML parser
-
getXMLReader
org.xml.sax.XMLReader getXMLReader(java.lang.String features)
Returns an XML document parser implementing the requested set of features. The feature list is a comma separated list of features that parser may or may not support. No errors are generated for unsupported features. If the feature list is not null, it overrides the default feature list specified in the configuration file, including validation and Namespaces.- Parameters:
features- the name of feature to set- Returns:
- A suitable XML parser
-
getPrimitiveNodeType
NodeType getPrimitiveNodeType()
Returns the NodeType to use for Java primitives. A null value will be returned if no NodeType was specified, indicating the default NodeType should be used.- Returns:
- the NodeType assigned to Java primitives, or null if no NodeType was specified.
-
getRegExpEvaluator
RegExpEvaluator getRegExpEvaluator()
Returns a new instance of the specified Regular Expression Evaluator, or null if no validator was specified.- Returns:
- the regular expression evaluator,
-
getSerializer
Serializer getSerializer()
Returns a default serializer for producing an XML document. The caller can specify an alternative output format, may reuse this serializer across several streams, and may serialize both DOM and SAX events. If such control is not required, it is recommended to call one of the other two methods.- Returns:
- A suitable serializer
-
getOutputFormat
OutputFormat getOutputFormat()
Returns the default OutputFormat for use with a Serializer.- Returns:
- the default OutputFormat
-
getSerializer
org.xml.sax.DocumentHandler getSerializer(java.io.OutputStream output) throws java.io.IOExceptionReturns a default serializer for producing an XML document to the designated output stream using the default serialization format.- Parameters:
output- The output stream- Returns:
- A suitable serializer
- Throws:
java.io.IOException- if instantiation of the serializer fails
-
getSerializer
org.xml.sax.DocumentHandler getSerializer(java.io.Writer output) throws java.io.IOExceptionReturns a default serializer for producing an XML document to the designated output stream using the default serialization format.- Parameters:
output- The output stream- Returns:
- A suitable serializer
- Throws:
java.io.IOException- if instantiation of serializer fails
-
getXMLClassDescriptorResolver
XMLClassDescriptorResolver getXMLClassDescriptorResolver()
To get the XMLClassdescriptorResolver instance hold in the context.- Returns:
- the XMLClassdescriptorResolver instance hold in the context
-
getIntrospector
Introspector getIntrospector()
To get the Introspector assigned to this XMLContext.- Returns:
- the Introspector assigned to this XMLContext
-
getResolverStrategy
ResolverStrategy getResolverStrategy()
To get the XMLClassDescriptor resolver strategy to be used when resolving classes into class descriptors.- Returns:
- the ResolverStrategy to use
-
setResolverStrategy
void setResolverStrategy(ResolverStrategy resolverStrategy)
To set the XMLClassDescriptor resolver strategy to be used.- Parameters:
resolverStrategy- the ResolverStrategy to use
-
setMappingLoader
void setMappingLoader(MappingLoader mappingLoader)
To set theMappingLoaderto be used in this Castor session.- Parameters:
mappingLoader- theMappingLoaderto use
-
getMappingLoader
MappingLoader getMappingLoader()
To get theMappingLoaderspecified to be used in this Castor session.- Returns:
- the
MappingLoaderto use
-
setJavaNaming
void setJavaNaming(JavaNaming javaNaming)
To set theJavaNaming?property.- Parameters:
javaNaming- theJavaNamingto use
-
setXMLNaming
void setXMLNaming(XMLNaming xmlNaming)
To set theXMLNamingproperty.- Parameters:
xmlNaming- theXMLNamingto use
-
setProperty
void setProperty(java.lang.String propertyName, boolean value)To set any boolean property.- Parameters:
propertyName- name of the property to setvalue- boolean value to set
-
getBooleanProperty
java.lang.Boolean getBooleanProperty(java.lang.String propertyName)
Providing access to Boolean properties of the configuration.- Parameters:
propertyName- name of the property- Returns:
- null if property is not set or whichever value is set
-
getStringProperty
java.lang.String getStringProperty(java.lang.String propertyName)
Providing access to String properties of the configuration.- Parameters:
propertyName- name of the property- Returns:
- null if the property is not set or whichever value is set
-
setClassLoader
void setClassLoader(java.lang.ClassLoader classLoader)
To set the class loader to be used in all further marshalling, unmarshalling and other actions.- Parameters:
classLoader- the ClassLoader instance to use
-
setXMLClassDescriptorResolver
void setXMLClassDescriptorResolver(XMLClassDescriptorResolver xmlClassDescriptorResolver)
To 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?- Parameters:
xmlClassDescriptorResolver- theXMLClassDescriptorResolverto use
-
setIntrospector
void setIntrospector(Introspector introspector)
To specify whichIntrospector?is to be used.- Parameters:
introspector-Introspectorto be used
-
getClassLoader
java.lang.ClassLoader getClassLoader()
To get the ClassLoader to use for loading resources.- Returns:
- the ClassLoader to use
-
getLenientIdValidation
boolean getLenientIdValidation()
Get lenient id validation flag.- Returns:
- lenient id validation flag
-
getLenientSequenceOrder
boolean getLenientSequenceOrder()
Get lenient sequence order flag.- Returns:
- lenient sequence order flag
-
getLoadPackageMapping
java.lang.Boolean getLoadPackageMapping()
Get load package mapping flag.- Returns:
- load package mapping flag
-
setLoadPackageMapping
void setLoadPackageMapping(java.lang.Boolean loadPackageMapping)
To set the load package mapping flag.- Parameters:
loadPackageMapping- the load package mapping flag
-
getUseIntrospector
java.lang.Boolean getUseIntrospector()
To get use-introspection flag.- Returns:
- use-introspection flag
-
setUseIntrospector
void setUseIntrospector(java.lang.Boolean useIntrospector)
To set use-introspection flag.- Parameters:
useIntrospector- use-introspection flag
-
marshallingValidation
boolean marshallingValidation()
To get marshalling-validation flag.- Returns:
- marshalling-validation flag
-
strictElements
boolean strictElements()
To get strict-element flag.- Returns:
- strict-element flag
-
-