Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.bcel.classfile
Class Constant  view Constant download Constant.java

java.lang.Object
  extended byorg.apache.bcel.classfile.Constant
All Implemented Interfaces:
java.lang.Cloneable, Node, java.io.Serializable
Direct Known Subclasses:
ConstantClass, ConstantCP, ConstantDouble, ConstantFloat, ConstantInteger, ConstantLong, ConstantNameAndType, ConstantString, ConstantUtf8

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

Version:
$Id: Constant.java 386056 2006-03-15 11:31:56Z tcurdt $

Field Summary
private static org.apache.bcel.util.BCELComparator _cmp
           
protected  byte tag
           
 
Constructor Summary
(package private) Constant(byte tag)
           
 
Method Summary
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.
 java.lang.Object clone()
          This method may be called to create a new copy of the Object.
 Constant copy()
           
abstract  void dump(java.io.DataOutputStream file)
           
 boolean equals(java.lang.Object obj)
          Return value as defined by given BCELComparator strategy.
static org.apache.bcel.util.BCELComparator getComparator()
           
 byte getTag()
           
 int hashCode()
          Return value as defined by given BCELComparator strategy.
(package private) static Constant readConstant(java.io.DataInputStream file)
          Read one constant from the given file, the type depends on a tag byte.
static void setComparator(org.apache.bcel.util.BCELComparator comparator)
           
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_cmp

private static org.apache.bcel.util.BCELComparator _cmp

tag

protected byte tag
Constructor Detail

Constant

Constant(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.

Specified by:
accept in interface Node

dump

public abstract void dump(java.io.DataOutputStream file)
                   throws java.io.IOException

getTag

public final byte getTag()

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


copy

public Constant copy()

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Description copied from class: java.lang.Object
This method may be called to create a new copy of the Object. The typical behavior is as follows:
  • o == o.clone() is false
  • o.getClass() == o.clone().getClass() is true
  • o.equals(o) is true

However, these are not strict requirements, and may be violated if necessary. Of the three requirements, the last is the most commonly violated, particularly if the subclass does not override Object.equals(Object)>Object.equals(Object) 55 .

If the Object you call clone() on does not implement java.lang.Cloneable (which is a placeholder interface), then a CloneNotSupportedException is thrown. Notice that Object does not implement Cloneable; this method exists as a convenience for subclasses that do.

Object's implementation of clone allocates space for the new Object using the correct class, without calling any constructors, and then fills in all of the new field values with the old field values. Thus, it is a shallow copy. However, subclasses are permitted to make a deep copy.

All array types implement Cloneable, and override this method as follows (it should never fail):

 public Object clone()
 {
   try
     {
       super.clone();
     }
   catch (CloneNotSupportedException e)
     {
       throw new InternalError(e.getMessage());
     }
 }
 


readConstant

static final Constant readConstant(java.io.DataInputStream file)
                            throws java.io.IOException,
                                   ClassFormatException
Read one constant from the given file, the type depends on a tag byte.


getComparator

public static org.apache.bcel.util.BCELComparator getComparator()

setComparator

public static void setComparator(org.apache.bcel.util.BCELComparator comparator)

equals

public boolean equals(java.lang.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.


hashCode

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