gnu.jel.reflect
Class LocalField

java.lang.Object
  |
  +--gnu.jel.reflect.LocalField
Direct Known Subclasses:
Field, LocalMethod

public class LocalField
extends java.lang.Object
implements Member

Represents a field local to the class being compiled.


Field Summary
protected  int modifiers
           
 
Fields inherited from interface java.lang.reflect.Member
DECLARED, PUBLIC
 
Constructor Summary
LocalField(int modifiers, java.lang.Class type, java.lang.String name, java.lang.Object constValue)
          Constructs a new local field.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 java.lang.Object eval(java.lang.Object obj, java.lang.Object[] params)
          Evaluates the member.
 java.lang.Class getDeclaringClass()
           
 int getModifiers()
          Returns modifiers and more.
 java.lang.String getName()
           
 java.lang.Class[] getParameterTypes()
          Used to get types and number of parameters needed to evaluate this member.
 java.lang.Class getType()
          Used to get the type of this member.
 int getTypeID()
          Returns an integer identifier of this member type.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

modifiers

protected int modifiers
Constructor Detail

LocalField

public LocalField(int modifiers,
                  java.lang.Class type,
                  java.lang.String name,
                  java.lang.Object constValue)
Constructs a new local field.
Parameters:
modifiers - field modifiers, a sum of one or more of PUBLIC, PRIVATE,PROTECTED, STATIC, FINAL,VOLATILE, TRANSIENT constants defined in java.lang.reflect.Modifier
type - is a class representing the type of this field.
name - is the name of this field.
constValue - is the value of this field if it is static final, null otherwise.
Method Detail

getDeclaringClass

public java.lang.Class getDeclaringClass()

getName

public java.lang.String getName()

getModifiers

public int getModifiers()
Description copied from interface: Member
Returns modifiers and more.

This method returns modifiers of the method in the less significant half of the returned int, and the type of member in the other part. The members are encoded according to the following scheme.

 1 - field
 2 - method
 3 - constructor ()
 
Specified by:
getModifiers in interface Member
Tags copied from interface: Member
Returns:
modifiers for the method.

getType

public java.lang.Class getType()
Description copied from interface: Member
Used to get the type of this member.

For fields it is the field type, for methods it is the method return value.

Primitive types are encoded as TYPE fields of corresponding reflection objects.

Specified by:
getType in interface Member
Tags copied from interface: Member
Returns:
the type of this member.

getTypeID

public int getTypeID()
Description copied from interface: Member
Returns an integer identifier of this member type.

For performance and indexing reasons JEL encodes all Java types by integers. The encoding is defined in gnu.jel.TypesStack class. This method returns an integer encoding of this member's type.

Specified by:
getTypeID in interface Member
Tags copied from interface: Member
Returns:
the type of this member encoded as an int.

getParameterTypes

public java.lang.Class[] getParameterTypes()
Description copied from interface: Member
Used to get types and number of parameters needed to evaluate this member.

Is there are no parameters (like for fields) it returns an array of length zero.

Specified by:
getParameterTypes in interface Member
Tags copied from interface: Member
Returns:
the array of parameters of this member.

eval

public java.lang.Object eval(java.lang.Object obj,
                             java.lang.Object[] params)
                      throws java.lang.Exception
Description copied from interface: Member
Evaluates the member.

Looks up the value of the field or calls the method.

Not all members can be evaluated, for example non static final local fields can not since they exist only in compiler's memory.

Specified by:
eval in interface Member
Tags copied from interface: Member
Parameters:
obj - this pointer of corresponding object.
params - array of parameters wrapped in reflection objects.
Returns:
the result wrapped in a reflection object.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object