View Javadoc
1   package org.apache.maven.tools.plugin.extractor.annotations.scanner.visitors;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.HashMap;
23  import java.util.Map;
24  
25  import org.codehaus.plexus.logging.Logger;
26  import org.objectweb.asm.AnnotationVisitor;
27  import org.objectweb.asm.Opcodes;
28  
29  /**
30   * @author Olivier Lamy
31   * @since 3.0
32   */
33  public class MojoAnnotationVisitor
34      extends AnnotationVisitor
35  {
36      private Logger logger;
37  
38      private String annotationClassName;
39  
40      private Map<String, Object> annotationValues = new HashMap<String, Object>();
41  
42      MojoAnnotationVisitor( Logger logger, String annotationClassName )
43      {
44          super( Opcodes.ASM5 );
45          this.logger = logger;
46          this.annotationClassName = annotationClassName;
47      }
48  
49      public Map<String, Object> getAnnotationValues()
50      {
51          return annotationValues;
52      }
53  
54      public void visit( String name, Object value )
55      {
56          annotationValues.put( name, value );
57      }
58  
59      public void visitEnum( String name, String desc, String value )
60      {
61          annotationValues.put( name, value );
62      }
63  
64      public AnnotationVisitor visitAnnotation( String name, String desc )
65      {
66          return new MojoAnnotationVisitor( logger, this.annotationClassName );
67      }
68  
69      public AnnotationVisitor visitArray( String s )
70      {
71          return new MojoAnnotationVisitor( logger, this.annotationClassName );
72      }
73  
74      public void visitEnd()
75      {
76          // no op
77      }
78  
79      public String getAnnotationClassName()
80      {
81          return annotationClassName;
82      }
83  }