FileDocCategorySizeDatePackage
ConstantPoolEntry.javaAPI DocApache Ant 1.706675Wed Dec 13 06:16:24 GMT 2006org.apache.tools.ant.taskdefs.optional.depend.constantpool

ConstantPoolEntry

public abstract class ConstantPoolEntry extends Object
An entry in the constant pool. This class contains a representation of the constant pool entries. It is an abstract base class for all the different forms of constant pool entry.
see
ConstantPool

Fields Summary
public static final int
CONSTANT_UTF8
Tag value for UTF8 entries.
public static final int
CONSTANT_INTEGER
Tag value for Integer entries.
public static final int
CONSTANT_FLOAT
Tag value for Float entries.
public static final int
CONSTANT_LONG
Tag value for Long entries.
public static final int
CONSTANT_DOUBLE
Tag value for Double entries.
public static final int
CONSTANT_CLASS
Tag value for Class entries.
public static final int
CONSTANT_STRING
Tag value for String entries.
public static final int
CONSTANT_FIELDREF
Tag value for Field Reference entries.
public static final int
CONSTANT_METHODREF
Tag value for Method Reference entries.
public static final int
CONSTANT_INTERFACEMETHODREF
Tag value for Interface Method Reference entries.
public static final int
CONSTANT_NAMEANDTYPE
Tag value for Name and Type entries.
private int
tag
This entry's tag which identifies the type of this constant pool entry.
private int
numEntries
The number of slots in the constant pool, occupied by this entry.
private boolean
resolved
A flag which indicates if this entry has been resolved or not.
Constructors Summary
public ConstantPoolEntry(int tagValue, int entries)
Initialise the constant pool entry.

param
tagValue the tag value which identifies which type of constant pool entry this is.
param
entries the number of constant pool entry slots this entry occupies.


                                                   
         
        tag = tagValue;
        numEntries = entries;
        resolved = false;
    
Methods Summary
public final intgetNumEntries()
Get the number of Constant Pool Entry slots within the constant pool occupied by this entry.

return
the number of slots used.

        return numEntries;
    
public intgetTag()
Get the Entry's type tag.

return
The Tag value of this entry

        return tag;
    
public booleanisResolved()
Indicates whether this entry has been resolved. In general a constant pool entry can reference another constant pool entry by its index value. Resolution involves replacing this index value with the constant pool entry at that index.

return
true if this entry has been resolved.

        return resolved;
    
public abstract voidread(java.io.DataInputStream cpStream)
read a constant pool entry from a class stream.

param
cpStream the DataInputStream which contains the constant pool entry to be read.
exception
IOException if there is a problem reading the entry from the stream.

public static org.apache.tools.ant.taskdefs.optional.depend.constantpool.ConstantPoolEntryreadEntry(java.io.DataInputStream cpStream)
Read a constant pool entry from a stream. This is a factory method which reads a constant pool entry form a stream and returns the appropriate subclass for the entry.

param
cpStream the stream from which the constant pool entry is to be read.
return
the appropriate ConstantPoolEntry subclass representing the constant pool entry from the stream.
exception
IOException if the constant pool entry cannot be read from the stream

        ConstantPoolEntry cpInfo = null;
        int cpTag = cpStream.readUnsignedByte();

        switch (cpTag) {

            case CONSTANT_UTF8:
                cpInfo = new Utf8CPInfo();

                break;
            case CONSTANT_INTEGER:
                cpInfo = new IntegerCPInfo();

                break;
            case CONSTANT_FLOAT:
                cpInfo = new FloatCPInfo();

                break;
            case CONSTANT_LONG:
                cpInfo = new LongCPInfo();

                break;
            case CONSTANT_DOUBLE:
                cpInfo = new DoubleCPInfo();

                break;
            case CONSTANT_CLASS:
                cpInfo = new ClassCPInfo();

                break;
            case CONSTANT_STRING:
                cpInfo = new StringCPInfo();

                break;
            case CONSTANT_FIELDREF:
                cpInfo = new FieldRefCPInfo();

                break;
            case CONSTANT_METHODREF:
                cpInfo = new MethodRefCPInfo();

                break;
            case CONSTANT_INTERFACEMETHODREF:
                cpInfo = new InterfaceMethodRefCPInfo();

                break;
            case CONSTANT_NAMEANDTYPE:
                cpInfo = new NameAndTypeCPInfo();

                break;
            default:
                throw new ClassFormatError("Invalid Constant Pool entry Type "
                     + cpTag);
        }

        cpInfo.read(cpStream);

        return cpInfo;
    
public voidresolve(ConstantPool constantPool)
Resolve this constant pool entry with respect to its dependents in the constant pool.

param
constantPool the constant pool of which this entry is a member and against which this entry is to be resolved.

        resolved = true;