FileDocCategorySizeDatePackage
LocalVariable.javaAPI DocJava SE 5 API8272Fri Aug 26 14:55:18 BST 2005com.sun.org.apache.bcel.internal.classfile

LocalVariable

public final class LocalVariable extends Object implements Node, com.sun.org.apache.bcel.internal.Constants, Cloneable
This class represents a local variable within a method. It contains its scope, name, signature and index on the method's frame.
version
$Id: LocalVariable.java,v 1.1.1.1 2001/10/29 20:00:02 jvanzyl Exp $
author
M. Dahm
see
LocalVariableTable

Fields Summary
private int
start_pc
private int
length
private int
name_index
private int
signature_index
private int
index
private ConstantPool
constant_pool
Constructors Summary
public LocalVariable(LocalVariable c)
Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a physical copy.

    this(c.getStartPC(), c.getLength(), c.getNameIndex(),
	 c.getSignatureIndex(), c.getIndex(), c.getConstantPool());
  
LocalVariable(DataInputStream file, ConstantPool constant_pool)
Construct object from file stream.

param
file Input stream
throw
IOException

    this(file.readUnsignedShort(), file.readUnsignedShort(), 
	 file.readUnsignedShort(), file.readUnsignedShort(), 
	 file.readUnsignedShort(), constant_pool);
  
public LocalVariable(int start_pc, int length, int name_index, int signature_index, int index, ConstantPool constant_pool)

param
start_pc Range in which the variable
param
length ... is valid
param
name_index Index in constant pool of variable name
param
signature_index Index of variable's signature
param
index Variable is `index'th local variable on the method's frame
param
constant_pool Array of constants

    this.start_pc        = start_pc;
    this.length          = length;
    this.name_index      = name_index;
    this.signature_index = signature_index;
    this.index           = index;
    this.constant_pool   = constant_pool;
  
Methods Summary
public voidaccept(com.sun.org.apache.bcel.internal.classfile.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.

param
v Visitor object

    v.visitLocalVariable(this);
  
public com.sun.org.apache.bcel.internal.classfile.LocalVariablecopy()

return
deep copy of this object

    try {
      return (LocalVariable)clone();
    } catch(CloneNotSupportedException e) {}

    return null;
  
public final voiddump(java.io.DataOutputStream file)
Dump local variable to file stream in binary format.

param
file Output file stream
throw
IOException

    file.writeShort(start_pc);
    file.writeShort(length);
    file.writeShort(name_index);
    file.writeShort(signature_index);
    file.writeShort(index);
  
public final com.sun.org.apache.bcel.internal.classfile.ConstantPoolgetConstantPool()

return
Constant pool used by this object.

 return constant_pool; 
public final intgetIndex()

return
index of register where variable is stored

 return index; 
public final intgetLength()

return
Variable is valid within getStartPC() .. getStartPC()+getLength()

 return length; 
public final java.lang.StringgetName()

return
Variable name.

    ConstantUtf8  c;

    c = (ConstantUtf8)constant_pool.getConstant(name_index, CONSTANT_Utf8);
    return c.getBytes();
  
public final intgetNameIndex()

return
Index in constant pool of variable name.

 return name_index; 
public final java.lang.StringgetSignature()

return
Signature.

    ConstantUtf8  c;
    c = (ConstantUtf8)constant_pool.getConstant(signature_index, 
						CONSTANT_Utf8);
    return c.getBytes();
  
public final intgetSignatureIndex()

return
Index in constant pool of variable signature.

 return signature_index; 
public final intgetStartPC()

return
Start of range where he variable is valid

 return start_pc; 
public final voidsetConstantPool(com.sun.org.apache.bcel.internal.classfile.ConstantPool constant_pool)

param
constant_pool Constant pool to be used for this object.

    this.constant_pool = constant_pool;
  
public final voidsetIndex(int index)

param
index.

 this.index = index; 
public final voidsetLength(int length)

param
length.

    this.length = length;
  
public final voidsetNameIndex(int name_index)

param
name_index.

    this.name_index = name_index;
  
public final voidsetSignatureIndex(int signature_index)

param
signature_index.

    this.signature_index = signature_index;
  
public final voidsetStartPC(int start_pc)

param
start_pc Specify range where the local variable is valid.

    this.start_pc = start_pc;
  
public final java.lang.StringtoString()

return
string representation.

    String name = getName(), signature = Utility.signatureToString(getSignature());

    return "LocalVariable(start_pc = " + start_pc + ", length = " + length +
      ", index = " + index + ":" + signature + " " + name + ")";