org.apache.bcel.classfile

Class ConstantString

public final class ConstantString extends Constant implements ConstantObject

This class is derived from the abstract Constant class and represents a reference to a String object.

See Also: Constant

Constructor Summary
ConstantString(ConstantString c)
Initialize from another object.
ConstantString(int string_index)
Method Summary
voidaccept(Visitor v)
Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class.
voiddump(DataOutputStream file)
Dump constant field reference to file stream in binary format.
StringgetBytes(ConstantPool cp)
ObjectgetConstantValue(ConstantPool cp)
intgetStringIndex()
voidsetStringIndex(int string_index)
StringtoString()

Constructor Detail

ConstantString

public ConstantString(ConstantString c)
Initialize from another object.

ConstantString

public ConstantString(int string_index)

Parameters: string_index Index of Constant_Utf8 in constant pool

Method Detail

accept

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

Parameters: v Visitor object

dump

public final void dump(DataOutputStream file)
Dump constant field reference to file stream in binary format.

Parameters: file Output file stream

Throws: IOException

getBytes

public String getBytes(ConstantPool cp)

Returns: dereferenced string

getConstantValue

public Object getConstantValue(ConstantPool cp)

Returns: String object

getStringIndex

public final int getStringIndex()

Returns: Index in constant pool of the string (ConstantUtf8).

setStringIndex

public final void setStringIndex(int string_index)

Parameters: string_index the index into the constant of the string value

toString

public final String toString()

Returns: String representation.