|
1 |
| -/*** |
2 |
| - * ASM: a very small and fast Java bytecode manipulation framework |
3 |
| - * Copyright (c) 2000-2011 INRIA, France Telecom |
4 |
| - * All rights reserved. |
5 |
| - * |
6 |
| - * Redistribution and use in source and binary forms, with or without |
7 |
| - * modification, are permitted provided that the following conditions |
8 |
| - * are met: |
9 |
| - * 1. Redistributions of source code must retain the above copyright |
10 |
| - * notice, this list of conditions and the following disclaimer. |
11 |
| - * 2. Redistributions in binary form must reproduce the above copyright |
12 |
| - * notice, this list of conditions and the following disclaimer in the |
13 |
| - * documentation and/or other materials provided with the distribution. |
14 |
| - * 3. Neither the name of the copyright holders nor the names of its |
15 |
| - * contributors may be used to endorse or promote products derived from |
16 |
| - * this software without specific prior written permission. |
17 |
| - * |
18 |
| - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 |
| - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 |
| - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 |
| - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
22 |
| - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 |
| - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 |
| - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
25 |
| - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
26 |
| - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
27 |
| - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
28 |
| - * THE POSSIBILITY OF SUCH DAMAGE. |
29 |
| - */ |
| 1 | +// ASM: a very small and fast Java bytecode manipulation framework |
| 2 | +// Copyright (c) 2000-2011 INRIA, France Telecom |
| 3 | +// All rights reserved. |
| 4 | +// |
| 5 | +// Redistribution and use in source and binary forms, with or without |
| 6 | +// modification, are permitted provided that the following conditions |
| 7 | +// are met: |
| 8 | +// 1. Redistributions of source code must retain the above copyright |
| 9 | +// notice, this list of conditions and the following disclaimer. |
| 10 | +// 2. Redistributions in binary form must reproduce the above copyright |
| 11 | +// notice, this list of conditions and the following disclaimer in the |
| 12 | +// documentation and/or other materials provided with the distribution. |
| 13 | +// 3. Neither the name of the copyright holders nor the names of its |
| 14 | +// contributors may be used to endorse or promote products derived from |
| 15 | +// this software without specific prior written permission. |
| 16 | +// |
| 17 | +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 18 | +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 20 | +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 21 | +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 24 | +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 25 | +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 26 | +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 27 | +// THE POSSIBILITY OF SUCH DAMAGE. |
30 | 28 | package clojure.asm;
|
31 | 29 |
|
32 | 30 | /**
|
33 |
| - * A visitor to visit a Java annotation. The methods of this class must be |
34 |
| - * called in the following order: ( <tt>visit</tt> | <tt>visitEnum</tt> | |
35 |
| - * <tt>visitAnnotation</tt> | <tt>visitArray</tt> )* <tt>visitEnd</tt>. |
| 31 | + * A visitor to visit a Java annotation. The methods of this class must be called in the following |
| 32 | + * order: ( <tt>visit</tt> | <tt>visitEnum</tt> | <tt>visitAnnotation</tt> | <tt>visitArray</tt> )* |
| 33 | + * <tt>visitEnd</tt>. |
36 | 34 | *
|
37 | 35 | * @author Eric Bruneton
|
38 | 36 | * @author Eugene Kuleshov
|
39 | 37 | */
|
40 | 38 | public abstract class AnnotationVisitor {
|
41 | 39 |
|
42 |
| - /** |
43 |
| - * The ASM API version implemented by this visitor. The value of this field |
44 |
| - * must be one of {@link Opcodes#ASM4}. |
45 |
| - */ |
46 |
| - protected final int api; |
| 40 | + /** |
| 41 | + * The ASM API version implemented by this visitor. The value of this field must be one of {@link |
| 42 | + * Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7_EXPERIMENTAL}. |
| 43 | + */ |
| 44 | + protected final int api; |
47 | 45 |
|
48 |
| - /** |
49 |
| - * The annotation visitor to which this visitor must delegate method calls. |
50 |
| - * May be null. |
51 |
| - */ |
52 |
| - protected AnnotationVisitor av; |
| 46 | + /** The annotation visitor to which this visitor must delegate method calls. May be null. */ |
| 47 | + protected AnnotationVisitor av; |
53 | 48 |
|
54 |
| - /** |
55 |
| - * Constructs a new {@link AnnotationVisitor}. |
56 |
| - * |
57 |
| - * @param api |
58 |
| - * the ASM API version implemented by this visitor. Must be one |
59 |
| - * of {@link Opcodes#ASM4}. |
60 |
| - */ |
61 |
| - public AnnotationVisitor(final int api) { |
62 |
| - this(api, null); |
63 |
| - } |
| 49 | + /** |
| 50 | + * Constructs a new {@link AnnotationVisitor}. |
| 51 | + * |
| 52 | + * @param api the ASM API version implemented by this visitor. Must be one of {@link |
| 53 | + * Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link |
| 54 | + * Opcodes#ASM7_EXPERIMENTAL}. |
| 55 | + */ |
| 56 | + public AnnotationVisitor(final int api) { |
| 57 | + this(api, null); |
| 58 | + } |
64 | 59 |
|
65 |
| - /** |
66 |
| - * Constructs a new {@link AnnotationVisitor}. |
67 |
| - * |
68 |
| - * @param api |
69 |
| - * the ASM API version implemented by this visitor. Must be one |
70 |
| - * of {@link Opcodes#ASM4}. |
71 |
| - * @param av |
72 |
| - * the annotation visitor to which this visitor must delegate |
73 |
| - * method calls. May be null. |
74 |
| - */ |
75 |
| - public AnnotationVisitor(final int api, final AnnotationVisitor av) { |
76 |
| - if (api != Opcodes.ASM4) { |
77 |
| - throw new IllegalArgumentException(); |
78 |
| - } |
79 |
| - this.api = api; |
80 |
| - this.av = av; |
| 60 | + /** |
| 61 | + * Constructs a new {@link AnnotationVisitor}. |
| 62 | + * |
| 63 | + * @param api the ASM API version implemented by this visitor. Must be one of {@link |
| 64 | + * Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link |
| 65 | + * Opcodes#ASM7_EXPERIMENTAL}. |
| 66 | + * @param annotationVisitor the annotation visitor to which this visitor must delegate method |
| 67 | + * calls. May be null. |
| 68 | + */ |
| 69 | + public AnnotationVisitor(final int api, final AnnotationVisitor annotationVisitor) { |
| 70 | + if (api != Opcodes.ASM6 |
| 71 | + && api != Opcodes.ASM5 |
| 72 | + && api != Opcodes.ASM4 |
| 73 | + && api != Opcodes.ASM7_EXPERIMENTAL) { |
| 74 | + throw new IllegalArgumentException(); |
81 | 75 | }
|
| 76 | + this.api = api; |
| 77 | + this.av = annotationVisitor; |
| 78 | + } |
82 | 79 |
|
83 |
| - /** |
84 |
| - * Visits a primitive value of the annotation. |
85 |
| - * |
86 |
| - * @param name |
87 |
| - * the value name. |
88 |
| - * @param value |
89 |
| - * the actual value, whose type must be {@link Byte}, |
90 |
| - * {@link Boolean}, {@link Character}, {@link Short}, |
91 |
| - * {@link Integer} , {@link Long}, {@link Float}, {@link Double}, |
92 |
| - * {@link String} or {@link Type} or OBJECT or ARRAY sort. This |
93 |
| - * value can also be an array of byte, boolean, short, char, int, |
94 |
| - * long, float or double values (this is equivalent to using |
95 |
| - * {@link #visitArray visitArray} and visiting each array element |
96 |
| - * in turn, but is more convenient). |
97 |
| - */ |
98 |
| - public void visit(String name, Object value) { |
99 |
| - if (av != null) { |
100 |
| - av.visit(name, value); |
101 |
| - } |
| 80 | + /** |
| 81 | + * Visits a primitive value of the annotation. |
| 82 | + * |
| 83 | + * @param name the value name. |
| 84 | + * @param value the actual value, whose type must be {@link Byte}, {@link Boolean}, {@link |
| 85 | + * Character}, {@link Short}, {@link Integer} , {@link Long}, {@link Float}, {@link Double}, |
| 86 | + * {@link String} or {@link Type} of {@link Type#OBJECT} or {@link Type#ARRAY} sort. This |
| 87 | + * value can also be an array of byte, boolean, short, char, int, long, float or double values |
| 88 | + * (this is equivalent to using {@link #visitArray} and visiting each array element in turn, |
| 89 | + * but is more convenient). |
| 90 | + */ |
| 91 | + public void visit(final String name, final Object value) { |
| 92 | + if (av != null) { |
| 93 | + av.visit(name, value); |
102 | 94 | }
|
| 95 | + } |
103 | 96 |
|
104 |
| - /** |
105 |
| - * Visits an enumeration value of the annotation. |
106 |
| - * |
107 |
| - * @param name |
108 |
| - * the value name. |
109 |
| - * @param desc |
110 |
| - * the class descriptor of the enumeration class. |
111 |
| - * @param value |
112 |
| - * the actual enumeration value. |
113 |
| - */ |
114 |
| - public void visitEnum(String name, String desc, String value) { |
115 |
| - if (av != null) { |
116 |
| - av.visitEnum(name, desc, value); |
117 |
| - } |
| 97 | + /** |
| 98 | + * Visits an enumeration value of the annotation. |
| 99 | + * |
| 100 | + * @param name the value name. |
| 101 | + * @param descriptor the class descriptor of the enumeration class. |
| 102 | + * @param value the actual enumeration value. |
| 103 | + */ |
| 104 | + public void visitEnum(final String name, final String descriptor, final String value) { |
| 105 | + if (av != null) { |
| 106 | + av.visitEnum(name, descriptor, value); |
118 | 107 | }
|
| 108 | + } |
119 | 109 |
|
120 |
| - /** |
121 |
| - * Visits a nested annotation value of the annotation. |
122 |
| - * |
123 |
| - * @param name |
124 |
| - * the value name. |
125 |
| - * @param desc |
126 |
| - * the class descriptor of the nested annotation class. |
127 |
| - * @return a visitor to visit the actual nested annotation value, or |
128 |
| - * <tt>null</tt> if this visitor is not interested in visiting this |
129 |
| - * nested annotation. <i>The nested annotation value must be fully |
130 |
| - * visited before calling other methods on this annotation |
131 |
| - * visitor</i>. |
132 |
| - */ |
133 |
| - public AnnotationVisitor visitAnnotation(String name, String desc) { |
134 |
| - if (av != null) { |
135 |
| - return av.visitAnnotation(name, desc); |
136 |
| - } |
137 |
| - return null; |
| 110 | + /** |
| 111 | + * Visits a nested annotation value of the annotation. |
| 112 | + * |
| 113 | + * @param name the value name. |
| 114 | + * @param descriptor the class descriptor of the nested annotation class. |
| 115 | + * @return a visitor to visit the actual nested annotation value, or <tt>null</tt> if this visitor |
| 116 | + * is not interested in visiting this nested annotation. <i>The nested annotation value must |
| 117 | + * be fully visited before calling other methods on this annotation visitor</i>. |
| 118 | + */ |
| 119 | + public AnnotationVisitor visitAnnotation(final String name, final String descriptor) { |
| 120 | + if (av != null) { |
| 121 | + return av.visitAnnotation(name, descriptor); |
138 | 122 | }
|
| 123 | + return null; |
| 124 | + } |
139 | 125 |
|
140 |
| - /** |
141 |
| - * Visits an array value of the annotation. Note that arrays of primitive |
142 |
| - * types (such as byte, boolean, short, char, int, long, float or double) |
143 |
| - * can be passed as value to {@link #visit visit}. This is what |
144 |
| - * {@link ClassReader} does. |
145 |
| - * |
146 |
| - * @param name |
147 |
| - * the value name. |
148 |
| - * @return a visitor to visit the actual array value elements, or |
149 |
| - * <tt>null</tt> if this visitor is not interested in visiting these |
150 |
| - * values. The 'name' parameters passed to the methods of this |
151 |
| - * visitor are ignored. <i>All the array values must be visited |
152 |
| - * before calling other methods on this annotation visitor</i>. |
153 |
| - */ |
154 |
| - public AnnotationVisitor visitArray(String name) { |
155 |
| - if (av != null) { |
156 |
| - return av.visitArray(name); |
157 |
| - } |
158 |
| - return null; |
| 126 | + /** |
| 127 | + * Visits an array value of the annotation. Note that arrays of primitive types (such as byte, |
| 128 | + * boolean, short, char, int, long, float or double) can be passed as value to {@link #visit |
| 129 | + * visit}. This is what {@link ClassReader} does. |
| 130 | + * |
| 131 | + * @param name the value name. |
| 132 | + * @return a visitor to visit the actual array value elements, or <tt>null</tt> if this visitor is |
| 133 | + * not interested in visiting these values. The 'name' parameters passed to the methods of |
| 134 | + * this visitor are ignored. <i>All the array values must be visited before calling other |
| 135 | + * methods on this annotation visitor</i>. |
| 136 | + */ |
| 137 | + public AnnotationVisitor visitArray(final String name) { |
| 138 | + if (av != null) { |
| 139 | + return av.visitArray(name); |
159 | 140 | }
|
| 141 | + return null; |
| 142 | + } |
160 | 143 |
|
161 |
| - /** |
162 |
| - * Visits the end of the annotation. |
163 |
| - */ |
164 |
| - public void visitEnd() { |
165 |
| - if (av != null) { |
166 |
| - av.visitEnd(); |
167 |
| - } |
| 144 | + /** Visits the end of the annotation. */ |
| 145 | + public void visitEnd() { |
| 146 | + if (av != null) { |
| 147 | + av.visitEnd(); |
168 | 148 | }
|
| 149 | + } |
169 | 150 | }
|
0 commit comments