org.exolab.castor.xml.util

Class XMLFieldDescriptorImpl

Implemented Interfaces:
FieldDescriptor, XMLFieldDescriptor
Known Direct Subclasses:
XMLContainerElementFieldDescriptor

public class XMLFieldDescriptorImpl
extends AbstractFieldDescriptor
implements XMLFieldDescriptor

XML field descriptor. Wraps FieldDescriptor and adds XML-related information, type conversion, etc.

Note: When using a GeneralizedFieldHandler the getFieldType() methods of handler and descriptor need to return the same result.

Version:
$Revision: 7398 $ $Date: 2006-04-13 06:47:36 -0600 (Thu, 13 Apr 2006) $
Authors:
Keith Visco
Ralf Joachim

Field Summary

boolean
_isReference
True if the field is a reference to another Object in the hierarchy.

Fields inherited from interface org.exolab.castor.xml.XMLFieldDescriptor

PROPERTY_XML_LANG, PROPERTY_XML_SPACE

Constructor Summary

XMLFieldDescriptorImpl(Class fieldType, String fieldName, String xmlName, NodeType nodeType)
XMLFieldDescriptorImpl(FieldDescriptor fieldDesc, String xmlName, NodeType nodeType, NodeType primitiveNodeType)
Construct a new field descriptor for the specified field.

Method Summary

boolean
equals(Object obj)
Returns true if two XMLFieldDescriptors should be treated as equal.
String
getComponentType()
int
getConstructorArgumentIndex()
String
getLocationPath()
String
getNameSpacePrefix()
String
getNameSpaceURI()
NodeType
getNodeType()
String
getProperty(String propertyName)
String
getQNamePrefix()
Returns the prefix used in case the value of the field described by this descriptor is of type QName.
String
getSchemaType()
List
getSubstitutes()
Returns the possible substitution groups for this class.
FieldValidator
getValidator()
String
getXMLName()
int
hashCode()
Returns the hashCode for this XMLFieldDescriptor
boolean
isConstructorArgument()
boolean
isContainer()
boolean
isDerivedFromXSList()
boolean
isIncremental()
boolean
isMapped()
boolean
isNillable()
boolean
isReference()
boolean
matches(String xmlName)
boolean
matches(String xmlName, String namespace)
void
setComponentType(String componentType)
Sets the type of the XML Schema type of the value for the field being described.
void
setConstructorArgumentIndex(int index)
Sets whether or not the value of the field represented by this FieldDescriptor should be set via the constructor of the containing ClassDescriptor.
void
setContainer(boolean isContainer)
Set if the field is a container field or not.
void
setDerivedFromXSList(boolean derivedFromXSList)
void
setIncremental(boolean incremental)
Sets the incremental flag which indicates whether this member can be added before the unmarshaler is finished unmarshaling it.
void
setLocationPath(String path)
Sets the location path for the field being described.
void
setMapped(boolean mapped)
Sets whether or not this field has been mapped in a Map or Hashtable.
void
setMatches(String matchExpr)
This is a space separated list of xml names that this Field descriptor matches.
void
setNameSpacePrefix(String nsPrefix)
Sets the namespace prefix used when marshaling as XML.
void
setNameSpaceURI(String nsURI)
Sets the namespace URI used when marshaling and unmarshaling as XML.
void
setNillable(boolean nillable)
Sets whether or not the described field is allowed to be nil.
void
setNodeType(NodeType nodeType)
Sets the XML node type for the described field.
void
setProperty(String propertyName, String value)
Sets the value property with the given name.
void
setQNamePrefix(String qNamePrefix)
Sets the prefix used in case the value of the field described by this descriptor is of type QName.
void
setReference(boolean isReference)
Sets the flag indicating that the field described by this descriptor is a reference to another field in the object model.
void
setSchemaType(String schemaType)
Sets the type of the XML Schema type of the value for the field being described.
void
setSubstitutes(List substitutes)
Sets the possible substitution groups for this class.
void
setUseParentsNamespace(boolean useParentsNamespace)
Sets whether or not the namespace for the parent "containing" class should be used during marshaling/unmarshaling when no specific namespace URI has been set for this field.
void
setValidator(FieldValidator validator)
void
setXMLName(String xmlName)
Sets the xml name for the described field.
String
toString()

Methods inherited from class org.exolab.castor.mapping.loader.AbstractFieldDescriptor

getClassDescriptor, getContainingClassDescriptor, getFieldName, getFieldType, getHandler, isIdentity, isImmutable, isMultivalued, isRequired, isTransient, setClassDescriptor, setContainingClassDescriptor, setFieldName, setFieldType, setHandler, setIdentity, setImmutable, setMultivalued, setRequired, setTransient

