View Javadoc

1   package org.apache.maven.tools.plugin.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 org.codehaus.plexus.logging.Logger;
23  import org.objectweb.asm.AnnotationVisitor;
24  
25  import java.util.HashMap;
26  import java.util.Map;
27  
28  /**
29   * @author Olivier Lamy
30   * @since 3.0
31   */
32  public class MojoAnnotationVisitor
33      implements AnnotationVisitor
34  {
35      private Logger logger;
36  
37      private String annotationClassName;
38  
39      private Map<String, Object> annotationValues = new HashMap<String, Object>();
40  
41      MojoAnnotationVisitor( Logger logger, String annotationClassName )
42      {
43          this.logger = logger;
44          this.annotationClassName = annotationClassName;
45      }
46  
47      public Map<String, Object> getAnnotationValues()
48      {
49          return annotationValues;
50      }
51  
52      public void visit( String name, Object value )
53      {
54          annotationValues.put( name, value );
55          logger.debug( "MojoAnnotationVisitor#visit:" + name + ":" + value );
56      }
57  
58      public void visitEnum( String name, String desc, String value )
59      {
60          annotationValues.put( name, value );
61          logger.debug( "MojoAnnotationVisitor#visitEnum:" + name + ":" + desc + ":" + value );
62      }
63  
64      public AnnotationVisitor visitAnnotation( String name, String desc )
65      {
66          logger.debug( "MojoAnnotationVisitor#visitAnnotation:" + name + ":" + desc );
67          return new MojoAnnotationVisitor( logger, this.annotationClassName );
68      }
69  
70      public AnnotationVisitor visitArray( String s )
71      {
72          logger.debug( "MojoAnnotationVisitor#visitArray" );
73          return new MojoAnnotationVisitor( logger, this.annotationClassName );
74      }
75  
76      public void visitEnd()
77      {
78          // no op
79      }
80  
81      public String getAnnotationClassName()
82      {
83          return annotationClassName;
84      }
85  }