final class ClassConstant extends Constant
CONSTANT_Class_info
structure
defined by the Java Virtual Machine Specification. This is a constant
in a class file's constant pool which refers to a class within the JVM.
The constructor for this class is private. To create an instance,
the static create(com.goldencode.expr.ConstantPool, java.lang.String)
method is used. This method will ensure that
the constant is properly added to the constant pool.
Modifier and Type | Field and Description |
---|---|
private Utf8Constant |
nameConstant
Constant for the name of the class represented by this constant
|
Modifier | Constructor and Description |
---|---|
private |
ClassConstant(ConstantPool pool,
java.lang.String name)
Create a new instance of this class, given a class name.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(java.lang.Object o)
This method compares this object to the specified object to determine
the natural ordering among the two.
|
(package private) static ClassConstant |
create(ConstantPool pool,
java.lang.String name)
Return an instance of this class, either newly created, or retrieved
from the specified constant pool.
|
boolean |
equals(java.lang.Object o)
This method returns true if this object is equal to the specified
object.
|
java.lang.String |
getName()
Return the name of the class represented by this constant.
|
int |
hashCode()
Return the unique hash code for this object.
|
java.lang.String |
toString()
Return a string representation of this constant, which is simply the
name of the class it represents.
|
protected void |
writeContent(java.io.DataOutput out)
This method writes the index of the name constant out to the
specified output stream.
|
getCpIndex, getWidth, setCpIndex, write
private Utf8Constant nameConstant
private ClassConstant(ConstantPool pool, java.lang.String name)
pool
- Constant pool from which to retrieve the Utf8Constant which
represents the name of the class.name
- Name of the class represented by the new constant.static ClassConstant create(ConstantPool pool, java.lang.String name)
pool
- Constant pool from which to retrieve instance of this class,
if one with the same name already has been created.name
- Name of the class represented by this constant.public java.lang.String getName()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- Another ClassConstant object to check for equality.public int compareTo(java.lang.Object o)
compareTo()
method is first called, which sorts the objects according to
the constant types. If this comparison indicates the objects compare
as equal, the class names are then compared.compareTo
in interface java.lang.Comparable
compareTo
in class Constant
o
- Another object to compare to this one, presumably another
subclass of Constant
.public java.lang.String toString()
protected void writeContent(java.io.DataOutput out) throws java.io.IOException
writeContent
in class Constant
out
- Output stream to which text is written.java.io.IOException
- If error occurs writing to stream.