Field Details

_isReference

public boolean _isReference
True if the field is a reference to another Object in the hierarchy.

Constructor Details

XMLFieldDescriptorImpl

public XMLFieldDescriptorImpl(Class fieldType,
                              String fieldName,
                              String xmlName,
                              NodeType nodeType)

XMLFieldDescriptorImpl

public XMLFieldDescriptorImpl(FieldDescriptor fieldDesc,
                              String xmlName,
                              NodeType nodeType,
                              NodeType primitiveNodeType)
            throws MappingException
Construct a new field descriptor for the specified field. This is an XML field descriptor wrapping a field descriptor and adding XML related properties and methods.
Parameters:
fieldDesc - The field descriptor
xmlName - The XML name of the field
nodeType - The node type of this field
primitiveNodeType -
Throws:
MappingException - Invalid mapping information

Method Details

equals

public boolean equals(Object obj)
Returns true if two XMLFieldDescriptors should be treated as equal. Any XMLFieldDescriptor that handles the same field is considered equal.
Parameters:
obj - The object to compare to this
Returns:
true if two XMLFieldDescriptors should be treated as equal.

getComponentType

public String getComponentType()
Specified by:
getComponentType in interface XMLFieldDescriptor

getConstructorArgumentIndex

public int getConstructorArgumentIndex()
Specified by:
getConstructorArgumentIndex in interface XMLFieldDescriptor
See Also:
{@inheritDoc}

getLocationPath

public String getLocationPath()
Specified by:
getLocationPath in interface XMLFieldDescriptor
See Also:
{@inheritDoc}

getNameSpacePrefix

public String getNameSpacePrefix()
Specified by:
getNameSpacePrefix in interface XMLFieldDescriptor
See Also:
{@inheritDoc}

getNameSpaceURI

public String getNameSpaceURI()
Specified by:
getNameSpaceURI in interface XMLFieldDescriptor
See Also:
{@inheritDoc}

getNodeType

public NodeType getNodeType()
Specified by:
getNodeType in interface XMLFieldDescriptor
See Also:
{@inheritDoc}

getProperty

public String getProperty(String propertyName)
Specified by:
getProperty in interface XMLFieldDescriptor
See Also:
{@inheritDoc}

getQNamePrefix

public String getQNamePrefix()
Returns the prefix used in case the value of the field described by this descriptor is of type QName. This is helpful for the marshaler but not mandatory.
Returns:
the prefix used in the QName value.

getSchemaType

public String getSchemaType()
Specified by:
getSchemaType in interface XMLFieldDescriptor
See Also:
{@inheritDoc}

getSubstitutes

public List getSubstitutes()
Returns the possible substitution groups for this class.
Specified by:
getSubstitutes in interface XMLFieldDescriptor
Returns:
the possible substitution groups for this class.

getValidator

public FieldValidator getValidator()
Specified by:
getValidator in interface XMLFieldDescriptor
See Also:
{@inheritDoc}

getXMLName

public String getXMLName()
Specified by:
getXMLName in interface XMLFieldDescriptor
See Also:
{@inheritDoc}

hashCode

public int hashCode()
Returns the hashCode for this XMLFieldDescriptor
Returns:
the hashCode for this XMLFieldDescriptor

isConstructorArgument

public boolean isConstructorArgument()
Specified by:
isConstructorArgument in interface XMLFieldDescriptor
See Also:
{@inheritDoc}

isContainer

public boolean isContainer()
Specified by:
isContainer in interface XMLFieldDescriptor
See Also:
{@inheritDoc}

isDerivedFromXSList

public boolean isDerivedFromXSList()
Specified by:
isDerivedFromXSList in interface XMLFieldDescriptor

isIncremental

public boolean isIncremental()
Specified by:
isIncremental in interface XMLFieldDescriptor
See Also:
{@inheritDoc}

isMapped

public boolean isMapped()
Specified by:
isMapped in interface XMLFieldDescriptor
See Also:
{@inheritDoc}

isNillable

public boolean isNillable()
Specified by:
isNillable in interface XMLFieldDescriptor
See Also:
{@inheritDoc}

isReference

public boolean isReference()
Specified by:
isReference in interface XMLFieldDescriptor
See Also:
{@inheritDoc}

matches

public boolean matches(String xmlName)
Specified by:
matches in interface XMLFieldDescriptor
See Also:
{@inheritDoc}

matches

public boolean matches(String xmlName,
                       String namespace)
