public class AnnotationsWriter extends Object
..Annotations_attribute.
 See the source code of the AnnotationsAttribute.Copier class.
 The following code snippet is an example of use of this class:
 ConstPool pool = ...;
 output = new ByteArrayOutputStream();
 writer = new AnnotationsWriter(output, pool);
 writer.numAnnotations(1);
 writer.annotation("Author", 2);
 writer.memberValuePair("name");      // element_value_pair
 writer.constValueIndex("chiba");
 writer.memberValuePair("address");   // element_value_pair
 writer.constValueIndex("tokyo");
 writer.close();
 byte[] attribute_info = output.toByteArray();
 AnnotationsAttribute anno
     = new AnnotationsAttribute(pool, AnnotationsAttribute.visibleTag,
                                attribute_info);
 
 The code snippet above generates the annotation attribute corresponding to this annotation:
@Author(name = "chiba", address = "tokyo")
| Modifier and Type | Field and Description | 
|---|---|
| protected OutputStream | output | 
| Constructor and Description | 
|---|
| AnnotationsWriter(OutputStream os,
                 ConstPool cp)Constructs with the given output stream. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | annotation(int typeIndex,
          int numMemberValuePairs)Writes  annotation. | 
| void | annotation(String type,
          int numMemberValuePairs)Writes  annotation. | 
| void | annotationValue()Writes  tagandannotation_valueinelement_value. | 
| void | arrayValue(int numValues)Writes  tagandarray_valueinelement_value. | 
| void | classInfoIndex(int index)Writes  tagandclass_info_indexinelement_value. | 
| void | classInfoIndex(String name)Writes  tagandclass_info_indexinelement_value. | 
| void | close()Closes the output stream. | 
| void | constValueIndex(boolean value)Writes  tagandconst_value_indexinelement_value. | 
| void | constValueIndex(byte value)Writes  tagandconst_value_indexinelement_value. | 
| void | constValueIndex(char value)Writes  tagandconst_value_indexinelement_value. | 
| void | constValueIndex(double value)Writes  tagandconst_value_indexinelement_value. | 
| void | constValueIndex(float value)Writes  tagandconst_value_indexinelement_value. | 
| void | constValueIndex(int value)Writes  tagandconst_value_indexinelement_value. | 
| void | constValueIndex(int tag,
               int index)Writes  tagandconst_value_indexinelement_value. | 
| void | constValueIndex(long value)Writes  tagandconst_value_indexinelement_value. | 
| void | constValueIndex(short value)Writes  tagandconst_value_indexinelement_value. | 
| void | constValueIndex(String value)Writes  tagandconst_value_indexinelement_value. | 
| void | enumConstValue(int typeNameIndex,
              int constNameIndex)Writes  tagandenum_const_valueinelement_value. | 
| void | enumConstValue(String typeName,
              String constName)Writes  tagandenum_const_valueinelement_value. | 
| ConstPool | getConstPool()Obtains the constant pool given to the constructor. | 
| void | memberValuePair(int memberNameIndex)Writes an element of a  element_value_pairsarray
 inannotation. | 
| void | memberValuePair(String memberName)Writes an element of a  element_value_pairsarray
 inannotation. | 
| void | numAnnotations(int num)Writes  num_annotationsinRuntime(In)VisibleAnnotations_attribute. | 
| void | numParameters(int num)Writes  num_parametersinRuntime(In)VisibleParameterAnnotations_attribute. | 
| protected void | write16bit(int value) | 
protected OutputStream output
public AnnotationsWriter(OutputStream os, ConstPool cp)
os - the output stream.cp - the constant pool.public ConstPool getConstPool()
public void close()
           throws IOException
IOExceptionpublic void numParameters(int num)
                   throws IOException
num_parameters in
 Runtime(In)VisibleParameterAnnotations_attribute.
 This method must be followed by num calls to
 numAnnotations().IOExceptionpublic void numAnnotations(int num)
                    throws IOException
