org.apache.bcel.generic
Class LocalVariableGen

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

public class LocalVariableGen
extends Object
implements InstructionTargeter, NamedAndTyped, Cloneable, 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 $
See Also:
LocalVariable, MethodGen, Serialized Form

Constructor Summary
LocalVariableGen(int index, String name, Type type, InstructionHandle start, InstructionHandle end)
          Generate a local variable that with index `index'.
 
Method Summary
 Object clone()
           
 boolean containsTarget(InstructionHandle ih)
           
 boolean equals(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()
           
 LocalVariable getLocalVariable(ConstantPoolGen cp)
          Get LocalVariable object.
 String getName()
           
 InstructionHandle getStart()
           
 Type getType()
           
 int hashCode()
           
 void setEnd(InstructionHandle end)
           
 void setIndex(int index)
           
 void setName(String name)
           
 void setStart(InstructionHandle start)
           
 void setType(Type type)
           
 String toString()
           
 void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocalVariableGen

public LocalVariableGen(int index,
                        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.

Parameters:
index - index of local variable
name - its name
type - its type
start - from where the instruction is valid (null means from the start)
end - until where the instruction is valid (null means to the end)
Method Detail

getLocalVariable

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

Parameters:
cp - constant pool

setIndex

public void setIndex(int index)

getIndex

public int getIndex()

setName

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

getName

public 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
Parameters:
old_ih - old target, either start or end
new_ih - new target

containsTarget

public boolean containsTarget(InstructionHandle ih)
Specified by:
containsTarget in interface InstructionTargeter
Returns:
true, if ih is target of this variable

hashCode

public int hashCode()
Overrides:
hashCode in class Object
Returns:
a hash code value for the object.

equals

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

Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

clone

public Object clone()
Overrides:
clone in class Object


Copyright © 2002-2006 Apache Software Foundation. All Rights Reserved.