View Javadoc
1   /*
2    * Copyright 2005 Werner Guttmann
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.exolab.castor.builder;
17  
18  import org.exolab.castor.builder.info.ClassInfo;
19  import org.exolab.castor.builder.info.FieldInfo;
20  import org.exolab.castor.xml.schema.Facet;
21  import org.exolab.castor.xml.schema.SimpleType;
22  import org.exolab.javasource.JClass;
23  import org.exolab.javasource.JEnum;
24  import org.exolab.javasource.JEnumConstant;
25  import org.exolab.javasource.JField;
26  import org.exolab.javasource.JMethod;
27  
28  /**
29   * This interface is a hook for (external) tools to add annotations to
30   * classes, fields and enums during the XML code generation process.
31   * 
32   * Custom implementations of {@link AnnotationBuilder} instances can be 
33   * added to a code generation execution using 
34   * {@link SourceGenerator#addAnnotationBuilder(AnnotationBuilder)} 
35   * 
36   * @since 1.1.3
37   */
38  public interface AnnotationBuilder {
39  
40      /**
41       * add annotations to a JClass.
42       * @param classInfo the classInfo
43       * @param jClass the jClass
44       */
45      void addClassAnnotations(ClassInfo classInfo, JClass jClass);
46      
47      /**
48       * add annotation to a property definition.
49       * @param fieldInfo the fieldInfo
50       * @param field the jField
51       */
52      void addFieldAnnotations(FieldInfo fieldInfo, JField field);
53      
54      /**
55       * add annotations to a getter of a property.
56       * @param fieldInfo the fieldInfo 
57       * @param method the getter method
58       */
59      void addFieldGetterAnnotations(FieldInfo fieldInfo, JMethod method);
60      
61      /**
62       * add annotations to a java5 enum.
63       * @param simpleType the corresponding simpleType
64       * @param jEnums the jEnum
65       */
66      void addEnumAnnotations(SimpleType simpleType, JEnum jEnums);
67      
68      /**
69       * add annotations to a java5 enum constant.
70       * @param facet the corresponding facet
71       * @param enumConstant the jEnumConstant
72       */
73      void addEnumConstantAnnotations(Facet facet, JEnumConstant enumConstant);
74  
75  }