FileDocCategorySizeDatePackage
Attribute.javaAPI DocJ2ME CLDC 1.13682Wed Feb 05 15:56:02 GMT 2003components

Attribute

public abstract class Attribute extends ClassComponent

Fields Summary
public UnicodeConstant
name
public int
length
Constructors Summary
protected Attribute(UnicodeConstant n, int l)

    name = n;
    length = l;
    resolved = true;
    
Methods Summary
public static voidcountConstantReferences(components.Attribute[] a, boolean isRelocatable)

    if ( a == null ) return;
    for ( int i = 0; i < a.length; i++ ){
        a[i].countConstantReferences( isRelocatable );
    }
    
public voidcountConstantReferences(boolean isRelocatable)

    //
    // if we are producing relocatable output, then
    // we will need our name in the string table.
    // Else not.
    //
    if ( isRelocatable )
        name.incReference();
    
public voidexternalize(ConstantPool p)

    if ( name != null ){
        name = (UnicodeConstant)p.add( name );
    }
    
public static voidexternalizeAttributes(components.Attribute[] a, ConstantPool p)

    int arryl = ( a == null ) ? 0 : a.length;
    for ( int i = 0; i < arryl; i++ ){
        a[i].externalize(p);
    }
    
public intlength()

    return 6+length; // believe length unchanged
    
public static intlength(components.Attribute[] a)

    int l = 0;
    int arryl = ( a == null ) ? 0 : a.length;
    for ( int i = 0; i < arryl; i++ ){
        l += a[i].length();
    }
    return l + 2;
    
public static components.Attribute[]readAttributes(java.io.DataInput i, ConstantObject[] locals, ConstantObject[] globals, java.util.Hashtable typetable, boolean verbose)

    int nattr =  i.readUnsignedShort();
    if ( verbose ){
        System.out.println(Localizer.getString("attribute.reading_attributes", Integer.toString(nattr)));
    }
    if ( nattr == 0 ) return null;
    Attribute a[] = new Attribute[nattr];
    for ( int j = 0; j < nattr; j++ ){
        UnicodeConstant name = (UnicodeConstant)globals[i.readUnsignedShort()];
        String typename = name.string.intern();
        AttributeFactory afact = (AttributeFactory)typetable.get( typename );
        if ( afact == null )
        afact = UninterpretedAttributeFactory.instance;

        a[j] = afact.finishReadAttribute( i, name, locals, globals );
    }
    return a;
    
public voidwrite(java.io.DataOutput o)

    o.writeShort( name.index );
    o.writeInt( length );
    int trueLength = writeData( o );
    if ( length != trueLength ){
        throw new DataFormatException(Localizer.getString("attribute.bad_attribute_length_for.dataformatexception", name ));
    }
    
public static voidwriteAttributes(components.Attribute[] a, java.io.DataOutput o, boolean verbose)

    int nattr =  ( a == null ) ? 0 : a.length;
    if ( verbose ){
        System.out.println(Localizer.getString("attribute.writing_attributes", Integer.toString(nattr)));
    }
    o.writeShort( nattr );
    for ( int j = 0; j < nattr; j++ ){
        if ( verbose ){
        System.out.println("    "+a[j].name.string );
        }
        a[j].write( o );
    }
    
protected abstract intwriteData(java.io.DataOutput o)