APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.bcel.internal.classfile

public final Class ConstantValue

extends Attribute
Class Inheritance
Imports
java.io.DataInput, .DataOutputStream, .IOException, com.sun.org.apache.bcel.internal.Const, com.sun.org.apache.bcel.internal.util.Args

This class is derived from Attribute and represents a constant value, i.e., a default value for initializing a class field. This class is instantiated by the Attribute.readAttribute() method.
ConstantValue_attribute {
  u2 attribute_name_index;
  u4 attribute_length;
  u2 constantvalue_index;
}
See Also
Attribute

Field Summary

Modifier and TypeField and Description
private int
Inherited from com.sun.org.apache.bcel.internal.classfile.Attribute:
constant_poolEMPTY_ARRAYlengthname_indextag

Constructor Summary

AccessConstructor and Description
public
ConstantValue(final ConstantValue
Source to copy.
c
)

Initialize from another object.

pack-priv
ConstantValue(final int
Name index in constant pool
nameIndex
,
final int
Content length in bytes
length
,
final DataInput
Input stream
input
,
final ConstantPool
Array of constants
constantPool
)

Constructs object from input stream.

public
ConstantValue(final int
Name index in constant pool
nameIndex
,
final int
Content length in bytes
length
,
final int
Index in constant pool
constantValueIndex
,
final ConstantPool
Array of constants
constantPool
)

Method Summary

Modifier and TypeMethod and Description
public void
accept(final Visitor
Visitor object
v
)

Implements abstract com.sun.org.apache.bcel.internal.classfile.Attribute.accept.

Implements com.sun.org.apache.bcel.internal.classfile.Node.accept.

Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.

public Attribute
copy(final ConstantPool constantPool)

Implements abstract com.sun.org.apache.bcel.internal.classfile.Attribute.copy.

Returns: deep copy of this attribute

public void
dump(final DataOutputStream
Output file stream
file
)

Overrides com.sun.org.apache.bcel.internal.classfile.Attribute.dump.

Dump constant value attribute to file stream on binary format.

public int
getConstantValueIndex()

Returns: Index in constant pool of constant value.

public void
setConstantValueIndex(final int
the index info the constant pool of this constant value
constantValueIndex
)

public String

Returns:

String representation of constant value.
toString
()

Overrides com.sun.org.apache.bcel.internal.classfile.Attribute.toString.

Returns a string representation of the object.

Inherited from com.sun.org.apache.bcel.internal.classfile.Attribute:
addAttributeReaderclonegetConstantPoolgetLengthgetNamegetNameIndexgetTagprintlnreadAttributereadAttributeremoveAttributeReadersetConstantPoolsetLengthsetNameIndex

Field Detail

constantValueIndexback to summary
private int constantValueIndex

Constructor Detail

ConstantValueback to summary
public ConstantValue(final ConstantValue c)

Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a physical copy.

Parameters
c:ConstantValue

Source to copy.

ConstantValueback to summary
pack-priv ConstantValue(final int nameIndex, final int length, final DataInput input, final ConstantPool constantPool) throws IOException

Constructs object from input stream.

Parameters
nameIndex:int

Name index in constant pool

length:int

Content length in bytes

input:DataInput

Input stream

constantPool:ConstantPool

Array of constants

Exceptions
IOException:
if an I/O error occurs.
ConstantValueback to summary
public ConstantValue(final int nameIndex, final int length, final int constantValueIndex, final ConstantPool constantPool)
Parameters
nameIndex:int

Name index in constant pool

length:int

Content length in bytes

constantValueIndex:int

Index in constant pool

constantPool:ConstantPool

Array of constants

Method Detail

acceptback to summary
public void accept(final Visitor v)

Implements abstract com.sun.org.apache.bcel.internal.classfile.Attribute.accept.

Implements com.sun.org.apache.bcel.internal.classfile.Node.accept.

Called by objects that are traversing the nodes of the tree implicitly 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

Visitor object

Annotations
@Override
copyback to summary
public Attribute copy(final ConstantPool constantPool)

Implements abstract com.sun.org.apache.bcel.internal.classfile.Attribute.copy.

Returns:Attribute

deep copy of this attribute

Annotations
@Override
dumpback to summary
public void dump(final DataOutputStream file) throws IOException

Overrides com.sun.org.apache.bcel.internal.classfile.Attribute.dump.

Dump constant value attribute to file stream on binary format.

Parameters
file:DataOutputStream

Output file stream

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
getConstantValueIndexback to summary
public int getConstantValueIndex()
Returns:int

Index in constant pool of constant value.

setConstantValueIndexback to summary
public void setConstantValueIndex(final int constantValueIndex)
Parameters
constantValueIndex:int

the index info the constant pool of this constant value

toStringback to summary
public String toString()

Overrides com.sun.org.apache.bcel.internal.classfile.Attribute.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

String representation of constant value.

Annotations
@Override