org.apache.tomcat.util.bcel.classfile

## Class Constant

- java.lang.Object
- - org.apache.tomcat.util.bcel.classfile.Constant

All Implemented Interfaces:
  Serializable, Cloneable

Direct Known Subclasses:
  ConstantClass, ConstantCP, ConstantDouble, ConstantFloat, ConstantInteger, ConstantInvokeDynamic, ConstantLong, ConstantMethodHandle, ConstantMethodType, ConstantNameAndType, ConstantString, ConstantUtf8

    public abstract class Constant
    extends Object
    implements Cloneable, 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.

Author:
  M. Dahm
See Also:
  Serialized Form

### Field Summary

Fields
`protected byte` `tag`

### Method Summary

Methods
`Object` `clone()`
`boolean` `equals(Object obj)` Return value as defined by given BCELComparator strategy.
`byte` `getTag()`
`int` `hashCode()` Return value as defined by given BCELComparator strategy.
`String` `toString()`

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Field Detail

#### tag

    protected byte tag

### Method Detail

#### getTag

    public final byte getTag()

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

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`
Returns:
  String representation.

#### clone

    public Object clone()

Overrides:
  `clone` in class `Object`

#### 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.

Overrides:
  `equals` in class `Object`
See Also:
  `Object.equals(java.lang.Object)`

#### hashCode

    public int hashCode()

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

Overrides:
  `hashCode` in class `Object`
See Also:
  `Object.hashCode()`