Top Description Fields Constructors Methods
com.sun.org.apache.bcel.internal.classfile

public abstract Class Constant

extends Object
implements Cloneable, Node
Class Inheritance
All Implemented Interfaces
com.sun.org.apache.bcel.internal.classfile.Node, java.lang.Cloneable
Known Direct Subclasses
com.sun.org.apache.bcel.internal.classfile.ConstantCP, com.sun.org.apache.bcel.internal.classfile.ConstantDouble, com.sun.org.apache.bcel.internal.classfile.ConstantFloat, com.sun.org.apache.bcel.internal.classfile.ConstantInteger, com.sun.org.apache.bcel.internal.classfile.ConstantLong, com.sun.org.apache.bcel.internal.classfile.ConstantMethodHandle, com.sun.org.apache.bcel.internal.classfile.ConstantMethodType, com.sun.org.apache.bcel.internal.classfile.ConstantModule, com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType, com.sun.org.apache.bcel.internal.classfile.ConstantPackage, com.sun.org.apache.bcel.internal.classfile.ConstantString, com.sun.org.apache.bcel.internal.classfile.ConstantUtf8, com.sun.org.apache.bcel.internal.classfile.ConstantClass
Imports
java.io.DataInput, .DataOutputStream, .IOException, java.util.Objects, com.sun.org.apache.bcel.internal.Const, com.sun.org.apache.bcel.internal.util.BCELComparator

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

Modifier and TypeField and Description
private static BCELComparator
protected byte
tag

Deprecated (since 6.0) will be made private; do not access directly, use getter/setter

Constructor Summary

AccessConstructor and Description
pack-priv
Constant(final byte tag)

Method Summary

Modifier and TypeMethod and Description
public abstract void
accept(Visitor
Visitor object
v
)

Redeclares com.sun.org.apache.bcel.internal.classfile.Node.accept.

Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public Constant

Returns:

deep copy of this constant
copy
()

public abstract void
public boolean
equals(final Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Returns value as defined by given BCELComparator strategy.
public static BCELComparator

Returns:

Comparison strategy object
getComparator
()

public final byte

Returns:

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

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns value as defined by given BCELComparator strategy.
public static Constant

Returns:

Constant object
readConstant
(final DataInput
Input stream
dataInput
)

Reads one constant from the given input, the type depends on a tag byte.

public static void
setComparator(final BCELComparator
Comparison strategy object
comparator
)

public String

Returns:

String representation.
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

bcelComparatorback to summary
private static BCELComparator bcelComparator
tagback to summary
protected byte tag

Deprecated

(since 6.0) will be made private; do not access directly, use getter/setter

Annotations
@Deprecated

Constructor Detail

Constantback to summary
pack-priv Constant(final byte tag)

Method Detail

acceptback to summary
public abstract void accept(Visitor v)

Redeclares com.sun.org.apache.bcel.internal.classfile.Node.accept.

Called by objects that are traversing the nodes of the tree implicitly 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

Visitor object

Annotations
@Override
cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

Annotations
@Override
copyback to summary
public Constant copy()
Returns:Constant

deep copy of this constant

dumpback to summary
public abstract void dump(DataOutputStream file) throws IOException
equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Returns value as defined by given BCELComparator strategy. By default two Constant objects are said to be equal when the result of toString() is equal.

Parameters
obj:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
See Also
Object#equals(Object)
getComparatorback to summary
public static BCELComparator getComparator()
Returns:BCELComparator

Comparison strategy object

getTagback to summary
public final byte getTag()
Returns:byte

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

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns value as defined by given BCELComparator strategy. By default return the hashcode of the result of toString().

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object

Annotations
@Override
See Also
Object#hashCode()
readConstantback to summary
public static Constant readConstant(final DataInput dataInput) throws IOException, ClassFormatException

Reads one constant from the given input, the type depends on a tag byte.

Parameters
dataInput:DataInput

Input stream

Returns:Constant

Constant object

Exceptions
IOException:
if an I/O error occurs reading from the given dataInput.
ClassFormatException:
if the next byte is not recognized
Since
6.0 made public
setComparatorback to summary
public static void setComparator(final BCELComparator comparator)
Parameters
comparator:BCELComparator

Comparison strategy object

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

String representation.

Annotations
@Override