Package org.apache.bcel.classfile
Class ConstantPackage
java.lang.Object
org.apache.bcel.classfile.Constant
org.apache.bcel.classfile.ConstantPackage
- All Implemented Interfaces:
Cloneable,ConstantObject,Node
This class is derived from the abstract
Constant and represents a reference to a package.
Note: Early access Java 9 support- currently subject to change
- Since:
- 6.1
- See Also:
-
Field Summary
FieldsFields inherited from class org.apache.bcel.classfile.Constant
EMPTY_ARRAY, tag -
Constructor Summary
ConstructorsConstructorDescriptionConstantPackage(int nameIndex) Constructs a ConstantPackage.ConstantPackage(DataInput file) Initialize instance from file data.Initialize from another object. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.voiddump(DataOutputStream file) Dumps constant package to file stream in binary format.getBytes(ConstantPool cp) Gets the dereferenced string.Gets the String object.intGets the name index in constant pool of package name.voidsetNameIndex(int nameIndex) Sets the name index in the constant pool.toString()Methods inherited from class org.apache.bcel.classfile.Constant
clone, copy, equals, getComparator, getTag, hashCode, readConstant, setComparator
-
Field Details
-
nameIndex
private int nameIndex
-
-
Constructor Details
-
ConstantPackage
Initialize from another object.- Parameters:
c- Source to copy.
-
ConstantPackage
ConstantPackage(DataInput file) throws IOException Initialize instance from file data.- Parameters:
file- Input stream.- Throws:
IOException- Thrown if an I/O error occurs.
-
ConstantPackage
public ConstantPackage(int nameIndex) Constructs a ConstantPackage.- Parameters:
nameIndex- Name index in constant pool. Should refer to a ConstantUtf8.
-
-
Method Details
-
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. -
dump
Dumps constant package to file stream in binary format.- Specified by:
dumpin classConstant- Parameters:
file- Output file stream.- Throws:
IOException- Thrown if an I/O error occurs.
-
getBytes
Gets the dereferenced string.- Parameters:
cp- The constant pool.- Returns:
- dereferenced string.
-
getConstantValue
Gets the String object.- Specified by:
getConstantValuein interfaceConstantObject- Parameters:
cp- The constant pool.- Returns:
- String object.
-
getNameIndex
public int getNameIndex()Gets the name index in constant pool of package name.- Returns:
- Name index in constant pool of package name.
-
setNameIndex
public void setNameIndex(int nameIndex) Sets the name index in the constant pool.- Parameters:
nameIndex- The name index in the constant pool of this Constant Package.
-
toString
-