FileDocCategorySizeDatePackage
FieldInfo.javaAPI DocGlassfish v2 API6310Fri May 04 22:35:08 BST 2007com.sun.jdo.spi.persistence.support.sqlstore.query.util.type

FieldInfo

public class FieldInfo extends Object

Fields Summary
protected String
name
The name of the field.
protected ClassType
classType
The corresponding classType object.
protected Field
field
The reflection representation of the field.
protected com.sun.jdo.api.persistence.model.jdo.PersistenceFieldElement
pfe
JDO model representation
protected static final ResourceBundle
messages
I18N support
Constructors Summary
public FieldInfo(Field field, ClassType classType)


          
         
    
        this.name = field.getName();
        this.classType = classType;
        this.field = field;
        this.pfe = (classType.pce != null) ? classType.pce.getField(this.name) : null;
    
Methods Summary
public TypegetAssociatedClass()

return
the associated class (meaning the "other side") of the relationship; or null if this does not denote a relationship field.

        Type associatedClass = null;
        if ((pfe != null) && (pfe instanceof RelationshipElement))
        {
            String className = ((RelationshipElement)pfe).getElementClass();
            associatedClass = classType.typetab.checkType(className);
        }
        return associatedClass;
    
public java.lang.reflect.FieldgetField()

        return field;
    
public intgetFieldNumber()
Return the field number in the case of a field of a persistence capable class.

        if (pfe != null)
        {
            int index = pfe.getFieldNumber();
            if (index < 0)
                throw new JDOFatalInternalException(I18NHelper.getMessage(
                    messages, "query.util.type.fieldinfo.getfieldnumber.invalidfieldno", //NO18N
                    String.valueOf(index), name));
            return index;
        }
        else
        {
            throw new JDOFatalInternalException(I18NHelper.getMessage(
                messages, "query.util.type.fieldinfo.getfieldnumber.missingfieldelement", //NO18N
                name));
        }
    
public java.lang.StringgetName()

        return name;
    
public TypegetType()
Returns the Type representation of the type of the field.

return
field type

        if (field == null)
            return classType.typetab.errorType;
        
        Type ret = classType.typetab.checkType(field.getType());
        if (ret == null)
            ret = classType.typetab.errorType;
        return ret;
	        
    
public booleanisPersistent()
Checks whether this field is defined as persistent field.

return
true if the field is defined as persistent; false otherwise.

        if (pfe != null)
        {
            return pfe.getPersistenceType() == PersistenceFieldElement.PERSISTENT;
        }
        return false;
    
public booleanisPublic()
Checks whether this field is defined with the public modifier.

return
true if the field is defined as public; false otherwise.

        return (field != null) && Modifier.isPublic(field.getModifiers());
    
public booleanisRelationship()

return
true if the field is a relationship field

        return ((pfe != null) && (pfe instanceof RelationshipElement));
    
public booleanisStatic()
Checks whether this field is defined with the static modifier.

return
true if the field is defined as static; false otherwise.

        return (field != null) && Modifier.isStatic(field.getModifiers());