org.apache.bcel.classfile

Class Constant

public abstract class Constant extends Object implements Cloneable, Node, Serializable

Abstract superclass for classes to represent the different constant types in the constant pool of a class file. The classes keep closely to the JVM specification.
Field Summary
protected bytetag
Method Summary
abstract voidaccept(Visitor v)
Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class.
Objectclone()
Constantcopy()
abstract voiddump(DataOutputStream file)
booleanequals(Object obj)
Return value as defined by given BCELComparator strategy.
static BCELComparatorgetComparator()
bytegetTag()
inthashCode()
Return value as defined by given BCELComparator strategy.
static voidsetComparator(BCELComparator comparator)
StringtoString()

Field Detail

tag

protected byte tag

Method Detail

accept

public abstract void accept(Visitor v)
Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.

Parameters: v Visitor object

clone

public Object clone()

copy

public Constant copy()

Returns: deep copy of this constant

dump

public abstract void dump(DataOutputStream file)

equals

public boolean equals(Object obj)
Return value as defined by given BCELComparator strategy. By default two Constant objects are said to be equal when the result of toString() is equal.

See Also: java.lang.Object#equals(java.lang.Object)

getComparator

public static BCELComparator getComparator()

Returns: Comparison strategy object

getTag

public final byte getTag()

Returns: Tag of constant, i.e., its type. No setTag() method to avoid confusion.

hashCode

public int hashCode()
Return value as defined by given BCELComparator strategy. By default return the hashcode of the result of toString().

See Also: java.lang.Object#hashCode()

setComparator

public static void setComparator(BCELComparator comparator)

Parameters: comparator Comparison strategy object

toString

public String toString()

Returns: String representation.