org.exolab.castor.builder
Class FieldInfo

java.lang.Object
  extended by org.exolab.castor.builder.XMLInfo
      extended by org.exolab.castor.builder.FieldInfo
Direct Known Subclasses:
CollectionInfo, IdentityInfo

public class FieldInfo
extends XMLInfo

A class for representing field members of a Class. FieldInfo objects hold all the information required about a member in order to be able to produce marshal/unmarshal and validation code.

Version:
$Revision: 1.11 $ $Date: 2005/03/05 13:41:42 $
Author:
Keith Visco

Field Summary
static int READ_METHOD
          The Read / Getter method flag
static int READ_WRITE_METHODS
          The Read and Write methods flags
static int WRITE_METHOD
          The Write / Setter method flag
 
Fields inherited from class org.exolab.castor.builder.XMLInfo
ATTRIBUTE_TYPE, ELEMENT_TYPE, TEXT_TYPE
 
Constructor Summary
FieldInfo(XSType type, java.lang.String name)
          Creates a new FieldInfo with the given XML Schema type and the given member name
 
Method Summary
 void createAccessMethods(JClass jClass)
          Creates the access methods for field associated with this FieldInfo.
 void createGetterComment(JDocComment jDocComment)
          Creates the Javadoc comments for the getter method associated with this FieldInfo.
 void createGetterMethod(JClass jClass)
          Creates the getter methods for this FieldInfo
 void createHasAndDeleteMethods(JClass jClass)
          Creates the "has" and "delete" methods for this field associated with this FieldInfo.
 void createJavaField(JClass jClass)
          Creates the JMembers for this FieldInfo, sometimes a "field" requires more than one java field for this FieldInfo
 void createSetterComment(JDocComment jDocComment)
          Creates the Javadoc comments for the setter method associated with this FieldInfo.
 void createSetterMethod(JClass jClass)
          Creates the setter (mutator) method(s) for this FieldInfo
 void generateInitializerCode(JSourceCode jsc)
          Creates code for initialization of this Member
 java.lang.String getComment()
          Returns the comment associated with this Member
 ClassInfo getDeclaringClassInfo()
          Returns the ClassInfo to which this Member was declared, for inheritance reasons
 java.lang.String getDefaultValue()
          Returns the default value for this FieldInfo
 java.lang.String getDeleteMethodName()
          Returns the name of the delete method for this FieldInfo.
 java.lang.String getFixedValue()
          Returns the fixed production for this FieldInfo, or null if no fixed value has been specified.
 java.lang.String getHasMethodName()
          Returns the name of the has method for this FieldInfo
 int getMethods()
          Returns the methods flag that indicates which methods will be created
 java.lang.String getName()
          Returns the name of this FieldInfo
 java.lang.String getReadMethodName()
          Returns the name of the read method for this FieldInfo
 java.lang.String getValidator()
          Returns the fully qualified name of the Validator to use.
 java.lang.String getWriteMethodName()
          Returns the name of the write method for this FieldInfo
 java.lang.String getXMLFieldHandler()
          Returns the fully qualified name of the XMLFieldHandler to use.
 boolean isBound()
          Returns true if this FieldInfo represents a bound property
 boolean isContainer()
          Returns true if this FieldInfo describes a container class.
 boolean isHasAndDeleteMethods()
          Returns true if the "has" and "delete" methods are needed for the field associated with this FieldInfo.
 boolean isNillable()
          Returns true if this field represents a nillable field.
 boolean isTransient()
          Returns true if this FieldInfo is a transient member.
protected  java.lang.String methodSuffix()
          Returns the method suffix for creating method names.
 void setBound(boolean bound)
          Sets whether or not this FieldInfo represents a bound property
 void setComment(java.lang.String comment)
          Sets the comment for this Member
 void setContainer(boolean isContainer)
          Sets whether or not this FieldInfo describes a container field.
 void setDeclaringClassInfo(ClassInfo declaringClassInfo)
           
 void setDefaultValue(java.lang.String defaultValue)
          Sets the default value for this FieldInfo
 void setFinal(boolean isFinal)
          Sets the "final" status of this FieldInfo.
 void setFixedValue(java.lang.String fixedValue)
          Sets the fixed value in which instances of this field type must lexically match
 void setMethods(int methods)
          Sets which methods to create READ_METHOD, WRITE_METHOD, READ_WRITE_METHODS
 void setNillable(boolean nillable)
          Sets whether or not this field can be nillable.
 void setReference(java.lang.String fieldName)
          Sets the name of the field within the same class that is a reference to this field.
 void setStatic(boolean isStatic)
          Sets the "static" status of this FieldInfo.
 void setTransient(boolean isTransient)
          Sets the transient status of this FieldInfo.
 void setValidator(java.lang.String validator)
          Sets the name of the Validator to use.
 void setXMLFieldHandler(java.lang.String handler)
          Sets the name of the XMLfieldHandler to use.
 
