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

NameAndTypeConstant

public class NameAndTypeConstant extends ConstantObject

Fields Summary
public UnicodeConstant
name
public UnicodeConstant
type
int
nameIndex
int
typeIndex
public int
ID
Constructors Summary
private NameAndTypeConstant(int t, int ni, int ti)


            
	tag = t;
	nameIndex = ni;
	typeIndex = ti;
	nSlots = 1;
    
public NameAndTypeConstant(UnicodeConstant name, UnicodeConstant type)

	tag = Const.CONSTANT_NAMEANDTYPE;
	this.name = name;
	this.type = type;
	nSlots = 1;
	resolved = true;
    
Methods Summary
public voiddecReference()

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

	if (o instanceof NameAndTypeConstant) {
	    NameAndTypeConstant n = (NameAndTypeConstant) o;
	    return name.string.equals(n.name.string) &&
		   type.string.equals(n.type.string);
	} else {
	    return false;
	}
    
public voidexternalize(ConstantPool p)

	name = (UnicodeConstant)p.add( name );
	type = (UnicodeConstant)p.add( type );
    
public inthashCode()

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

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

 return true; 
public static ConstantObjectread(int t, java.io.DataInput i)

	return new NameAndTypeConstant( t, i.readUnsignedShort(), i.readUnsignedShort() );
    
public voidresolve(ConstantObject[] table)

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

	if ( resolved ){
	    return "NameAndType: "+name.string+" : "+type.string;
	}else{
	    return "NameAndType[ "+nameIndex+" : "+typeIndex+" ]";
	}
    
public voidwrite(java.io.DataOutput o)

	o.writeByte( tag );
	if ( resolved ){
	    o.writeShort( name.index );
	    o.writeShort( type.index );
	} else {
	    throw new DataFormatException("unresolved NameAndTypeConstant");
	    //o.writeShort( nameIndex );
	    //o.writeShort( typeIndex );
	}