org.exolab.castor.xml.util
Class XMLFieldDescriptorImpl

java.lang.Object
  extended byorg.exolab.castor.xml.util.XMLFieldDescriptorImpl
All Implemented Interfaces:
FieldDescriptor, XMLFieldDescriptor

public class XMLFieldDescriptorImpl
extends java.lang.Object
implements XMLFieldDescriptor

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

Version:
$Revision: 1.22 $ $Date: 2001/08/15 16:11:34 $
Author:
Keith Visco

Field Summary
 boolean _isReference
          True if the field is a reference to another Object in the hierarchy.
 boolean _required
          indicates a required field when true
 
Constructor Summary
XMLFieldDescriptorImpl(java.lang.Class fieldType, java.lang.String fieldName, java.lang.String xmlName, NodeType nodeType)
           
XMLFieldDescriptorImpl(FieldDescriptor fieldDesc, java.lang.String xmlName, NodeType nodeType)
          Construct a new field descriptor for the specified field.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Returns true if two XMLFieldDescriptors should be treated as equal.
 ClassDescriptor getClassDescriptor()
          Returns the class descriptor related to the field type.
 CollectionHandler getCollectionHandler()
          Return the collection handler of this field type.
 ClassDescriptor getContainingClassDescriptor()
           
 java.lang.String getFieldName()
          Returns the name of the field.
 java.lang.Class getFieldType()
          Returns the Java type of the field.
 FieldHandler getHandler()
          Returns the handler of the field.
 java.lang.String getNameSpacePrefix()
          Return the "suggested" namespace prefix to use when marshalling as XML.
 java.lang.String getNameSpaceURI()
          Returns the namespace URI to be used when marshalling and unmarshalling as XML.
 NodeType getNodeType()
          Returns the NodeType of the Field being described.
 java.lang.String getQNamePrefix()
          Returns the prefix used in case the value of the field described by this descriptor is of type QName.
 java.lang.String getSchemaType()
          Returns the XML Schema type of the value of the field described by this descriptor.
 FieldValidator getValidator()
          Returns a specific validator for the field described by this descriptor.
 java.lang.String getXMLName()
          Returns the XML Name for the field being described.
