org.sourceforge.jemm.weaver.transformation.field
Class FieldClassifier

java.lang.Object
  extended by org.sourceforge.jemm.weaver.transformation.field.FieldClassifier

public class FieldClassifier
extends java.lang.Object

Determines if a field on a class is either a jemm created field or specifically using the JEMM API and hence should be ignored.

Author:
Paul Keeble

Nested Class Summary
static class FieldClassifier.Classification
          A classification of a CtField as needed by the transformation process.
 
Constructor Summary
FieldClassifier()
          Creates a new instance of a FieldClassifier.
 
Method Summary
 int arrayDimensions(javassist.CtField field)
          Returns the dimensions of an array field type.
 FieldClassifier.Classification classifySingular(javassist.CtField field)
          Classifies the passed in field into a number of different states so that the compiler can determine what to do with a particular field.
 boolean isArray(javassist.CtField field)
          Returns whether the given field is an array type.
 boolean isArrayReferenceTransformable(javassist.CtField field)
          If an array field can be converted to a JEMMArrayReference then this returns true, else false.
 boolean isEntity(javassist.CtField field)
          Returned whether the type referred to by the field is another entity (jemm object).
 boolean isJemmCollection(javassist.CtField field)
          If the field is a Jemm specific type then this returns true, else false.
 boolean isJEMMReferenceTransformable(javassist.CtField field)
          If a field can be converted to a JEMMReference then this returns true, else false
 boolean isJemmSpecialField(javassist.CtField field)
          Is a special field if the field is the shadow object or has the class type of one of the Jemm Collections.
 boolean isKnownImmutable(javassist.CtField field)
          The wrapper types for the Primitives (Integer, Long, Float etc) are covered by this definition as are the Jemm special immutable types such as JemmDate.
 boolean isPrimitive(javassist.CtField field)
          Uses the descriptors to determine if the type of the field is a primitive, even if it is an array this will return true if the type of the array is based on a primitive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FieldClassifier

public FieldClassifier()
Creates a new instance of a FieldClassifier.

Method Detail

classifySingular

public FieldClassifier.Classification classifySingular(javassist.CtField field)
                                                throws javassist.NotFoundException
Classifies the passed in field into a number of different states so that the compiler can determine what to do with a particular field.

Parameters:
field - The field to check
Returns:
A classification of the field
Throws:
javassist.NotFoundException

isEntity

public boolean isEntity(javassist.CtField field)
Returned whether the type referred to by the field is another entity (jemm object).

Parameters:
field - The target field.
Returns:
True if the field is an entity type, false otherwise.

isJemmSpecialField

public boolean isJemmSpecialField(javassist.CtField field)
                           throws javassist.NotFoundException
Is a special field if the field is the shadow object or has the class type of one of the Jemm Collections.

Parameters:
field - The field to check
Returns:
true if the field is Jemm specific, false otherwise.
Throws:
javassist.NotFoundException - ClassPool JA exception if the CtClass can't be found.

isJEMMReferenceTransformable

public boolean isJEMMReferenceTransformable(javassist.CtField field)
                                     throws javassist.NotFoundException
If a field can be converted to a JEMMReference then this returns true, else false

Parameters:
field - the field to check
Returns:
true if convertable, else false.
Throws:
javassist.NotFoundException

isArrayReferenceTransformable

public boolean isArrayReferenceTransformable(javassist.CtField field)
                                      throws javassist.NotFoundException
If an array field can be converted to a JEMMArrayReference then this returns true, else false. Arrays of NORMALOBJECT, primatives, Strings and JemmObject's should be supported.

Parameters:
field - The field to check
Returns:
true if convertable, else false
Throws:
javassist.NotFoundException

arrayDimensions

public int arrayDimensions(javassist.CtField field)
                    throws javassist.NotFoundException
Returns the dimensions of an array field type.

Parameters:
field - The target field.
Returns:
The number of array dimensions.
Throws:
javassist.NotFoundException - In an internal error occurs whilst loading the field type.

isArray

public boolean isArray(javassist.CtField field)
                throws javassist.NotFoundException
Returns whether the given field is an array type.

Parameters:
field - The target field.
Returns:
True if the target field is an array type, false otherwise.
Throws:
javassist.NotFoundException - In an internal error occurs whilst loading the field type.

isJemmCollection

public boolean isJemmCollection(javassist.CtField field)
                         throws javassist.NotFoundException
If the field is a Jemm specific type then this returns true, else false. Jemm specific types include all the Collections.

Parameters:
field - The field to check the type of
Returns:
true if the field is a jemm type, false otherwise
Throws:
javassist.NotFoundException - In an internal error occurs whilst loading the field type.

isPrimitive

public boolean isPrimitive(javassist.CtField field)
                    throws javassist.NotFoundException
Uses the descriptors to determine if the type of the field is a primitive, even if it is an array this will return true if the type of the array is based on a primitive.

Parameters:
field - The field to check
Returns:
true if a primitive, false otherwise
Throws:
javassist.NotFoundException

isKnownImmutable

public boolean isKnownImmutable(javassist.CtField field)
                         throws javassist.NotFoundException
The wrapper types for the Primitives (Integer, Long, Float etc) are covered by this definition as are the Jemm special immutable types such as JemmDate.

Parameters:
field - The field to test
Returns:
true if it is a known immutable, else false.
Throws:
javassist.NotFoundException - In an internal error occurs whilst loading the field type.


Copyright © 2009. All Rights Reserved.