diff options
Diffstat (limited to 'src/main/javassist/bytecode/annotation/AnnotationsWriter.java')
-rw-r--r-- | src/main/javassist/bytecode/annotation/AnnotationsWriter.java | 78 |
1 files changed, 40 insertions, 38 deletions
diff --git a/src/main/javassist/bytecode/annotation/AnnotationsWriter.java b/src/main/javassist/bytecode/annotation/AnnotationsWriter.java index f435d8f..8095fbe 100644 --- a/src/main/javassist/bytecode/annotation/AnnotationsWriter.java +++ b/src/main/javassist/bytecode/annotation/AnnotationsWriter.java @@ -1,11 +1,12 @@ /* * Javassist, a Java-bytecode translator toolkit. - * Copyright (C) 1999-2007 Shigeru Chiba. All Rights Reserved. + * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved. * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. Alternatively, the contents of this file may be used under - * the terms of the GNU Lesser General Public License Version 2.1 or later. + * the terms of the GNU Lesser General Public License Version 2.1 or later, + * or the Apache License Version 2.0. * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License @@ -15,7 +16,8 @@ package javassist.bytecode.annotation; -import java.io.*; +import java.io.IOException; +import java.io.OutputStream; import javassist.bytecode.ByteArray; import javassist.bytecode.ConstPool; @@ -27,16 +29,16 @@ import javassist.bytecode.ConstPool; * * <p>The following code snippet is an example of use of this class: * - * <ul><pre> + * <pre> * ConstPool pool = ...; * output = new ByteArrayOutputStream(); * writer = new AnnotationsWriter(output, pool); * * writer.numAnnotations(1); * writer.annotation("Author", 2); - * writer.memberValuePair("name"); + * writer.memberValuePair("name"); // element_value_pair * writer.constValueIndex("chiba"); - * writer.memberValuePair("address"); + * writer.memberValuePair("address"); // element_value_pair * writer.constValueIndex("tokyo"); * * writer.close(); @@ -44,20 +46,20 @@ import javassist.bytecode.ConstPool; * AnnotationsAttribute anno * = new AnnotationsAttribute(pool, AnnotationsAttribute.visibleTag, * attribute_info); - * </pre></ul> + * </pre> * * <p>The code snippet above generates the annotation attribute * corresponding to this annotation: * - * <ul><pre> + * <pre> * @Author(name = "chiba", address = "tokyo") - * </pre></ul> + * </pre> * * @see javassist.bytecode.AnnotationsAttribute * @see javassist.bytecode.ParameterAnnotationsAttribute */ public class AnnotationsWriter { - private OutputStream output; + protected OutputStream output; private ConstPool pool; /** @@ -112,7 +114,7 @@ public class AnnotationsWriter { * calls to <code>memberValuePair()</code>. * * @param type the annotation interface name. - * @param numMemberValuePairs <code>num_member_value_pairs</code> + * @param numMemberValuePairs <code>num_element_value_pairs</code> * in <code>annotation</code>. */ public void annotation(String type, int numMemberValuePairs) @@ -127,7 +129,7 @@ public class AnnotationsWriter { * calls to <code>memberValuePair()</code>. * * @param typeIndex <code>type_index</code> in <code>annotation</code>. - * @param numMemberValuePairs <code>num_member_value_pairs</code> + * @param numMemberValuePairs <code>num_element_value_pairs</code> * in <code>annotation</code>. */ public void annotation(int typeIndex, int numMemberValuePairs) @@ -138,27 +140,27 @@ public class AnnotationsWriter { } /** - * Writes an element of a <code>member_value_pairs</code> array + * Writes an element of a <code>element_value_pairs</code> array * in <code>annotation</code>. * This method must be followed by a * call to <code>constValueIndex()</code>, <code>enumConstValue()</code>, * etc. * - * @param memberName the name of the annotation type member. + * @param memberName the element name. */ public void memberValuePair(String memberName) throws IOException { memberValuePair(pool.addUtf8Info(memberName)); } /** - * Writes an element of a <code>member_value_pairs</code> array + * Writes an element of a <code>element_value_pairs</code> array * in <code>annotation</code>. * This method must be followed by a * call to <code>constValueIndex()</code>, <code>enumConstValue()</code>, * etc. * - * @param memberNameIndex <code>member_name_index</code> - * in <code>member_value_pairs</code> array. + * @param memberNameIndex <code>element_name_index</code> + * in <code>element_value_pairs</code> array. */ public void memberValuePair(int memberNameIndex) throws IOException { write16bit(memberNameIndex); @@ -166,7 +168,7 @@ public class AnnotationsWriter { /** * Writes <code>tag</code> and <code>const_value_index</code> - * in <code>member_value</code>. + * in <code>element_value</code>. * * @param value the constant value. */ @@ -176,7 +178,7 @@ public class AnnotationsWriter { /** * Writes <code>tag</code> and <code>const_value_index</code> - * in <code>member_value</code>. + * in <code>element_value</code>. * * @param value the constant value. */ @@ -186,7 +188,7 @@ public class AnnotationsWriter { /** * Writes <code>tag</code> and <code>const_value_index</code> - * in <code>member_value</code>. + * in <code>element_value</code>. * * @param value the constant value. */ @@ -196,7 +198,7 @@ public class AnnotationsWriter { /** * Writes <code>tag</code> and <code>const_value_index</code> - * in <code>member_value</code>. + * in <code>element_value</code>. * * @param value the constant value. */ @@ -206,7 +208,7 @@ public class AnnotationsWriter { /** * Writes <code>tag</code> and <code>const_value_index</code> - * in <code>member_value</code>. + * in <code>element_value</code>. * * @param value the constant value. */ @@ -216,7 +218,7 @@ public class AnnotationsWriter { /** * Writes <code>tag</code> and <code>const_value_index</code> - * in <code>member_value</code>. + * in <code>element_value</code>. * * @param value the constant value. */ @@ -226,7 +228,7 @@ public class AnnotationsWriter { /** * Writes <code>tag</code> and <code>const_value_index</code> - * in <code>member_value</code>. + * in <code>element_value</code>. * * @param value the constant value. */ @@ -236,7 +238,7 @@ public class AnnotationsWriter { /** * Writes <code>tag</code> and <code>const_value_index</code> - * in <code>member_value</code>. + * in <code>element_value</code>. * * @param value the constant value. */ @@ -246,7 +248,7 @@ public class AnnotationsWriter { /** * Writes <code>tag</code> and <code>const_value_index</code> - * in <code>member_value</code>. + * in <code>element_value</code>. * * @param value the constant value. */ @@ -256,11 +258,11 @@ public class AnnotationsWriter { /** * Writes <code>tag</code> and <code>const_value_index</code> - * in <code>member_value</code>. + * in <code>element_value</code>. * - * @param tag <code>tag</code> in <code>member_value</code>. + * @param tag <code>tag</code> in <code>element_value</code>. * @param index <code>const_value_index</code> - * in <code>member_value</code>. + * in <code>element_value</code>. */ public void constValueIndex(int tag, int index) throws IOException @@ -271,7 +273,7 @@ public class AnnotationsWriter { /** * Writes <code>tag</code> and <code>enum_const_value</code> - * in <code>member_value</code>. + * in <code>element_value</code>. * * @param typeName the type name of the enum constant. * @param constName the simple name of the enum constant. @@ -285,12 +287,12 @@ public class AnnotationsWriter { /** * Writes <code>tag</code> and <code>enum_const_value</code> - * in <code>member_value</code>. + * in <code>element_value</code>. * * @param typeNameIndex <code>type_name_index</code> - * in <code>member_value</code>. + * in <code>element_value</code>. * @param constNameIndex <code>const_name_index</code> - * in <code>member_value</code>. + * in <code>element_value</code>. */ public void enumConstValue(int typeNameIndex, int constNameIndex) throws IOException @@ -302,7 +304,7 @@ public class AnnotationsWriter { /** * Writes <code>tag</code> and <code>class_info_index</code> - * in <code>member_value</code>. + * in <code>element_value</code>. * * @param name the class name. */ @@ -312,7 +314,7 @@ public class AnnotationsWriter { /** * Writes <code>tag</code> and <code>class_info_index</code> - * in <code>member_value</code>. + * in <code>element_value</code>. * * @param index <code>class_info_index</code> */ @@ -323,7 +325,7 @@ public class AnnotationsWriter { /** * Writes <code>tag</code> and <code>annotation_value</code> - * in <code>member_value</code>. + * in <code>element_value</code>. * This method must be followed by a call to <code>annotation()</code>. */ public void annotationValue() throws IOException { @@ -332,7 +334,7 @@ public class AnnotationsWriter { /** * Writes <code>tag</code> and <code>array_value</code> - * in <code>member_value</code>. + * in <code>element_value</code>. * This method must be followed by <code>numValues</code> calls * to <code>constValueIndex()</code>, <code>enumConstValue()</code>, * etc. @@ -345,7 +347,7 @@ public class AnnotationsWriter { write16bit(numValues); } - private void write16bit(int value) throws IOException { + protected void write16bit(int value) throws IOException { byte[] buf = new byte[2]; ByteArray.write16bit(value, buf, 0); output.write(buf); |