num_annotations in
 Runtime(In)VisibleAnnotations_attribute.
 This method must be followed by num calls to
 annotation().IOExceptionpublic void annotation(String type, int numMemberValuePairs) throws IOException
annotation.
 This method must be followed by numMemberValuePairs
 calls to memberValuePair().type - the annotation interface name.numMemberValuePairs - num_element_value_pairs
                              in annotation.IOExceptionpublic void annotation(int typeIndex,
                       int numMemberValuePairs)
                throws IOException
annotation.
 This method must be followed by numMemberValuePairs
 calls to memberValuePair().typeIndex - type_index in annotation.numMemberValuePairs - num_element_value_pairs
                              in annotation.IOExceptionpublic void memberValuePair(String memberName) throws IOException
element_value_pairs array
 in annotation.
 This method must be followed by a
 call to constValueIndex(), enumConstValue(),
 etc.memberName - the element name.IOExceptionpublic void memberValuePair(int memberNameIndex)
                     throws IOException
element_value_pairs array
 in annotation.
 This method must be followed by a
 call to constValueIndex(), enumConstValue(),
 etc.memberNameIndex - element_name_index
                          in element_value_pairs array.IOExceptionpublic void constValueIndex(boolean value)
                     throws IOException
tag and const_value_index 
 in element_value.value - the constant value.IOExceptionpublic void constValueIndex(byte value)
                     throws IOException
tag and const_value_index 
 in element_value.value - the constant value.IOExceptionpublic void constValueIndex(char value)
                     throws IOException
tag and const_value_index 
 in element_value.value - the constant value.IOExceptionpublic void constValueIndex(short value)
                     throws IOException
tag and const_value_index 
 in element_value.value - the constant value.IOExceptionpublic void constValueIndex(int value)
                     throws IOException
tag and const_value_index 
 in element_value.value - the constant value.IOExceptionpublic void constValueIndex(long value)
                     throws IOException
tag and const_value_index 
 in element_value.value - the constant value.IOExceptionpublic void constValueIndex(float value)
                     throws IOException
tag and const_value_index 
 in element_value.value - the constant value.IOExceptionpublic void constValueIndex(double value)
                     throws IOException
tag and const_value_index 
 in element_value.value - the constant value.IOExceptionpublic void constValueIndex(String value) throws IOException
tag and const_value_index 
 in element_value.value - the constant value.IOExceptionpublic void constValueIndex(int tag,
                            int index)
                     throws IOException
tag and const_value_index 
 in element_value.tag - tag in element_value.index - const_value_index
                              in element_value.IOExceptionpublic void enumConstValue(String typeName, String constName) throws IOException
tag and enum_const_value 
 in element_value.typeName - the type name of the enum constant.constName - the simple name of the enum constant.IOExceptionpublic void enumConstValue(int typeNameIndex,
                           int constNameIndex)
                    throws IOException
tag and enum_const_value 
 in element_value.typeNameIndex - type_name_index
                              in element_value.constNameIndex - const_name_index
                              in element_value.IOExceptionpublic void classInfoIndex(String name) throws IOException
tag and class_info_index 
 in element_value.name - the class name.IOExceptionpublic void classInfoIndex(int index)
                    throws IOException
tag and class_info_index 
 in element_value.index - class_info_indexIOExceptionpublic void annotationValue()
                     throws IOException
tag and annotation_value 
 in element_value.
 This method must be followed by a call to annotation().IOExceptionpublic void arrayValue(int numValues)
                throws IOException
tag and array_value 
 in element_value.
 This method must be followed by numValues calls
 to constValueIndex(), enumConstValue(),
 etc.numValues - num_values
                      in array_value.IOExceptionprotected void write16bit(int value)
                   throws IOException
IOExceptionCopyright © 2016 Shigeru Chiba, www.javassist.org. All Rights Reserved.