Methods inherited from class org.exolab.castor.builder.XMLInfo
getNamespacePrefix, getNamespaceURI, getNodeName, getNodeType, getNodeTypeName, getSchemaType, isMultivalued, isRequired, setMultivalued, setNamespacePrefix, setNamespaceURI, setNodeName, setNodeType, setRequired, setSchemaType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READ_METHOD

public static final int READ_METHOD
The Read / Getter method flag

See Also:
Constant Field Values

WRITE_METHOD

public static final int WRITE_METHOD
The Write / Setter method flag

See Also:
Constant Field Values

READ_WRITE_METHODS

public static final int READ_WRITE_METHODS
The Read and Write methods flags

See Also:
Constant Field Values
Constructor Detail

FieldInfo

public FieldInfo(XSType type,
                 java.lang.String name)
Creates a new FieldInfo with the given XML Schema type and the given member name

Parameters:
type - the XML Schema type of this member
name - the name of the member
Method Detail

createJavaField

public void createJavaField(JClass jClass)
Creates the JMembers for this FieldInfo, sometimes a "field" requires more than one java field for this FieldInfo


createAccessMethods

public void createAccessMethods(JClass jClass)
Creates the access methods for field associated with this FieldInfo. The access methods include getters, setters, and "has" and "delete" methods if necessary.

Parameters:
jClass - the JClass to add the methods to
See Also:
createGetterMethod(org.exolab.javasource.JClass), createSetterMethod(org.exolab.javasource.JClass), createHasAndDeleteMethods(org.exolab.javasource.JClass)

createGetterComment

public void createGetterComment(JDocComment jDocComment)
Creates the Javadoc comments for the getter method associated with this FieldInfo.

Parameters:
jDocComment - the JDocComment to add the Javadoc comments to.

createGetterMethod

public void createGetterMethod(JClass jClass)
Creates the getter methods for this FieldInfo

Parameters:
jClass - the JClass to add the methods to

createHasAndDeleteMethods

public void createHasAndDeleteMethods(JClass jClass)
Creates the "has" and "delete" methods for this field associated with this FieldInfo. These methods are typically only needed for primitive types which cannot be assigned a null value.

Parameters:
jClass - the JClass to add the methods to

createSetterComment

public void createSetterComment(JDocComment jDocComment)
Creates the Javadoc comments for the setter method associated with this FieldInfo.

Parameters:
jDocComment - the JDocComment to add the Javadoc comments to.

createSetterMethod

public void createSetterMethod(JClass jClass)
Creates the setter (mutator) method(s) for this FieldInfo

Parameters:
jClass - the JClass to add the methods to

getDefaultValue

public java.lang.String getDefaultValue()
Returns the default value for this FieldInfo

Returns:
the default value for this FieldInfo, or null if no default value was set;

getFixedValue

public java.lang.String getFixedValue()
Returns the fixed production for this FieldInfo, or null if no fixed value has been specified.

Returns:
the fixed value for this FieldInfo
NOTE: Fixed values are NOT the same as default values

getDeleteMethodName

public java.lang.String getDeleteMethodName()
Returns the name of the delete method for this FieldInfo.

Returns:
the name of the delete method for this FieldInfo

getHasMethodName

public java.lang.String getHasMethodName()
Returns the name of the has method for this FieldInfo

Returns:
the name of the has method for this FieldInfo

getReadMethodName

public java.lang.String getReadMethodName()
Returns the name of the read method for this FieldInfo

Returns:
the name of the read method for this FieldInfo

getValidator

public java.lang.String getValidator()
Returns the fully qualified name of the Validator to use.

Returns:
the fully qualified name of the Validator to use.

getWriteMethodName

public java.lang.String getWriteMethodName()
Returns the name of the write method for this FieldInfo

Returns:
the name of the write method for this FieldInfo

getXMLFieldHandler

