|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.exolab.castor.mapping.loader.FieldDescriptorImpl
org.exolab.castor.xml.util.XMLFieldDescriptorImpl
public class XMLFieldDescriptorImpl
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.
| 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()
Returns the component type of this XMLFieldDescriptor instance, if
the field described represents a collection of values. |
int |
getConstructorArgumentIndex()
Returns the index within the constructor argument array where the value of this field should be. |
String |
getLocationPath()
Returns the "relative" XML path for the field being described. |
String |
getNameSpacePrefix()
Return the "suggested" namespace prefix to use when marshaling as XML. |
String |
getNameSpaceURI()
Returns the namespace URI to be used when marshaling and unmarshaling as XML. |
NodeType |
getNodeType()
Returns the node type of the field being described. |
String |
getQNamePrefix()
Returns the prefix used in case the value of the field described by this descriptor is of type QName. |
String |
getSchemaType()
Returns the XML Schema type of the XML field being described. |
List<String> |
getSubstitutes()
Returns the possible substitution groups for this class. |
FieldValidator |
getValidator()
Returns a specific validator for the field described by this descriptor. |
String |
getXMLName()
Returns the XML Name for the field being described. |
String |
getXMLProperty(String propertyName)
Returns the value property with the given name or null if no such property exists. |
int |
hashCode()
Returns the hashCode for this XMLFieldDescriptor |
boolean |
isConstructorArgument()
Returns true if the value of the field represented by this descriptor should be set via the constructor of the containing class. |
boolean |
isContainer()
Returns true if the field described by this descriptor is a container field. |
boolean |
isDerivedFromXSList()
Indicates whether the field described by this XMLFieldDescriptorImpl is
created as a result of a |
boolean |
isIncremental()
Returns the incremental flag which when true indicates that this member may be safely added before the unmarshaler is finished unmarshaling it. |
boolean |
isMapped()
Returns true if the field described by this descriptor is Map or Hashtable. |
boolean |
isNillable()
Returns true if the field described by this descriptor may be nillable. |
boolean |
isReference()
Returns true if the field described by this descriptor is a reference (ie. |
boolean |
matches(String xmlName)
Returns true if this descriptor can be used to handle elements or attributes with the given XML name. |
boolean |
matches(String xmlName,
String namespace)
Returns true if this descriptor can be used to handle elements or attributes with the given XML name. |
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)
Sets whether the field described by this XMLFieldDescriptorImpl is
created as a result of a |
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 |
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<String> 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. |
void |
setXMLProperty(String propertyName,
String value)
Sets the value property with the given name. |
String |
toString()
|
| Methods inherited from class org.exolab.castor.mapping.loader.FieldDescriptorImpl |
|---|
addNature, getClassDescriptor, getCollection, getComparator, getContainingClassDescriptor, getCreateMethod, getFieldName, getFieldType, getGetMethod, getHandler, getProperty, getSetMethod, hasNature, isDirect, isIdentity, isImmutable, isLazy, isMultivalued, isRequired, isTransient, setClassDescriptor, setCollection, setComparator, setContainingClassDescriptor, setCreateMethod, setDirect, setFieldName, setFieldType, setGetMethod, setHandler, setIdentity, setImmutable, setLazy, setMultivalued, setProperty, setRequired, setSetMethod, setTransient |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.exolab.castor.xml.XMLFieldDescriptor |
|---|
isMultivalued |
| Methods inherited from interface org.exolab.castor.mapping.FieldDescriptor |
|---|
getClassDescriptor, getContainingClassDescriptor, getFieldName, getFieldType, getHandler, isImmutable, isRequired, isTransient, setContainingClassDescriptor |
| Methods inherited from interface org.castor.core.nature.PropertyHolder |
|---|
getProperty, setProperty |
| Methods inherited from interface org.castor.core.nature.NatureExtendable |
|---|
addNature, hasNature |
| Field Detail |
|---|
public boolean _isReference
| Constructor Detail |
|---|
public XMLFieldDescriptorImpl(Class<?> fieldType,
String fieldName,
String xmlName,
NodeType nodeType)
public XMLFieldDescriptorImpl(FieldDescriptor fieldDesc,
String xmlName,
NodeType nodeType,
NodeType primitiveNodeType)
throws MappingException
fieldDesc - The field descriptorxmlName - The XML name of the fieldnodeType - The node type of this fieldprimitiveNodeType -
MappingException - Invalid mapping information| Method Detail |
|---|
public void setConstructorArgumentIndex(int index)
Note: This only applies to attribute mapped fields at this time.
index - the index within the argument array. A value less than zero
indicates that this field should not be part of the constructor
arguments.public int getConstructorArgumentIndex()
XMLFieldDescriptorNote: This only applies to attribute mapped fields at this time.
getConstructorArgumentIndex in interface XMLFieldDescriptor{@inheritDoc}public boolean isConstructorArgument()
XMLFieldDescriptor
isConstructorArgument in interface XMLFieldDescriptor{@inheritDoc}public void setLocationPath(String path)
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"
path - the "relative" location path for the field.getLocationPath()public String getLocationPath()
XMLFieldDescriptorIn most cases, this will be null. However sometimes a field may be mapped to a nested element. In which case the value returned by this method should be the nested element name. If more than one level of nesting is needed each nested element name should be separated by by a path separator (forward slash '/').
The location path name is "relative" to the parent Class. The name of the parent must 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"
getLocationPath in interface XMLFieldDescriptor{@inheritDoc}public void setNameSpacePrefix(String nsPrefix)
nsPrefix - The namespace prefix used when marshaling the
"described" object.public String getNameSpacePrefix()
XMLFieldDescriptor
getNameSpacePrefix in interface XMLFieldDescriptor{@inheritDoc}public void setUseParentsNamespace(boolean useParentsNamespace)
public void setNameSpaceURI(String nsURI)
nsURI - The namespace URI used when marshaling and unmarshaling the
"described" Object.public String getNameSpaceURI()
XMLFieldDescriptor
getNameSpaceURI in interface XMLFieldDescriptor{@inheritDoc}public void setNodeType(NodeType nodeType)
nodeType - the NodeType for the described field.public NodeType getNodeType()
XMLFieldDescriptorNodeType
represents the type of node that the field will be marshaled into XML as.
getNodeType in interface XMLFieldDescriptorNodeType of the Field being described.{@inheritDoc}
public void setXMLProperty(String propertyName,
String value)
propertyName - The name of the property to set the value of.value - The value of the property.FieldDescriptorImpl.getProperty(java.lang.String)public String getXMLProperty(String propertyName)
XMLFieldDescriptor
getXMLProperty in interface XMLFieldDescriptorpropertyName - the name of the property whose value should be
returned.
{@inheritDoc}public void setSchemaType(String schemaType)
schemaType - The value type.public void setComponentType(String componentType)
componentType - The component type for <xs:list>s.public String getSchemaType()
XMLFieldDescriptor
getSchemaType in interface XMLFieldDescriptor{@inheritDoc}public String getComponentType()
XMLFieldDescriptor instance, if
the field described represents a collection of values.
getComponentType in interface XMLFieldDescriptorXMLFieldDescriptor.getComponentType()public void setValidator(FieldValidator validator)
public FieldValidator getValidator()
XMLFieldDescriptor
getValidator in interface XMLFieldDescriptor{@inheritDoc}public void setXMLName(String xmlName)
xmlName - the XML name for the described field.public String getXMLName()
XMLFieldDescriptor
getXMLName in interface XMLFieldDescriptor{@inheritDoc}public void setContainer(boolean isContainer)
isContainer - a boolean indicating whether or not the field is a
container field.public boolean isContainer()
XMLFieldDescriptor
isContainer in interface XMLFieldDescriptor{@inheritDoc}public void setIncremental(boolean incremental)
incremental - the boolean which if true indicated that this member
can safely be added before the unmarshaler is finished
unmarshaling it.public boolean isIncremental()
XMLFieldDescriptor
isIncremental in interface XMLFieldDescriptor{@inheritDoc}public void setMapped(boolean mapped)
mapped - a boolean that when true indicates this field is a
Hashtable or Map.public boolean isMapped()
XMLFieldDescriptorXMLFieldDescriptor.isMultivalued().
isMapped in interface XMLFieldDescriptor{@inheritDoc}public void setNillable(boolean nillable)
nillable - a boolean indicating whether or not the described field
may be nillable.public boolean isNillable()
XMLFieldDescriptor
isNillable in interface XMLFieldDescriptor{@inheritDoc}public void setReference(boolean isReference)
isReference - true if the field is a reference to another field.public boolean isReference()
XMLFieldDescriptor
isReference in interface XMLFieldDescriptor{@inheritDoc}public void setQNamePrefix(String qNamePrefix)
qNamePrefix - public String getQNamePrefix()
public void setMatches(String matchExpr)
matchExpr - the space separated list of xml names, matched by this
descriptor.public boolean matches(String xmlName)
XMLFieldDescriptor
matches in interface XMLFieldDescriptorxmlName - the XML name to compare
{@inheritDoc}
public boolean matches(String xmlName,
String namespace)
XMLFieldDescriptor
matches in interface XMLFieldDescriptorxmlName - the XML name to comparenamespace - the namespace URI
{@inheritDoc}public boolean equals(Object obj)
equals in class Objectobj - The object to compare to this
public int hashCode()
hashCode in class Objectpublic String toString()
toString in class FieldDescriptorImplpublic List<String> getSubstitutes()
getSubstitutes in interface XMLFieldDescriptorpublic void setSubstitutes(List<String> substitutes)
setSubstitutes in interface XMLFieldDescriptorsubstitutes - Possible substitution groups for this class.public void setDerivedFromXSList(boolean derivedFromXSList)
XMLFieldDescriptorImpl is
created as a result of a
setDerivedFromXSList in interface XMLFieldDescriptorderivedFromXSList - A boolean value, true or false.XMLFieldDescriptor.setDerivedFromXSList(boolean)public boolean isDerivedFromXSList()
XMLFieldDescriptorImpl is
created as a result of a
isDerivedFromXSList in interface XMLFieldDescriptorXMLFieldDescriptor.isDerivedFromXSList()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||