Package com.ibm.wala.shrikeCT
Class ConstantValueWriter
- java.lang.Object
-
- com.ibm.wala.shrikeCT.ClassWriter.Element
-
- com.ibm.wala.shrikeCT.ConstantValueWriter
-
public final class ConstantValueWriter extends ClassWriter.Element
This class builds serializable ConstantValue attributes. These attributes are associated with final fields. After constructing a ConstantValueWriter, you must call setValueCPIndex.
-
-
Constructor Summary
Constructors Constructor Description ConstantValueWriter(ClassWriter w)
Build an empty writer.ConstantValueWriter(ClassWriter w, double v)
Build an writer for a 'double' constant value.ConstantValueWriter(ClassWriter w, float v)
Build an writer for a 'float' constant value.ConstantValueWriter(ClassWriter w, int v)
Build an writer for an 'int' constant value.ConstantValueWriter(ClassWriter w, long v)
Build an writer for a 'long' constant value.ConstantValueWriter(ClassWriter w, String v)
Build an writer for a 'String' constant value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
copyInto(byte[] buf, int offset)
Copy the bytes into 'buf' at offset 'offset'.int
getSize()
void
setDouble(double value)
Set the constant value to a double.void
setFloat(float value)
Set the constant value to a float.void
setInt(int value)
Set the constant value to an int.void
setLong(long value)
Set the constant value to a long.void
setString(String value)
Set the constant value to a String.void
setValueCPIndex(int index)
Set the index of the constant pool item holding the constant value.
-
-
-
Constructor Detail
-
ConstantValueWriter
public ConstantValueWriter(ClassWriter w)
Build an empty writer.- Throws:
IllegalArgumentException
- if w is null
-
ConstantValueWriter
public ConstantValueWriter(ClassWriter w, long v)
Build an writer for a 'long' constant value.
-
ConstantValueWriter
public ConstantValueWriter(ClassWriter w, int v)
Build an writer for an 'int' constant value.
-
ConstantValueWriter
public ConstantValueWriter(ClassWriter w, float v)
Build an writer for a 'float' constant value.
-
ConstantValueWriter
public ConstantValueWriter(ClassWriter w, double v)
Build an writer for a 'double' constant value.
-
ConstantValueWriter
public ConstantValueWriter(ClassWriter w, String v)
Build an writer for a 'String' constant value.
-
-
Method Detail
-
getSize
public int getSize()
- Specified by:
getSize
in classClassWriter.Element
- Returns:
- the number of bytes that will be generated.
-
copyInto
public int copyInto(byte[] buf, int offset) throws IllegalArgumentException
Description copied from class:ClassWriter.Element
Copy the bytes into 'buf' at offset 'offset'.- Specified by:
copyInto
in classClassWriter.Element
- Returns:
- the number of bytes copies, which must be equal to getSize()
- Throws:
IllegalArgumentException
-
setLong
public void setLong(long value)
Set the constant value to a long.
-
setDouble
public void setDouble(double value)
Set the constant value to a double.
-
setInt
public void setInt(int value)
Set the constant value to an int.
-
setFloat
public void setFloat(float value)
Set the constant value to a float.
-
setString
public void setString(String value)
Set the constant value to a String.
-
setValueCPIndex
public void setValueCPIndex(int index) throws IllegalArgumentException
Set the index of the constant pool item holding the constant value.- Throws:
IllegalArgumentException
-
-