FileDocCategorySizeDatePackage
ClassConstant.javaAPI DocJ2ME CLDC 1.12576Wed Feb 05 15:56:02 GMT 2003components

ClassConstant

public class ClassConstant extends ConstantObject

Fields Summary
public UnicodeConstant
name
private boolean
didLookup
private ClassInfo
theClass
public int
nameIndex
Constructors Summary
ClassConstant(int t, int n)

 
    tag = t;
    nameIndex = n;
    nSlots = 1;
    
public ClassConstant(UnicodeConstant n)

    tag = Const.CONSTANT_CLASS;
    name = n;
    nSlots = 1;
    resolved = true;
    
Methods Summary
public voiddecReference()

    references--;
    name.decReference();
    
public booleanequals(java.lang.Object o)

    if (o instanceof ClassConstant) {
        ClassConstant c = (ClassConstant) o;
        return name.string.equals(c.name.string);
    } else {
        return false;
    }
    
public voidexternalize(ConstantPool p)

    name = (UnicodeConstant)p.add( name );
    
public ClassInfofind()

    if ( !didLookup ){
        theClass = ClassInfo.lookupClass( name.string );
        didLookup = true;
    }
    return theClass; // which may be null
    
public voidforget()

    didLookup = false;
    theClass = null;
    
public inthashCode()

    return tag + name.hashCode();
    
public voidincReference()

    references++;
    name.incReference();
    
public booleanisResolved()

 return find() != null; 
public static components.ClassConstantread(int tag, java.io.DataInput in)

    return new ClassConstant( tag, in.readUnsignedShort() );
    
public voidresolve(ConstantObject[] table)

    if (resolved) return;
    name = (UnicodeConstant)table[nameIndex];
    resolved = true;
    
public java.lang.StringtoString()

    if ( resolved )
        return "Class: "+name.toString();
    else
        return "Class: ["+nameIndex+"]";
    
public voidwrite(java.io.DataOutput o)

    o.writeByte( tag );
    if ( ! resolved )
        throw new DataFormatException("unresolved ClassConstant");
    int x = name.index;
    if ( x == 0 )
        throw new DataFormatException("0 name index for "+name.string);
    o.writeShort( x );