abstract class Constant extends java.lang.Object implements java.lang.Comparable, WritableData
Modifier and Type | Field and Description |
---|---|
protected static int |
CLASS
Class constant value.
|
private int |
cpIndex
Index of this constant within the constant pool.
|
protected static int |
DOUBLE
Double constant value.
|
protected static int |
FIELDREF
Fieldref constant value.
|
protected static int |
FLOAT
Float constant value.
|
protected int |
hashBase
Base number used when determining a hashcode for subclasses.
|
protected static int |
INTEGER
Integer constant value.
|
protected static int |
INTERFACEMETHODREF
InterfaceMethodref constant value.
|
protected static int |
LONG
Long constant value.
|
protected static int |
METHODREF
Methodref constant value.
|
protected static int |
NAMEANDTYPE
NameAndType constant value.
|
private static int[] |
NATURAL_ORDER
Natural order for each constant type within the constant pool.
|
protected static int |
STRING
String constant value.
|
protected int |
tag
Constant value tag for this constant object.
|
protected static int |
UTF8
Utf8 constant value.
|
private static int[] |
WIDTH
Width in constant pool "slots" (index positions) for each type.
|
Constructor and Description |
---|
Constant(int tag)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(java.lang.Object o)
This method determines the relative ordering of the current constant
with the constant specified, based upon the natural ordering of the
constant types within the constant pool.
|
(package private) int |
getCpIndex()
Return the index assigned to this constant within the constant pool.
|
(package private) int |
getWidth()
Return the width of this constant in terms of constant pool "slots".
|
(package private) void |
setCpIndex(int cpIndex)
Assign the index of this constant within the constant pool.
|
java.lang.String |
toString()
Return the string representation of this constant, primarily for
debugging purposes.
|
void |
write(java.io.DataOutput out)
Write the binary format of this constant to the specified output
stream.
|
protected abstract void |
writeContent(java.io.DataOutput out)
This method must be implemented by a subclass to provide the
appropriate behavior when writing the binary representation of
this constant to an output stream.
|
protected static final int CLASS
protected static final int FIELDREF
protected static final int METHODREF
protected static final int INTERFACEMETHODREF
protected static final int STRING
protected static final int INTEGER
protected static final int FLOAT
protected static final int LONG
protected static final int DOUBLE
protected static final int NAMEANDTYPE
protected static final int UTF8
private static final int[] NATURAL_ORDER
private static final int[] WIDTH
protected int tag
protected int hashBase
private int cpIndex
Constant(int tag)
tag
- One of the type value constants.public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
o
- A Constant
object with which to compare this
Constant
for purposes of sorting.final int getWidth()
final int getCpIndex()
final void setCpIndex(int cpIndex)
cpIndex
- Constant pool index to be assigned to this constant.public void write(java.io.DataOutput out) throws java.io.IOException
write
in interface WritableData
out
- Output stream to which to write the binary representation
of this constant.java.io.IOException
- if any error writing to stream.public java.lang.String toString()
toString
in class java.lang.Object
protected abstract void writeContent(java.io.DataOutput out) throws java.io.IOException
out
- Output stream to which to write the portion of the binary
representation of this constant which is specific to the
subclass.java.io.IOException
- if any error writing to stream.