KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > ElementFactory


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.java;
21
22 import org.openide.src.*;
23
24 /** Builder interface for creating parse results.
25  * This inteface allows a parser engine to create some items of implementation
26  * unknown to the engine. The engine is provided with opaque Item reference
27  * and can communicate with the factory using those references.
28  * The ElementFactory is focused on creating and connecting Java Source
29  * elements and provides the only way how to access JavaLoader's internals from
30  * the parser engine.
31  */

32 public interface ElementFactory {
33     /* ======================= Item creator methods ========================== */
34     
35     /** Creates a new class element.
36     @param isInterface true if the element should in fact correspond to an interface rather than to a class.
37     @param modifiers union of Modifier.* values composing access and other modifiers for the element.
38     @param superclass Identifier of superclass, or null if there isn't any.
39     @param interfaces all interfaces implemented on this class.
40     */

41     public Item createClass(boolean isInterface, int modifiers, Identifier name, Identifier superclass, Identifier[] interfaces);
42     
43     /** Creates an element for a method.
44     @param modifiers Modifiers for the method.
45     @param name name of the method
46     @param returnType return type for the method.
47     @param params array of parameters for the method.
48     @param exceptions array of exceptions declared to be thrown from the method.
49     */

50     public Item createMethod(int modifiers, Identifier name, Type returnType, MethodParameter[] params, Identifier[] exceptions);
51     
52     /** Creates an element for a field.
53     @param modifiers Modifiers for the field element
54     @param name Field's name
55     @param type Field's type
56     @param initializer Initial value for the field (with equal sign excluded) or null if the field is not initialized.
57     */

58     public Item createField(int modifiers, Identifier name, Type type, String JavaDoc initializer);
59     
60     /** Creates an element for a constructor.
61     For parameters see {@link #createMethod}
62     */

63     public Item createConstructor(int modifiers, Identifier id, MethodParameter[] params, Identifier[] exceptions);
64     
65     /** Creates an element for an initializer.
66     @param modifiers Modifiers for the initializer.
67     */

68     public Item createInitializer(int modifiers);
69     
70     /** Creates data for import statement found in the source file.
71     @param im Import object that is declared in the source.
72     @param begin offset of the import statement start (position of `import' keyword)
73     @param end offset of the end of the import statement (after semicolon)
74     */

75     public void createImport(Import im, int begin, int end);
76     
77     /** Creates data for package declaration found in the source.
78     @param name name of the declared package
79     @param begin character index of the package declarator start
80     @param end character index of the package decalarator end (after the semicolon)
81     */

82     public void createPackage(Identifier name, int begin, int end);
83     
84     /** Binds two Items together in a parent-child relationship.
85     @param child Child item to be inserted into the parent
86     @param parent Parent item
87     */

88     public void setParent(Item child, Item parent);
89     
90     /** Sets bounds for the whole element. Begin is offset of first character of the element,
91     end is the offset of the last one.
92     */

93     public void setBounds(Item item, int begin, int end);
94
95     /** Sets bounds for the body of the element.
96     */

97     public void setBodyBounds(Item item, int begin, int end);
98
99     public void setHeaderBounds(Item item, int begin, int end);
100
101     /** Sets a documentation for the element.
102     @param begin offset of doc comment start
103     @param end offset of doc comment end
104     @param text documentation comment content
105     */

106     public void setDocumentation(Item item, int begin, int end, String JavaDoc text);
107     
108     /** Sets name of the field that precedes this one in a declaration statement.
109     */

110     public void setPrecedingField(Item item, Item previous);
111
112     /** Sets bounds for the identifier only.
113     */

114     public void setFieldTypeBounds(Item item, int begin, int end);
115     
116     public void markError(Item item);
117
118     /** Only marker interface
119     */

120     public interface Item {
121     }
122 }
123
Popular Tags