FileDocCategorySizeDatePackage
FieldInfo.javaAPI DocphoneME MR2 API (J2ME)4328Wed May 02 17:59:48 BST 2007components

FieldInfo

public class FieldInfo extends ClassMemberInfo

Fields Summary
private Attribute[]
fieldAttributes
public ConstantObject
value
private ConstantValueAttribute
valueAttribute
public int
instanceOffset
public int
nSlots
private static Hashtable
fieldAttributeTypes
Constructors Summary
public FieldInfo(int name, int sig, int access, ClassInfo p)

	     // ditto

    
             
	super( name, sig, access, p );
    
Methods Summary
public voidcountConstantReferences(boolean isRelocatable)

	super.countConstantReferences();
	Attribute.countConstantReferences( fieldAttributes, isRelocatable );
    
public voidexternalize(ConstantPool p)

	super.externalize( p );
	Attribute.externalizeAttributes( fieldAttributes, p );
	if ( value != null ){
	    value = valueAttribute.data;
	}
    
private voidreadAttributes(java.io.DataInput in)

    
	fieldAttributeTypes.put("ConstantValue", ConstantValueAttributeFactory.instance );
    
	fieldAttributes = Attribute.readAttributes( in, parent.constants, parent.symbols, fieldAttributeTypes, false );
    
public static components.FieldInforeadField(java.io.DataInput in, ClassInfo p)

	int acc  = in.readUnsignedShort();
	int name = in.readUnsignedShort();
	int sig =  in.readUnsignedShort();
	FieldInfo fi = new FieldInfo( name, sig, acc, p );
	fi.readAttributes(in );
	fi.resolve( p.symbols );
	return fi;
    
public voidresolve(ConstantObject[] table)

	if ( resolved ) return;
	super.resolve( table );
	/*
	 * Parse attributes.
	 * If we find a value attribute, pick it out
	 * for special handling.
	 */
	if ( fieldAttributes != null ) {
	    for ( int i = 0; i < fieldAttributes.length; i++ ){
		Attribute a = fieldAttributes[i];
		if (a.name.string.equals("ConstantValue") ) {
		    valueAttribute = (ConstantValueAttribute)a;
		    value = valueAttribute.data;
		}
	    }
	}
	switch( type.string.charAt(0) ){
	case 'D":
	case 'J":
	    nSlots = 2; access |= Const.ACC_DOUBLEWORD; break;
	case 'L":
	case '[":
	    nSlots = 1; access |= Const.ACC_REFERENCE; break;
	default:
	    nSlots = 1; break;
	}
	resolved = true;
    
public java.lang.StringtoString()

	String r = "Field: "+super.toString();
	if ( value != null ){
	    r += " Value: "+value.toString();
	}
	return r;
    
public voidwrite(java.io.DataOutput o)

	o.writeShort( access );
	if ( resolved ){
	    o.writeShort( name.index );
	    o.writeShort( type.index );
	    Attribute.writeAttributes( fieldAttributes, o, false );
	} else {
	    o.writeShort( nameIndex );
	    o.writeShort( typeIndex );
	    o.writeShort( 0 ); // no attribute!
	}