KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > spi > persistence > utility > generator > JavaClassWriter


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * JavaClassWriter.java
26  *
27  * Created on November 9, 2001, 2:27 PM
28  */

29
30 package com.sun.jdo.spi.persistence.utility.generator;
31
32 import java.io.IOException JavaDoc;
33 import java.lang.reflect.Modifier JavaDoc;
34
35 /**
36  * This interface can be used to describe a java class -- either
37  * top level or inner. The resulting class definition
38  * can be viewed by calling {@link java.lang.Object#toString}, but the entire
39  * source definition is only available when used with a JavaFileWriter.
40  * <p>
41  * The order of the generated code is up to the implementation. For
42  * example, one implementation may accept fields and methods in any
43  * order and generate all fields together and all methods together, but
44  * maintain the order within the list of fields and methods. Another
45  * implementation may take the same input and generate fields and
46  * methods interspersed among each other in exactly the order they were
47  * added. Still another implementation may make no guarantee as to the
48  * order of members at all.
49  *
50  * @author raccah
51  */

52 public interface JavaClassWriter
53 {
54     /** Sets the information for the class declaration including modifiers,
55      * name, and comments. Note that the name must not be fully qualified.
56      * @param modifiers The modifier flags for this class.
57      * @param className The (non-qualified) name of this class.
58      * @param comments The comments shown just above the class declaration.
59      * The comments are passed as an array so the line separators can be added
60      * by the implementation. Note that not all implementations will choose
61      * to make use of this comment.
62      * @throws IOException If the class declaration information cannot be set.
63      * @see java.lang.reflect.Modifier
64      */

65     public void setClassDeclaration (int modifiers, String JavaDoc className,
66         String JavaDoc[] comments) throws IOException JavaDoc;
67
68     /** Sets the superclass of this class. Note that the name format must
69      * be package style (that is - it can contain . but not / or $).
70      * @param name The name of the superclass.
71      * @throws IOException If the superclass cannot be set.
72      */

73     public void setSuperclass (String JavaDoc name) throws IOException JavaDoc;
74
75     /** Adds an interface to the list of those implemented by this class.
76      * @param name The name of the interface.
77      * @throws IOException If the interface cannot be added.
78      */

79     public void addInterface (String JavaDoc name) throws IOException JavaDoc;
80
81     /** Adds a field to the list of those declared by this class. Note
82      * that the type format must be package style (that is - it can contain
83      * . but not / or $).
84      * @param name The name of the field.
85      * @param modifiers The modifier flags for this field.
86      * @param type A string representing the type of this field.
87      * @param initialValue A string representing the initial value of
88      * this field.
89      * @param comments The comments shown just above the declaration of
90      * this field. The comments are passed as an array so the line
91      * separators can be added by the implementation. Note that not all
92      * implementations will choose to make use of this comment.
93      * @throws IOException If the field information cannot be added.
94      * @see java.lang.reflect.Modifier
95      */

96     public void addField (String JavaDoc name, int modifiers, String JavaDoc type,
97         String JavaDoc initialValue, String JavaDoc[] comments) throws IOException JavaDoc;
98
99     /** Adds an initializer to this class.
100      * @param isStatic True if this is a static initializer, false otherwise.
101      * @param body The implementation block of the initializer. The body of
102      * the implementation is passed as an array so the line separators can
103      * be added by the implementation.
104      * @param comments The comments shown just above the initializer block.
105      * The comments are passed as an array so the line separators can be added
106      * by the implementation. Note that not all implementations will choose
107      * to make use of this comment.
108      * @throws IOException If the initializer information cannot be added.
109      */

110     public void addInitializer (boolean isStatic, String JavaDoc[] body,
111         String JavaDoc[] comments) throws IOException JavaDoc;
112
113     /** Adds a constructor to this class. Note that the type format in the
114      * parameter type strings must be package style (that is - it can contain
115      * . but not / or $).
116      * @param name The name of the constructor - should be the same as the
117      * name of the class.
118      * @param modifiers The modifier flags for this constructor.
119      * @param parameterNames A list of parameter names.
120      * @param parameterTypes A list of parameter types.
121      * @param exceptions A list of exceptions.
122      * @param body The implementation block of the constructor. The body of
123      * the implementation is passed as an array so the line separators can
124      * be added by the implementation.
125      * @param comments The comments shown just above the constructor. The
126      * comments are passed as an array so the line separators can be added
127      * by the implementation. Note that not all implementations will choose
128      * to make use of this comment.
129      * @throws IOException If the constructor information cannot be added.
130      * @see java.lang.reflect.Modifier
131      */

132     public void addConstructor (String JavaDoc name, int modifiers,
133         String JavaDoc[] parameterNames, String JavaDoc[] parameterTypes, String JavaDoc[] exceptions,
134         String JavaDoc[] body, String JavaDoc[] comments) throws IOException JavaDoc;
135
136     /** Adds a method to this class. Note that the type format in the
137      * return type and parameter type strings must be package style
138      * (that is - it can contain . but not / or $).
139      * @param name The name of the method.
140      * @param modifiers The modifier flags for this method.
141      * @param returnType A string representing the return type of this method.
142      * @param parameterNames A list of parameter names.
143      * @param parameterTypes A list of parameter types.
144      * @param exceptions A list of exceptions.
145      * @param body The implementation block of the method. The body of
146      * the implementation is passed as an array so the line separators can
147      * be added by the implementation.
148      * @param comments The comments shown just above the method. The
149      * comments are passed as an array so the line separators can be added
150      * by the implementation. Note that not all implementations will choose
151      * to make use of this comment.
152      * @throws IOException If the method information cannot be added.
153      * @see java.lang.reflect.Modifier
154      */

155     public void addMethod (String JavaDoc name, int modifiers, String JavaDoc returnType,
156         String JavaDoc[] parameterNames, String JavaDoc[] parameterTypes, String JavaDoc[] exceptions,
157         String JavaDoc[] body, String JavaDoc[] comments) throws IOException JavaDoc;
158
159     /** Adds an inner class to this class.
160      * @param classWriter The definition of the inner class.
161      * @throws IOException If the class information cannot be added.
162      */

163     public void addClass (JavaClassWriter classWriter) throws IOException JavaDoc;
164 }
165
Popular Tags