Package serp.bytecode
Class ConstantValue
- java.lang.Object
-
- serp.bytecode.Attributes
-
- serp.bytecode.Attribute
-
- serp.bytecode.ConstantValue
-
- All Implemented Interfaces:
BCEntity
,VisitAcceptor
public class ConstantValue extends Attribute
A constant value for a member field.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int
_valueIndex
-
Constructor Summary
Constructors Constructor Description ConstantValue(int nameIndex, Attributes owner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptVisit(BCVisitor visit)
Accept a visit from aBCVisitor
, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this one.double
getDoubleValue()
Get the value of this double constant.BCField
getField()
Return the owning field.float
getFloatValue()
Get the value of this float constant.int
getIntValue()
Get the value of this int constant, or 0 if not set.(package private) int
getLength()
Return the length of the bytecode representation of this attribute in bytes, excluding the name index.long
getLongValue()
Get the value of this long constant.java.lang.String
getStringValue()
Get the value of this string constant.java.lang.Class
getType()
Return the type of constant this attribute represents (String.class, int.class, etc), or null if not set.BCClass
getTypeBC()
Return the bytecode for the type of constant this attribute represents.java.lang.String
getTypeName()
Return the type of constant this attribute represents, or null if not set.java.lang.Object
getValue()
Return the value of this constant as an Object of the appropriate type (String, Integer, Double, etc), or null if not set.int
getValueIndex()
Return theConstantPool
index of theConstantEntry
holding the value of this constant.(package private) void
read(java.io.DataInput in, int length)
Read the attribute bytecode from the given stream, up to length bytes, excluding the name index.(package private) void
read(Attribute other)
Copy the information from the given attribute to this one.void
setDoubleValue(double value)
Set the value of this double constant.void
setFloatValue(float value)
Set the value of this float constant.void
setIntValue(int value)
Set the value of this int constant.void
setLongValue(long value)
Set the value of this long constant.void
setStringValue(java.lang.String value)
Set the value of this string constant.void
setValue(java.lang.Object value)
Set the value of this constant using the appropriate wrapper Object type (String, Integer, Double, etc).void
setValueIndex(int valueIndex)
Set theConstantPool
of theConstantEntry
holding the value of this constant.(package private) void
write(java.io.DataOutput out, int length)
Write the attribute bytecode to the given stream, up to length bytes, excluding the name index.-
Methods inherited from class serp.bytecode.Attribute
create, getAttributesHolder, getClassLoader, getName, getNameIndex, getOwner, getPool, getProject, invalidate, isValid
-
Methods inherited from class serp.bytecode.Attributes
addAttribute, addAttribute, clearAttributes, getAttribute, getAttributes, getAttributes, readAttributes, removeAttribute, removeAttribute, setAttributes, visitAttributes, writeAttributes
-
-
-
-
Constructor Detail
-
ConstantValue
ConstantValue(int nameIndex, Attributes owner)
-
-
Method Detail
-
getLength
int getLength()
Description copied from class:Attribute
Return the length of the bytecode representation of this attribute in bytes, excluding the name index.
-
getField
public BCField getField()
Return the owning field.
-
getValueIndex
public int getValueIndex()
Return theConstantPool
index of theConstantEntry
holding the value of this constant. Defaults to 0.
-
setValueIndex
public void setValueIndex(int valueIndex)
Set theConstantPool
of theConstantEntry
holding the value of this constant.
-
getTypeName
public java.lang.String getTypeName()
Return the type of constant this attribute represents, or null if not set.
-
getType
public java.lang.Class getType()
Return the type of constant this attribute represents (String.class, int.class, etc), or null if not set.
-
getTypeBC
public BCClass getTypeBC()
Return the bytecode for the type of constant this attribute represents.
-
getValue
public java.lang.Object getValue()
Return the value of this constant as an Object of the appropriate type (String, Integer, Double, etc), or null if not set.
-
setValue
public void setValue(java.lang.Object value)
Set the value of this constant using the appropriate wrapper Object type (String, Integer, Double, etc). Types that are not directly supported will be converted accordingly if possible.
-
getIntValue
public int getIntValue()
Get the value of this int constant, or 0 if not set.
-
setIntValue
public void setIntValue(int value)
Set the value of this int constant.
-
getFloatValue
public float getFloatValue()
Get the value of this float constant.
-
setFloatValue
public void setFloatValue(float value)
Set the value of this float constant.
-
getDoubleValue
public double getDoubleValue()
Get the value of this double constant.
-
setDoubleValue
public void setDoubleValue(double value)
Set the value of this double constant.
-
getLongValue
public long getLongValue()
Get the value of this long constant.
-
setLongValue
public void setLongValue(long value)
Set the value of this long constant.
-
getStringValue
public java.lang.String getStringValue()
Get the value of this string constant.
-
setStringValue
public void setStringValue(java.lang.String value)
Set the value of this string constant.
-
acceptVisit
public void acceptVisit(BCVisitor visit)
Description copied from interface:VisitAcceptor
Accept a visit from aBCVisitor
, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this one.
-
read
void read(Attribute other)
Description copied from class:Attribute
Copy the information from the given attribute to this one. Does nothing by default.
-
read
void read(java.io.DataInput in, int length) throws java.io.IOException
Description copied from class:Attribute
Read the attribute bytecode from the given stream, up to length bytes, excluding the name index. Does nothing by default.
-
write
void write(java.io.DataOutput out, int length) throws java.io.IOException
Description copied from class:Attribute
Write the attribute bytecode to the given stream, up to length bytes, excluding the name index. Does nothing by default.
-
-