com.bea.tuxedo.control
Class JavaFieldSerialize

java.lang.Object
  extended by com.bea.tuxedo.control.JavaFieldSerialize
All Implemented Interfaces:
IJavaField, Comparable

public class JavaFieldSerialize
extends Object
implements IJavaField, Comparable

Provide access to a single field in a Java class. Fields may be accessed directly or through a JavaBean style setter/getter. This version is used by the run-time serialize and deserialize code.


Constructor Summary
JavaFieldSerialize(String nm)
          Constructor
 
Method Summary
 void addGetter(Method method, int level, boolean isPrefix)
          Add a getter accessor method to the field.
 void addPublicField(Field fld, int level)
          Add direct public access to the field.
 void addSetter(Method method, int level)
          Add a setter accessor method to the field.
 int compareTo(Object other)
          Overrides default compareTo.
 int getLevel()
          Return the derivation level for 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

JavaFieldSerialize

public JavaFieldSerialize(String nm)
Constructor

Parameters:
nm - Name of the field converted from a setter/getter name.
Method Detail

compareTo

public int compareTo(Object other)
Overrides default compareTo. Used in sorting operations.

Specified by:
compareTo in interface Comparable
Parameters:
other - The other field object to compare against.
Returns:
An integer showing the result of the comparison of names of the two fields. Comparison uses the default string compare method.

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 setter or getter, this is the name stripped of the set, get, or is prefix, and possibly with the first letter of the remaining string converted to lower case (depending on naming conventions settings).

addSetter

public void addSetter(Method 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(Method 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(Field 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()
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.


getLevel

public int getLevel()
Return the derivation level for the field. If we have both a setter and getter and their levels are different, than use the most derived level.

Returns:
The derivation level for the field.

getType

public Object getType()
Get the type of the field, as a Java class. We don't check here that the setter and getter have the same type, since we checked in the validation code.

Specified by:
getType in interface IJavaField
Returns:
A type object.

setValue

public void setValue(Object object,
                     Object value)
              throws ControlException
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.
Throws:
ControlException

getValue

public Object getValue(Object object)
                throws ControlException
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.
Throws:
ControlException