View Javadoc

1    /****************************************************************************
2    * Copyright (c) 2005, 2006, 2007, 2008, 2009 Imola Informatica.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the LGPL License v2.1
5    * which accompanies this distribution, and is available at
6    * http://www.gnu.org/licenses/lgpl.html
7    ****************************************************************************/
8   package it.imolinfo.jbi4corba.webservice.generator.bcm;
9   
10  import java.util.ArrayList;
11  import java.util.List;
12  
13  import it.imolinfo.jbi4corba.Logger;
14  import it.imolinfo.jbi4corba.LoggerFactory;
15  
16  import org.objectweb.asm.AnnotationVisitor;
17  import org.objectweb.asm.commons.EmptyVisitor;
18  
19  /**
20   * XXX javadoc.
21   */
22  public class AnnotationCollectorVisitor extends EmptyVisitor {
23  
24    /**
25     * Logger.
26     */
27    private static final Logger LOG = LoggerFactory.getLogger(
28      AnnotationCollectorVisitor.class);
29  
30    
31    /**
32     * XXX javadoc.
33     */
34    public List<AnnotationValue> list = new ArrayList<AnnotationValue>();
35  
36    /**
37     * Default constructor.
38     */
39    public AnnotationCollectorVisitor (){
40    }
41    
42    /**
43     * @param name   The name
44     * @param value  The value
45     */
46      @Override
47    public void visit(String name, Object value) {
48      LOG.debug("AnnotationCollectorVisitor.visit(String, Object)."
49        + "name=" + name + "; value=" + value);
50  
51      AnnotationValue av = new AnnotationValue(AnnotationValue.ANNOTATION_VISIT);
52  
53      av.name  = name;
54      av.value = value;
55  
56      list.add(av);
57  
58      super.visit(name, value);
59    }
60  
61    /**
62     * @param name  The name
63     * @param desc  The description
64     * @return      The return
65     */
66      @Override
67    public AnnotationVisitor visitAnnotation(String name, String desc) {
68      LOG.debug("AnnotationCollectorVisitor.visitAnnotation(String, String)."
69        + "name=" + name + "; desc=" + desc);
70  
71      AnnotationValue av = new AnnotationValue(
72        AnnotationValue.ANNOTATION_VISIT_ANNOTATION);
73  
74      av.name = name;
75      av.desc = desc;
76  
77      list.add(av);
78  
79      AnnotationCollectorVisitor annotationCollectorVisitor
80        = new AnnotationCollectorVisitor();
81  
82      av.nestedAnnotationValue = annotationCollectorVisitor.list;
83      LOG.debug("AnnotationValue." + av);
84  
85      return annotationCollectorVisitor;
86    }
87  
88    /**
89     * @param name The name
90     * @return     The return
91     */
92    @Override
93    public AnnotationVisitor visitArray(String name) {
94      LOG.debug("AnnotationCollectorVisitor.visitArray(String)."
95        + "name=" + name);
96  
97      AnnotationValue av = new AnnotationValue(
98        AnnotationValue.ANNOTATION_VISIT_ARRAY);
99  
100     av.name  = name;
101 
102     list.add(av);
103 
104     AnnotationCollectorVisitor annotationCollectorVisitor
105       = new AnnotationCollectorVisitor();
106 
107     av.nestedAnnotationValue = annotationCollectorVisitor.list;
108     LOG.debug("AnnotationValue." + av);
109 
110     return annotationCollectorVisitor;
111   }
112 
113   /**
114    * @param name   The name
115    * @param desc   The description
116    * @param value  The value
117    */
118     @Override
119   public void visitEnum(String name, String desc, String value) {
120     LOG.debug("AnnotationCollectorVisitor.visitEnum(String,String,String)."
121       + "name=" + name + "; desc=" + desc + "; value=" + value);
122 
123     AnnotationValue av = new AnnotationValue(
124       AnnotationValue.ANNOTATION_VISIT_ENUM);
125 
126     av.name  = name;
127     av.desc  = desc;
128     av.value = value;
129 
130     list.add(av);
131 
132     super.visitEnum(name, desc, value);
133   }
134 
135 }