public final class ConstantValueAttribute extends AttributeInfo
ConstantValueAttribute
denotes a ConstantValue_attribute structure somewhere in a ClassFile structure.
This class is not thread-safe.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NAME
The name of the ConstantValue_attribute structure.
|
Modifier and Type | Method and Description |
---|---|
ConstantValueAttribute |
copy()
Returns a copy of this
ConstantValueAttribute instance. |
boolean |
equals(java.lang.Object object)
Returns
true if, and only if, object is an instance of ConstantValueAttribute , and that ConstantValueAttribute instance is equal to this ConstantValueAttribute instance,
false otherwise. |
static java.util.List<ConstantValueAttribute> |
filter(Node node)
Returns a
List with all ConstantValueAttribute s. |
static java.util.Optional<ConstantValueAttribute> |
find(FieldInfo fieldInfo)
Attempts to find a
ConstantValueAttribute instance in fieldInfo . |
int |
getAttributeLength()
Returns the attribute_length of this
ConstantValueAttribute instance. |
int |
getConstantValueIndex()
Returns the constantvalue_index of this
ConstantValueAttribute instance. |
int |
hashCode()
Returns a hash code for this
ConstantValueAttribute instance. |
static ConstantValueAttribute |
newInstance(int attributeNameIndex,
int constantValueIndex)
Returns a new
ConstantValueAttribute instance. |
void |
setConstantValueIndex(int constantValueIndex)
Sets a new constantvalue_index for this
ConstantValueAttribute instance. |
java.lang.String |
toString()
Returns a
String representation of this ConstantValueAttribute instance. |
void |
write(java.io.DataOutput dataOutput)
Writes this
ConstantValueAttribute to dataOutput . |
getAttributeNameIndex, getName, setAttributeNameIndex
public static final java.lang.String NAME
public ConstantValueAttribute copy()
ConstantValueAttribute
instance.copy
in class AttributeInfo
ConstantValueAttribute
instancepublic java.lang.String toString()
String
representation of this ConstantValueAttribute
instance.toString
in class java.lang.Object
String
representation of this ConstantValueAttribute
instancepublic boolean equals(java.lang.Object object)
true
if, and only if, object
is an instance of ConstantValueAttribute
, and that ConstantValueAttribute
instance is equal to this ConstantValueAttribute
instance,
false
otherwise.equals
in class java.lang.Object
object
- an Object
to compare to this ConstantValueAttribute
instance for equalitytrue
if, and only if, object
is an instance of ConstantValueAttribute
, and that ConstantValueAttribute
instance is equal to this ConstantValueAttribute
instance,
false
otherwisepublic int getAttributeLength()
ConstantValueAttribute
instance.getAttributeLength
in class AttributeInfo
ConstantValueAttribute
instancepublic int getConstantValueIndex()
ConstantValueAttribute
instance.ConstantValueAttribute
instancepublic int hashCode()
ConstantValueAttribute
instance.hashCode
in class java.lang.Object
ConstantValueAttribute
instancepublic void setConstantValueIndex(int constantValueIndex)
ConstantValueAttribute
instance.
If constantValueIndex
is less than or equal to 0
, an IllegalArgumentException
will be thrown.
constantValueIndex
- the new constantvalue_index for this ConstantValueAttribute
instancejava.lang.IllegalArgumentException
- thrown if, and only if, constantValueIndex
is less than or equal to 0
public void write(java.io.DataOutput dataOutput)
ConstantValueAttribute
to dataOutput
.
If dataOutput
is an OutputStream
(or any other type of stream), this method will not close it.
If dataOutput
is null
, a NullPointerException
will be thrown.
If an I/O-error occurs, an UncheckedIOException
will be thrown.
write
in class AttributeInfo
dataOutput
- the DataOutput
to write tojava.lang.NullPointerException
- thrown if, and only if, dataOutput
is null
java.io.UncheckedIOException
- thrown if, and only if, an I/O-error occurspublic static ConstantValueAttribute newInstance(int attributeNameIndex, int constantValueIndex)
ConstantValueAttribute
instance.
If either attributeNameIndex
or constantValueIndex
are less than or equal to 0
, an IllegalArgumentException
will be thrown.
attributeNameIndex
- the attribute_name_index of the new ConstantValueAttribute
instanceconstantValueIndex
- the constantvalue_index of the new ConstantValueAttribute
instanceConstantValueAttribute
instancejava.lang.IllegalArgumentException
- thrown if, and only if, either attributeNameIndex
or constantValueIndex
are less than or equal to 0
public static java.util.List<ConstantValueAttribute> filter(Node node)
List
with all ConstantValueAttribute
s.
All ConstantValueAttribute
s are found by traversing node
using a simple NodeHierarchicalVisitor
implementation.
If node
is null
, a NullPointerException
will be thrown.
node
- the Node
to start traversal fromList
with all ConstantValueAttribute
sjava.lang.NullPointerException
- thrown if, and only if, node
is null
public static java.util.Optional<ConstantValueAttribute> find(FieldInfo fieldInfo)
ConstantValueAttribute
instance in fieldInfo
.
Returns an Optional
with the optional ConstantValueAttribute
instance.
If fieldInfo
is null
, a NullPointerException
will be thrown.
fieldInfo
- the FieldInfo
to check inOptional
with the optional ConstantValueAttribute
instancejava.lang.NullPointerException
- thrown if, and only if, fieldInfo
is null