Specified by:
matches in interface XMLFieldDescriptor
See Also:
{@inheritDoc}

setComponentType

public void setComponentType(String componentType)
Sets the type of the XML Schema type of the value for the field being described.
Parameters:
componentType - The component type for <xs:list>s.

setConstructorArgumentIndex

public void setConstructorArgumentIndex(int index)
Sets whether or not the value of the field represented by this FieldDescriptor should be set via the constructor of the containing ClassDescriptor. The index value greater than 0 specifies the index within the argument array that the value of this field should be.

Note: This only applies to attribute mapped fields at this time.

Parameters:
index - the index within the argument array. A value less than zero indicates that this field should not be part of the constructor arguments.

setContainer

public void setContainer(boolean isContainer)
Set if the field is a container field or not.
Parameters:
isContainer - a boolean indicating whether or not the field is a container field.

setDerivedFromXSList

public void setDerivedFromXSList(boolean derivedFromXSList)
Specified by:
setDerivedFromXSList in interface XMLFieldDescriptor

setIncremental

public void setIncremental(boolean incremental)
Sets the incremental flag which indicates whether this member can be added before the unmarshaler is finished unmarshaling it.
Parameters:
incremental - the boolean which if true indicated that this member can safely be added before the unmarshaler is finished unmarshaling it.

setLocationPath

public void setLocationPath(String path)
Sets the location path for the field being described.

In most cases, this isn't needed. However sometimes a field may be mapped to a nested element. In which case the value of the location path should be the nested element name. If more than one level of nesting is needed each nested element name should be separated by a path separator (forward slash '/').

The location path name is "relative" to the parent Class. The name of the parent should not be included in the path.

For example, give the following two classes: class Root { Bar bar; } class Bar { String value; } And the following XML: <root> <foo> <bar> value of bar </bar> </foo> </root> Since foo has no associated class, the path for 'bar' would be: "foo"

Parameters:
path - the "relative" location path for the field.

setMapped

public void setMapped(boolean mapped)
Sets whether or not this field has been mapped in a Map or Hashtable.
Parameters:
mapped - a boolean that when true indicates this field is a Hashtable or Map.

setMatches

public void setMatches(String matchExpr)
This is a space separated list of xml names that this Field descriptor matches. A '*' is wild.
Parameters:
matchExpr - the space separated list of xml names, matched by this descriptor.

setNameSpacePrefix

public void setNameSpacePrefix(String nsPrefix)
Sets the namespace prefix used when marshaling as XML.
Parameters:
nsPrefix - The namespace prefix used when marshaling the "described" object.

setNameSpaceURI

public void setNameSpaceURI(String nsURI)
Sets the namespace URI used when marshaling and unmarshaling as XML.
Parameters:
nsURI - The namespace URI used when marshaling and unmarshaling the "described" Object.

setNillable

public void setNillable(boolean nillable)
Sets whether or not the described field is allowed to be nil. A nillable field can have empty content (text or element content), but may have attribute values, and still be considered value, even if the child elements are required.
Parameters:
nillable - a boolean indicating whether or not the described field may be nillable.

setNodeType

public void setNodeType(NodeType nodeType)
Sets the XML node type for the described field.
Parameters:
nodeType - the NodeType for the described field.

setProperty

public void setProperty(String propertyName,
                        String value)
Sets the value property with the given name.
Parameters:
propertyName - The name of the property to set the value of.
value - The value of the property.

setQNamePrefix

public void setQNamePrefix(String qNamePrefix)
Sets the prefix used in case the value of the field described by this descriptor is of type QName.
Parameters:
qNamePrefix -

setReference

public void setReference(boolean isReference)
Sets the flag indicating that the field described by this descriptor is a reference to another field in the object model.
Parameters:
isReference - true if the field is a reference to another field.

setSchemaType

public void setSchemaType(String schemaType)
Sets the type of the XML Schema type of the value for the field being described.
Parameters:
schemaType - The value type.

setSubstitutes

public void setSubstitutes(List substitutes)
Sets the possible substitution groups for this class.
Specified by:
setSubstitutes in interface XMLFieldDescriptor
Parameters:
substitutes - Possible substitution groups for this class.

setUseParentsNamespace

public void setUseParentsNamespace(boolean useParentsNamespace)
Sets whether or not the namespace for the parent "containing" class should be used during marshaling/unmarshaling when no specific namespace URI has been set for this field.

setValidator

public void setValidator(FieldValidator validator)

setXMLName

public void setXMLName(String xmlName)
Sets the xml name for the described field.
Parameters:
xmlName - the XML name for the described field.

toString

public String toString()

Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com