Package org.exolab.castor.xml
Class MarshalFramework
java.lang.Object
org.exolab.castor.xml.MarshalFramework
- Direct Known Subclasses:
Marshaller
,UnmarshalHandler
A core class for common code shared throughout the
Marshalling Framework
- Version:
- $Revision: 8057 $ $Date: 2005-12-13 14:58:48 -0700 (Tue, 13 Dec 2005) $
- Author:
- Keith Visco
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Used to store the information when we find a possible inheritance.(package private) class
An internal implementation of XMLClassDescriptor used by the Unmarshaller and Marshaller... -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final String
A constant to indicate a wrong name without setting null.(package private) static final String
The default prefix used for specifying the xsi:type as a classname instead of a schema name.static final String
The xml:lang attribute, without the "xml:" prefix.static final String
The xsi:nil attribute, without the "xsi:" prefix.(package private) static final XMLFieldDescriptor[]
An empty array of field descriptors.(package private) static final String
The name of the QName type.static final String
The xml:space attribute name, without the "xml:" prefix.static final String
The value of 'true'.static final String
The xsi:type attribute name, without the "xsi:" prefix.static final String
The xml:lang attribute name.static final String
The xml:space attribute name.static final String
The XSI Namespace URI.static final String
The xsi:nil attribute.static final String
The name of the no namespace schema location attribute.static final String
The name of the Schema location attribute. -
Constructor Summary
ConstructorsConstructorDescriptionMarshalFramework
(InternalContext internalContext) We need some stuff initialized here. -
Method Summary
Modifier and TypeMethodDescriptiongetCollectionHandler
(Class clazz) Returns the CollectionHandler associated with the given collection, or null if no such handler exists.To get theAbstractInternalContext
to use.To get theJavaNaming
instance to be used.(package private) static final boolean
hasFieldsAtLocation
(String location, XMLClassDescriptor classDesc) Returns true if any of the fields associated with the given XMLClassDescriptor are located at, or beneath, the given location.static boolean
isCollection
(Class clazz) Returns true if the given Class is a considered a collection by the marshalling framework.(package private) static boolean
Returns true if the given class should be treated as an enum type.(package private) static boolean
isPrimitive
(Class type) Returns true if the given class should be treated as a primitive type.static boolean
namespaceEquals
(String ns1, String ns2) Compares the given namespaces (as strings) for equality.(package private) static boolean
Returns true if the given classes are both the same primitive or primitive wrapper class.protected MarshalFramework.InheritanceMatch[]
searchInheritance
(String name, String namespace, XMLClassDescriptor classDesc) Search there is a field descriptor which can accept one of the class descriptor which match the given name and namespace.void
setInternalContext
(InternalContext internalContext) To set theAbstractInternalContext
to use.
-
Field Details
-
XSI_NAMESPACE
The XSI Namespace URI.- See Also:
-
XSI_SCHEMA_LOCATION
The name of the Schema location attribute.- See Also:
-
XSI_NO_NAMESPACE_SCHEMA_LOCATION
The name of the no namespace schema location attribute.- See Also:
-
XML_LANG_ATTR
The xml:lang attribute name.- See Also:
-
LANG_ATTR
The xml:lang attribute, without the "xml:" prefix.- See Also:
-
NIL_ATTR
The xsi:nil attribute, without the "xsi:" prefix.- See Also:
-
XSI_NIL_ATTR
The xsi:nil attribute.- See Also:
-
XML_SPACE_ATTR
The xml:space attribute name.- See Also:
-
SPACE_ATTR
The xml:space attribute name, without the "xml:" prefix.- See Also:
-
TYPE_ATTR
The xsi:type attribute name, without the "xsi:" prefix.- See Also:
-
TRUE_VALUE
The value of 'true'.- See Also:
-
INTERNAL_XML_NAME
A constant to indicate a wrong name without setting null.- See Also:
-
JAVA_PREFIX
The default prefix used for specifying the xsi:type as a classname instead of a schema name. This is a Castor specific hack.- See Also:
-
QNAME_NAME
The name of the QName type.- See Also:
-
NO_FIELD_DESCRIPTORS
An empty array of field descriptors.
-
-
Constructor Details
-
MarshalFramework
We need some stuff initialized here. MarshalFramework requires internally anInternalContext
, so either one is given orBackwardCompatibilityContext
is instantiated! Mind that instantiatingBackwardCompatibilityContext
means to (re-)read configuration files.- Parameters:
internalContext
- either anInternalContext
comes from outside orBackwardCompatibilityContext
is instantiated
-
-
Method Details
-
getJavaNaming
To get theJavaNaming
instance to be used.- Returns:
- the JavaNaming to be used
-
getInternalContext
To get theAbstractInternalContext
to use.- Returns:
- the
AbstractInternalContext
to use
-
setInternalContext
To set theAbstractInternalContext
to use.- Parameters:
internalContext
- theAbstractInternalContext
to use
-
isCollection
Returns true if the given Class is a considered a collection by the marshalling framework.- Parameters:
clazz
- the Class to check- Returns:
- true if the given Class is considered a collection. TODO: joachim: this code exists somewhere else too!!
-
getCollectionHandler
Returns the CollectionHandler associated with the given collection, or null if no such handler exists.- Parameters:
clazz
- the Class to check- Returns:
- the CollectionHandler for the associated type.
-
isPrimitive
Returns true if the given class should be treated as a primitive type. This method will return true for all Java primitive types, the set of primitive object wrappers, as well as Strings.- Parameters:
type
- the Class to check- Returns:
- true if the given class should be treated as a primitive type TODO: joachim: this code exists somewhere else too!!
-
isEnum
Returns true if the given class should be treated as an enum type. This method will return true for all Java 5 (or later) enums, and for enum-style classes.- Parameters:
type
- the Class to check- Returns:
- true if the given class should be treated as an enum
-
hasFieldsAtLocation
Returns true if any of the fields associated with the given XMLClassDescriptor are located at, or beneath, the given location.- Parameters:
location
- the location to compare againstclassDesc
- the XMLClassDescriptor in which to check the field locations- Returns:
- true if any of the fields has a location associated
-
namespaceEquals
Compares the given namespaces (as strings) for equality. null and empty values are considered equal.- Parameters:
ns1
- the namespace to compare to argument ns2ns2
- the namespace to compare to argument ns1- Returns:
- true if the namespaces are considert equal TODO: joachim put it into XMLNaming!
-
primitiveOrWrapperEquals
Returns true if the given classes are both the same primitive or primitive wrapper class. For exmaple, if class "a" is an int (Integer.TYPE) and class "b" is either an int or Integer.class then true will be returned, otherwise false.- Parameters:
a
- compare a with bb
- compare a with b- Returns:
- true if both a and b are considered equal
-
searchInheritance
protected MarshalFramework.InheritanceMatch[] searchInheritance(String name, String namespace, XMLClassDescriptor classDesc) throws MarshalException Search there is a field descriptor which can accept one of the class descriptor which match the given name and namespace.- Parameters:
name
- XML name of the fieldnamespace
- namespace of the fieldclassDesc
- the class descriptor to match againstcdResolver
- the class descriptor resolver to use- Returns:
- An array of InheritanceMatch.
- Throws:
MarshalException
- if the resolver called fails fatally
-