javassist.bytecode.annotation

Class AnnotationsWriter

public class AnnotationsWriter extends Object

A convenience class for constructing a ..Annotations_attribute. See the source code of the AnnotationsAttribute.Copier class.

The following code snippet is an example of use of this class:

The code snippet above generates the annotation attribute corresponding to this annotation:

See Also: AnnotationsAttribute ParameterAnnotationsAttribute

Constructor Summary
AnnotationsWriter(OutputStream os, ConstPool cp)
Constructs with the given output stream.
Method Summary
voidannotation(String type, int numMemberValuePairs)
Writes annotation.
voidannotation(int typeIndex, int numMemberValuePairs)
Writes annotation.
voidannotationValue()
Writes tag and annotation_value in member_value.
voidarrayValue(int numValues)
Writes tag and array_value in member_value.
voidclassInfoIndex(String name)
Writes tag and class_info_index in member_value.
voidclassInfoIndex(int index)
Writes tag and class_info_index in member_value.
voidclose()
Closes the output stream.
voidconstValueIndex(boolean value)
Writes tag and const_value_index in member_value.
voidconstValueIndex(byte value)
Writes tag and const_value_index in member_value.
voidconstValueIndex(char value)
Writes tag and const_value_index in member_value.
voidconstValueIndex(short value)
Writes tag and const_value_index in member_value.
voidconstValueIndex(int value)
Writes tag and const_value_index in member_value.
voidconstValueIndex(long value)
Writes tag and const_value_index in member_value.
voidconstValueIndex(float value)
Writes tag and const_value_index in member_value.
voidconstValueIndex(double value)
Writes tag and const_value_index in member_value.
voidconstValueIndex(String value)
Writes tag and const_value_index in member_value.
voidconstValueIndex(int tag, int index)
Writes tag and const_value_index in member_value.
voidenumConstValue(String typeName, String constName)
Writes tag and enum_const_value in member_value.
voidenumConstValue(int typeNameIndex, int constNameIndex)
Writes tag and enum_const_value in member_value.
ConstPoolgetConstPool()
Obtains the constant pool given to the constructor.
voidmemberValuePair(String memberName)
Writes an element of a member_value_pairs array in annotation.
voidmemberValuePair(int memberNameIndex)
Writes an element of a member_value_pairs array in annotation.
voidnumAnnotations(int num)
Writes num_annotations in Runtime(In)VisibleAnnotations_attribute.
voidnumParameters(int num)
Writes num_parameters in Runtime(In)VisibleParameterAnnotations_attribute.

Constructor Detail

AnnotationsWriter

public AnnotationsWriter(OutputStream os, ConstPool cp)
Constructs with the given output stream.

Parameters: os the output stream. cp the constant pool.

Method Detail

annotation

public void annotation(String type, int numMemberValuePairs)
Writes annotation. This method must be followed by numMemberValuePairs calls to memberValuePair().

Parameters: type the annotation interface name. numMemberValuePairs num_member_value_pairs in annotation.

annotation

public void annotation(int typeIndex, int numMemberValuePairs)
Writes annotation. This method must be followed by numMemberValuePairs calls to memberValuePair().

Parameters: typeIndex type_index in annotation. numMemberValuePairs num_member_value_pairs in annotation.

annotationValue

public void annotationValue()
Writes tag and annotation_value in member_value. This method must be followed by a call to annotation().

arrayValue

public void arrayValue(int numValues)
Writes tag and array_value in member_value. This method must be followed by numValues calls to constValueIndex(), enumConstValue(), etc.

Parameters: numValues num_values in array_value.

classInfoIndex

public void classInfoIndex(String name)
Writes tag and class_info_index in member_value.

Parameters: name the class name.

classInfoIndex

public void classInfoIndex(int index)
Writes tag and class_info_index in member_value.

Parameters: index class_info_index

close

public void close()
Closes the output stream.

constValueIndex

public void constValueIndex(boolean value)
Writes tag and const_value_index in member_value.

Parameters: value the constant value.

constValueIndex

public void constValueIndex(byte value)
Writes tag and const_value_index in member_value.

Parameters: value the constant value.

constValueIndex

public void constValueIndex(char value)
Writes tag and const_value_index in member_value.

Parameters: value the constant value.

constValueIndex

public void constValueIndex(short value)
Writes tag and const_value_index in member_value.

Parameters: value the constant value.

constValueIndex

public void constValueIndex(int value)
Writes tag and const_value_index in member_value.

Parameters: value the constant value.

constValueIndex

public void constValueIndex(long value)
Writes tag and const_value_index in member_value.

Parameters: value the constant value.

constValueIndex

public void constValueIndex(float value)
Writes tag and const_value_index in member_value.

Parameters: value the constant value.

constValueIndex

public void constValueIndex(double value)
Writes tag and const_value_index in member_value.

Parameters: value the constant value.

constValueIndex

public void constValueIndex(String value)
Writes tag and const_value_index in member_value.

Parameters: value the constant value.

constValueIndex

public void constValueIndex(int tag, int index)
Writes tag and const_value_index in member_value.

Parameters: tag tag in member_value. index const_value_index in member_value.

enumConstValue

public void enumConstValue(String typeName, String constName)
Writes tag and enum_const_value in member_value.

Parameters: typeName the type name of the enum constant. constName the simple name of the enum constant.

enumConstValue

public void enumConstValue(int typeNameIndex, int constNameIndex)
Writes tag and enum_const_value in member_value.

Parameters: typeNameIndex type_name_index in member_value. constNameIndex const_name_index in member_value.

getConstPool

public ConstPool getConstPool()
Obtains the constant pool given to the constructor.

memberValuePair

public void memberValuePair(String memberName)
Writes an element of a member_value_pairs array in annotation. This method must be followed by a call to constValueIndex(), enumConstValue(), etc.

Parameters: memberName the name of the annotation type member.

memberValuePair

public void memberValuePair(int memberNameIndex)
Writes an element of a member_value_pairs array in annotation. This method must be followed by a call to constValueIndex(), enumConstValue(), etc.

Parameters: memberNameIndex member_name_index in member_value_pairs array.

numAnnotations

public void numAnnotations(int num)
Writes num_annotations in Runtime(In)VisibleAnnotations_attribute. This method must be followed by num calls to annotation().

numParameters

public void numParameters(int num)
Writes num_parameters in Runtime(In)VisibleParameterAnnotations_attribute. This method must be followed by num calls to numAnnotations().
Javassist, a Java-bytecode translator toolkit.
Copyright (C) 1999-2006 Shigeru Chiba. All Rights Reserved.