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

Quick Search    Search Deep

org.apache.bcel.generic
Class LocalVariableGen  view LocalVariableGen download LocalVariableGen.java

java.lang.Object
  extended byorg.apache.bcel.generic.LocalVariableGen
All Implemented Interfaces:
java.lang.Cloneable, InstructionTargeter, NamedAndTyped, java.io.Serializable

public class LocalVariableGen
extends java.lang.Object
implements InstructionTargeter, NamedAndTyped, java.lang.Cloneable, java.io.Serializable

This class represents a local variable within a method. It contains its scope, name and type. The generated LocalVariable object can be obtained with getLocalVariable which needs the instruction list and the constant pool as parameters.

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

Field Summary
private  InstructionHandle end
           
private  int index
           
private  java.lang.String name
           
private  InstructionHandle start
           
private  Type type
           
 
Constructor Summary
LocalVariableGen(int index, java.lang.String name, Type type, InstructionHandle start, InstructionHandle end)
          Generate a local variable that with index `index'.
 
Method Summary
 java.lang.Object clone()
          This method may be called to create a new copy of the Object.
 boolean containsTarget(InstructionHandle ih)
           
 boolean equals(java.lang.Object o)
          We consider to local variables to be equal, if the use the same index and are valid in the same range.
 InstructionHandle getEnd()
           
 int getIndex()
           
 org.apache.bcel.classfile.LocalVariable getLocalVariable(ConstantPoolGen cp)
          Get LocalVariable object.
 java.lang.String getName()
           
 InstructionHandle getStart()
           
 Type getType()
           
 int hashCode()
          Get a value that represents this Object, as uniquely as possible within the confines of an int.
 void setEnd(InstructionHandle end)
           
 void setIndex(int index)
           
 void setName(java.lang.String name)
           
 void setStart(InstructionHandle start)
           
 void setType(Type type)
           
 java.lang.String toString()
          Convert this Object to a human-readable String.
 void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

index

private int index

name

private java.lang.String name

type

private Type type

start

private InstructionHandle start

end

private InstructionHandle end
Constructor Detail

LocalVariableGen

public LocalVariableGen(int index,
                        java.lang.String name,
                        Type type,
                        InstructionHandle start,
                        InstructionHandle end)
Generate a local variable that with index `index'. Note that double and long variables need two indexs. Index indices have to be provided by the user.

Method Detail

getLocalVariable

public org.apache.bcel.classfile.LocalVariable getLocalVariable(ConstantPoolGen cp)
Get LocalVariable object. This relies on that the instruction list has already been dumped to byte code or or that the `setPositions' methods has been called for the instruction list. Note that for local variables whose scope end at the last instruction of the method's code, the JVM specification is ambiguous: both a start_pc+length ending at the last instruction and start_pc+length ending at first index beyond the end of the code are valid.


setIndex

public void setIndex(int index)

getIndex

public int getIndex()

setName

public void setName(java.lang.String name)
Specified by:
setName in interface NamedAndTyped

getName

public java.lang.String getName()
Specified by:
getName in interface NamedAndTyped

setType

public void setType(Type type)
Specified by:
setType in interface NamedAndTyped

getType

public Type getType()
Specified by:
getType in interface NamedAndTyped

getStart

public InstructionHandle getStart()

getEnd

public InstructionHandle getEnd()

setStart

public void setStart(InstructionHandle start)

setEnd

public void setEnd(InstructionHandle end)

updateTarget

public void updateTarget(InstructionHandle old_ih,
                         InstructionHandle new_ih)
Specified by:
updateTarget in interface InstructionTargeter

containsTarget

public boolean containsTarget(InstructionHandle ih)
Specified by:
containsTarget in interface InstructionTargeter

hashCode

public int hashCode()
Description copied from class: java.lang.Object
Get a value that represents this Object, as uniquely as possible within the confines of an int.

There are some requirements on this method which subclasses must follow:

  • Semantic equality implies identical hashcodes. In other words, if a.equals(b) is true, then a.hashCode() == b.hashCode() must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal.
  • It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.

Notice that since hashCode is used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.

The default implementation returns System.identityHashCode(this)


equals

public boolean equals(java.lang.Object o)
We consider to local variables to be equal, if the use the same index and are valid in the same range.


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


clone

public java.lang.Object clone()
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());
     }
 }