protected  boolean hasNonDefaultMatching()
          Returns true if a call to #setMatches has been made with a non-null, or non-zero-length value.
 boolean isContainer()
          Returns true if the field described by this descriptor is a container field.
 boolean isImmutable()
          Returns true if the field type is immutable.
 boolean isIncremental()
          Returns the incremental flag which when true indicates that this member may be safely added before the unmarshaller is finished unmarshalling it.
 boolean isMultivalued()
          Returns true if the Object described by this descriptor can contain more than one value
 boolean isReference()
          Returns true if the field described by this descriptor is a reference (ie.
 boolean isRequired()
          Returns true if the field described by this descriptor is a required field
 boolean isTransient()
          Returns true if the field is transient.
 boolean matches(java.lang.String xmlName)
          Returns true if this descriptor can be used to handle elements or attributes with the given XML name.
 void setClassDescriptor(XMLClassDescriptor classDescriptor)
          Sets the XMLClassDescriptor for the described field
 void setContainer(boolean b)
          Set if the field is a container field or not.
 void setContainingClassDescriptor(ClassDescriptor contClsDesc)
          Set the class which contains this field
protected  void setDescriptorResolver(MappingResolver resolver)
          Sets the DescriptorResolver for following relationships among descriptors and types.
 void setHandler(FieldHandler handler)
          Sets the FieldHandler for the field being described by this FieldDescriptor
 void setImmutable(boolean immutable)
          Sets the immutable flag which indicates that changes to this Field result in a new Object to be created, such as java.lang.String.
 void setIncremental(boolean incremental)
          Sets the incremental flag which indicates whether this member can be added before the unmarshaller is finished unmarshalling it.
 void setMatches(java.lang.String matchExpr)
          This is a space separated list of xml names that this Field descriptor matches.
 void setMultivalued(boolean multivalued)
           
 void setNameSpacePrefix(java.lang.String nsPrefix)
          Sets the namespace prefix used when marshalling as XML.
 void setNameSpaceURI(java.lang.String nsURI)
          Sets the namespace URI used when marshalling and unmarshalling as XML.
 void setNodeType(NodeType nodeType)
          Sets the XML node type for the described field
 void setQNamePrefix(java.lang.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 setRequired(boolean required)
          Sets the whether or not the described field is required
 void setSchemaType(java.lang.String schemaType)
          Sets the type of the XML Schema type of the value for the field being described.
 void setTransient(boolean isTransient)
          Sets whether or not the describled field is transient
 void setValidator(FieldValidator validator)
           
 void setXMLName(java.lang.String xmlName)
          Sets the xml name for the described field
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_isReference

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


_required

public boolean _required
indicates a required field when true

Constructor Detail

XMLFieldDescriptorImpl

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

XMLFieldDescriptorImpl

public XMLFieldDescriptorImpl(FieldDescriptor fieldDesc,
                              java.lang.String xmlName,
                              NodeType nodeType)
                       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
Throws:
MappingException - Invalid mapping information
Method Detail

equals

public boolean equals(java.lang.Object obj)
Returns true if two XMLFieldDescriptors should be treated as equal. Any XMLFieldDescriptor that handles the same field is considered equal.


setContainingClassDescriptor

public void setContainingClassDescriptor(ClassDescriptor contClsDesc)
Set the class which contains this field

Specified by:
setContainingClassDescriptor in interface FieldDescriptor

getContainingClassDescriptor

public ClassDescriptor getContainingClassDescriptor()
Specified by:
getContainingClassDescriptor in interface FieldDescriptor
Returns:
the class which contains this field

getClassDescriptor

public ClassDescriptor getClassDescriptor()
Returns the class descriptor related to the field type. If the field type is a class for which a descriptor exists, this descriptor is returned. If the field type is a class for which no mapping is provided, null is returned.

Specified by:
getClassDescriptor in interface FieldDescriptor
Returns:
The class descriptor of the field type, or null

getCollectionHandler

public CollectionHandler getCollectionHandler()
Return the collection handler of this field type. Returns null if the field is not a collection.

Returns:
The collection handler

getFieldName

public java.lang.String getFieldName()
Returns the name of the field.

Specified by:
getFieldName in interface FieldDescriptor
Returns:
Field name

getFieldType

public java.lang.Class getFieldType()
Returns the Java type of the field.

Specified by:
getFieldType in interface FieldDescriptor
Returns:
Field type

getHandler

public FieldHandler getHandler()
Returns the handler of the field. In order to persist or marshal a field descriptor will be associated with a handler.

Specified by:
getHandler in interface FieldDescriptor
Returns:
The field handler

getXMLName

public java.lang.String getXMLName()
Returns the XML Name for the field being described.

Specified by:
getXMLName in interface XMLFieldDescriptor
Returns:
the XML name.

getNameSpacePrefix

public java.lang.String getNameSpacePrefix()
Return the "suggested" namespace prefix to use when marshalling as XML.

Specified by:
getNameSpacePrefix in interface XMLFieldDescriptor
Returns:
the "suggested" namespace prefix.

getNameSpaceURI

public java.lang.String getNameSpaceURI()
Returns the namespace URI to be used when marshalling and unmarshalling as XML.

Specified by:
getNameSpaceURI in interface XMLFieldDescriptor
Returns:
the namespace URI.

getNodeType

public NodeType getNodeType()
Description copied from interface: XMLFieldDescriptor
Returns the NodeType of the Field being described. The NodeType represents the Type of Node that the Field will be marshalled into XML as.

Specified by:
getNodeType in interface XMLFieldDescriptor
Returns:
the NodeType of the Field being described.

getQNamePrefix

public java.lang.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 Marshaller but not mandatory.

Returns:
the prefix used in the QName value.

getValidator

public FieldValidator getValidator()
Returns a specific validator for the field described by this descriptor. A null value may be returned if no specific validator exists.

Specified by:
getValidator in interface XMLFieldDescriptor
Returns:
the type validator for the described field

getSchemaType

public java.lang.String getSchemaType()
Returns the XML Schema type of the value of the field described by this descriptor.

Specified by:
getSchemaType in interface XMLFieldDescriptor

isImmutable

public boolean isImmutable()
Returns true if the field type is immutable.

Specified by:
isImmutable in interface FieldDescriptor
Returns:
True if the field type is immutable

isIncremental

public boolean isIncremental()
Returns the incremental flag which when true indicates that this member may be safely added before the unmarshaller is finished unmarshalling it.

Specified by:
isIncremental in interface XMLFieldDescriptor
Returns:
true if the Object can safely be added before the unmarshaller is finished unmarshalling the Object.

isMultivalued

public boolean isMultivalued()
Returns true if the Object described by this descriptor can contain more than one value

Specified by:
isMultivalued in interface XMLFieldDescriptor
Returns:
true if the Object described by this descriptor can contain more than one value

isReference

public boolean isReference()
Returns true if the field described by this descriptor is a reference (ie. IDREF) to another object in the "Object Model" (XML tree)

Specified by:
isReference in interface XMLFieldDescriptor

isRequired

public boolean isRequired()
Returns true if the field described by this descriptor is a required field

Specified by:
isRequired in interface FieldDescriptor
Returns:
true if the field described by this descriptor is a required field

isTransient

public boolean isTransient()
Returns true if the field is transient. Transient fields are never persisted or marshalled.

Specified by:
isTransient in interface FieldDescriptor
Returns:
True if transient field

isContainer

public boolean isContainer()
Returns true if the field described by this descriptor is a container field.

Specified by:
isContainer in interface XMLFieldDescriptor

setContainer

public void setContainer(boolean b)
Set if the field is a container field or not.


matches

public boolean matches(java.lang.String xmlName)
Returns true if this descriptor can be used to handle elements or attributes with the given XML name. By default this method simply compares the given XML name with the internal XML name. This method can be overridden to provide more complex matching.

Specified by:
matches in interface XMLFieldDescriptor
Parameters:
xmlName - the XML name to compare
Returns:
true if this descriptor can be used to handle elements or attributes with the given XML name.

setClassDescriptor

public void setClassDescriptor(XMLClassDescriptor classDescriptor)
Sets the XMLClassDescriptor for the described field

Parameters:
classDescriptor - the XMLClassDescriptor for the described field.

setHandler

public void setHandler(FieldHandler handler)
Sets the FieldHandler for the field being described by this FieldDescriptor

Parameters:
handler - the FieldHandler for the field being described by this FieldDescriptor

setIncremental

public void setIncremental(boolean incremental)
Sets the incremental flag which indicates whether this member can be added before the unmarshaller is finished unmarshalling it.

Parameters:
incremental - the boolean which if true indicated that this member can safely be added before the unmarshaller is finished unmarshalling it.

setImmutable

public void setImmutable(boolean immutable)
Sets the immutable flag which indicates that changes to this Field result in a new Object to be created, such as java.lang.String. It serves to identify fields which should not be constructed...until after all the data is available.

Parameters:
immutable - the boolean which if true indicated that this described field is immutable

setMatches

public void setMatches(java.lang.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

setMultivalued

public void setMultivalued(boolean multivalued)

setSchemaType

public void setSchemaType(java.lang.String schemaType)
Sets the type of the XML Schema type of the value for the field being described.


setQNamePrefix

public void setQNamePrefix(java.lang.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.


setNameSpacePrefix

public void setNameSpacePrefix(java.lang.String nsPrefix)
Sets the namespace prefix used when marshalling as XML.

Parameters:
nsPrefix - the namespace prefix used when marshalling the "described" object

setNameSpaceURI

public void setNameSpaceURI(java.lang.String nsURI)
Sets the namespace URI used when marshalling and unmarshalling as XML.

Parameters:
nsURI - the namespace URI used when marshalling and unmarshalling the "described" Object.

setNodeType

public void setNodeType(NodeType nodeType)
Sets the XML node type for the described field

Parameters:
nodeType - the NodeType for the described field

setRequired

public void setRequired(boolean required)
Sets the whether or not the described field is required

Parameters:
required - the flag indicating whether or not the described field is required

setTransient

public void setTransient(boolean isTransient)
Sets whether or not the describled field is transient

Parameters:
isTransient - the flag indicating whether or not the described field is "transient".
See Also:
isTransient()

setValidator

public void setValidator(FieldValidator validator)

setXMLName

public void setXMLName(java.lang.String xmlName)
Sets the xml name for the described field


toString

public java.lang.String toString()

hasNonDefaultMatching

protected boolean hasNonDefaultMatching()
Returns true if a call to #setMatches has been made with a non-null, or non-zero-length value. This method is used by the XML Mapping Loader

Returns:
true if a call to #setMatches has been made with a legal value.

setDescriptorResolver

protected void setDescriptorResolver(MappingResolver resolver)
Sets the DescriptorResolver for following relationships among descriptors and types. This is used by the default matching scheme

Parameters:
resolver - the DescriptorResolver to use


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