Package com.ibm.wala.shrike.shrikeCT
Class ConstantValueWriter
- java.lang.Object
-
- com.ibm.wala.shrike.shrikeCT.ClassWriter.Element
-
- com.ibm.wala.shrike.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, java.lang.String v)Build an writer for a 'String' constant value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcopyInto(byte[] buf, int offset)Copy the bytes into 'buf' at offset 'offset'.intgetSize()voidsetDouble(double value)Set the constant value to a double.voidsetFloat(float value)Set the constant value to a float.voidsetInt(int value)Set the constant value to an int.voidsetLong(long value)Set the constant value to a long.voidsetString(java.lang.String value)Set the constant value to a String.voidsetValueCPIndex(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:
java.lang.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, java.lang.String v)
Build an writer for a 'String' constant value.
-
-
Method Detail
-
getSize
public int getSize()
- Specified by:
getSizein classClassWriter.Element- Returns:
- the number of bytes that will be generated.
-
copyInto
public int copyInto(byte[] buf, int offset) throws java.lang.IllegalArgumentExceptionDescription copied from class:ClassWriter.ElementCopy the bytes into 'buf' at offset 'offset'.- Specified by:
copyIntoin classClassWriter.Element- Returns:
- the number of bytes copies, which must be equal to getSize()
- Throws:
java.lang.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(java.lang.String value)
Set the constant value to a String.
-
setValueCPIndex
public void setValueCPIndex(int index) throws java.lang.IllegalArgumentExceptionSet the index of the constant pool item holding the constant value.- Throws:
java.lang.IllegalArgumentException
-
-