public java.lang.String getXMLFieldHandler()
Returns the fully qualified name of the XMLFieldHandler to use.

Returns:
the fully qualified name of the XMLFieldHandler to use.

generateInitializerCode

public void generateInitializerCode(JSourceCode jsc)
Creates code for initialization of this Member

Parameters:
jsc - the JSourceCode in which to add the source to

getComment

public java.lang.String getComment()
Returns the comment associated with this Member

Returns:
the comment associated with this Member, or null if one has not been set.

getMethods

public int getMethods()
Returns the methods flag that indicates which methods will be created

Returns:
the methods flag

getName

public java.lang.String getName()
Returns the name of this FieldInfo

Returns:
the name of this FieldInfo

isBound

public boolean isBound()
Returns true if this FieldInfo represents a bound property

Returns:
true if this FieldInfo represents a bound property

isContainer

public boolean isContainer()
Returns true if this FieldInfo describes a container class. A container class is a class which should not be marshalled as XML, but whose members should be.

Returns:
true if this ClassInfo describes a container class.

isHasAndDeleteMethods

public boolean isHasAndDeleteMethods()
Returns true if the "has" and "delete" methods are needed for the field associated with this FieldInfo.

Returns:
true if the has and delete methods are needed.

isNillable

public boolean isNillable()
Returns true if this field represents a nillable field. A nillable field is a field that can have null content (see XML Schema 1.0 definition of nillable).

Returns:
true if nillable, otherwise false.
See Also:
setNillable(boolean)

isTransient

public boolean isTransient()
Returns true if this FieldInfo is a transient member. Transient members are members which should be ignored by the Marshalling framework

Returns:
true if this FieldInfo is transient

setComment

public void setComment(java.lang.String comment)
Sets the comment for this Member

Parameters:
comment - the comment or description for this Member

getDeclaringClassInfo

public ClassInfo getDeclaringClassInfo()
Returns the ClassInfo to which this Member was declared, for inheritance reasons


setBound

public void setBound(boolean bound)
Sets whether or not this FieldInfo represents a bound property

Parameters:
bound - the flag when true indicates that this FieldInfo represents a bound property

setContainer

public void setContainer(boolean isContainer)
Sets whether or not this FieldInfo describes a container field. A container field is a field which should not be marshalled directly as XML, but whose members should be. By default this is false.

Parameters:
isContainer - the boolean value when true indicates this class should be a container class.

setDeclaringClassInfo

public void setDeclaringClassInfo(ClassInfo declaringClassInfo)

setDefaultValue

public void setDefaultValue(java.lang.String defaultValue)
Sets the default value for this FieldInfo

Parameters:
defaultValue - the default value

setFinal

public void setFinal(boolean isFinal)
Sets the "final" status of this FieldInfo. Final members are also transient.

Parameters:
isFinal - the boolean indicating the final status, if true this FieldInfo will be treated as final.

setFixedValue

public void setFixedValue(java.lang.String fixedValue)
Sets the fixed value in which instances of this field type must lexically match

Parameters:
fixedValue - the fixed production for this FieldInfo
NOTE: This is not the same as default value!

setMethods

public void setMethods(int methods)
Sets which methods to create READ_METHOD, WRITE_METHOD, READ_WRITE_METHODS

Parameters:
methods -

setNillable

public void setNillable(boolean nillable)
Sets whether or not this field can be nillable.

Parameters:
nillable - a boolean that when true means the field may be nil.
See Also:
isNillable()

setReference

public void setReference(java.lang.String fieldName)
Sets the name of the field within the same class that is a reference to this field.

Parameters:
fieldName -

setStatic

public void setStatic(boolean isStatic)
Sets the "static" status of this FieldInfo. Static members are also transient.

Parameters:
isStatic - the boolean indicating the static status, if true this FieldInfo will be treated as static

setTransient

public void setTransient(boolean isTransient)
Sets the transient status of this FieldInfo.

Parameters:
isTransient - the boolean indicating the transient status, if true this FieldInfo will be treated as transient

setValidator

public void setValidator(java.lang.String validator)
Sets the name of the Validator to use.

Parameters:
validator - the fully qualified name of the validator to use.

setXMLFieldHandler

public void setXMLFieldHandler(java.lang.String handler)
Sets the name of the XMLfieldHandler to use.

Parameters:
handler - the fully qualified name of the handler to use.

methodSuffix

protected java.lang.String methodSuffix()
Returns the method suffix for creating method names.



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