com.bea.tuxedo.control
Class JavaFieldValidate

java.lang.Object
  extended by com.bea.tuxedo.control.JavaFieldValidate
All Implemented Interfaces:
IJavaField

public class JavaFieldValidate
extends Object
implements IJavaField

Provide access to a single field in a Java class. For the validator, we only provide access to the field name and type (we use the compiler internal types). Fields may actually represent JavaBean style getters.


Constructor Summary
JavaFieldValidate(String nm)
          Constructor.
 
Method Summary
 void addGetter(MethodDeclaration method, int level, boolean isPrefix)
          Add a getter accessor method to the field.
 void addPublicField(FieldDeclaration fld, int level)
          Add direct public access to the field.
 void addSetter(MethodDeclaration method, int level)
          Add a setter accessor method to the field.
 String getName()
          Get the name of the field.
 Object getType()
          Get the type of the field, as a Java class.
 Object getValue(Object object)
          Get the value of the field.
 void normalizeField()
          Normalize the field definition.
 void setValue(Object object, Object value)
          Set the value of the field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaFieldValidate

public JavaFieldValidate(String nm)
Constructor.

Parameters:
nm - The field name.
Method Detail

getName

public String getName()
Get the name of the field.

Specified by:
getName in interface IJavaField
Returns:
A string representing the field name. If the field is represented by a getter, this is the name stripped of the get prefix, and with the first letter of the remaining string converted to lower case.

getType

public Object getType()
Get the type of the field, as a Java class.

Specified by:
getType in interface IJavaField
Returns:
A type object representing the compiler's internal type for the field.

setValue

public void setValue(Object object,
                     Object value)
Description copied from interface: IJavaField
Set the value of the field.

Specified by:
setValue in interface IJavaField
Parameters:
object - The class object for the defining class.
value - The value to set.

getValue

public Object getValue(Object object)
Description copied from interface: IJavaField
Get the value of the field.

Specified by:
getValue in interface IJavaField
Parameters:
object - The class object for the defining class.
Returns:
The value of the field.

addSetter

public void addSetter(MethodDeclaration method,
                      int level)
Add a setter accessor method to the field.

Parameters:
method - The accessor method
level - The derivation level of the declaring class

addGetter

public void addGetter(MethodDeclaration method,
                      int level,
                      boolean isPrefix)
Add a getter accessor method to the field. If there is already a getter method for this field and the name of the method we are adding starts with "is", the new method overrides.

Parameters:
method - The accessor method
level - The derivation level of the declaring class
isPrefix - True if the method's name starts with "is"

addPublicField

public void addPublicField(FieldDeclaration fld,
                           int level)
Add direct public access to the field. If there is already a publicly accessible field with this name, override if the new field is from a more derived class.

Parameters:
method - The Java Field class
level - The derivation level of the declaring class

normalizeField

public void normalizeField()
                    throws IntrospectionException
Normalize the field definition. If a field is both publicly accessible and has a setter or getter, then the following rules apply: If the setter and getter are both from the same derived class and this class is greater than or equal to the derivation level of the public field, the setter and getter take precedence. If the setter and getter are defined in different classes or they are defined in a class that is less derived than the class defining the public field, the public field takes precedence. Finally, if the field has both a setter and getter, make sure they represent the same type.

Throws:
IntrospectionException