KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > bridge > Binding


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.bridge;
21
22 import java.util.*;
23
24 import org.openide.src.*;
25
26 /**
27  * The Binding (sub-)classes give individual model elements the I/O capabilities (e.g.
28  * a Document or a Stream). Each element is, in fact, a composite of the element itself
29  * and the I/O binding of that element. All model change operations are transformed into
30  * simpler calls on the binding objects.
31  *
32  * @author sdedic
33  * @version 0.1
34  */

35 public interface Binding {
36
37     /** Binds any MemberElement to the underlying text.
38      */

39     public interface Member extends Binding {
40         /**
41          * Requests change of member's modifiers.
42          */

43         public void changeModifiers(int newMods) throws SourceException;
44         
45         /**
46          * Requests a change of member's name.
47          */

48         public void changeName(Identifier name) throws SourceException;
49     }
50     
51     public interface Body {
52         public String JavaDoc getBodyContent() throws SourceException;
53         public void changeBody(String JavaDoc bodyString) throws SourceException;
54         public void copyBody(String JavaDoc bodyString);
55     }
56
57     /** Binds an initializer to the source.
58      */

59     public interface Initializer extends Binding, Body {
60         /**
61          * Changes static <-> nonstatic
62          */

63         public void changeStatic(boolean enable) throws SourceException;
64     }
65     
66     public interface Field extends Member {
67         /** Changes the declared type of the field.
68          */

69         public void changeType(Type newType) throws SourceException;
70         
71         /** Changes contents of the initializer of the field.
72          */

73         public void changeInitializer(String JavaDoc newInitializer) throws SourceException;
74     }
75
76     /** Binds a method, or a constructor to the source.
77      */

78     public interface Method extends Member, Body {
79         /** Retrieves the text of the body.
80          */

81         public String JavaDoc getBodyContent() throws SourceException;
82
83         /** Makes the method abstract. The implementation should erase the current
84          * body definition and replace it with an abstract tag (; in the source representation)
85          */

86         public void makeAbstract() throws SourceException;
87         
88         /** Create a nonabstract body containing the passed text.
89          */

90          public void createBody(String JavaDoc bodyText) throws SourceException;
91          
92         /** Changes the return type declaration.
93          */

94         public void changeReturnType(Type type) throws SourceException;
95         
96         /** Changes parameter list for the method.
97          */

98         public void changeParameters(MethodParameter[] params) throws SourceException;
99         
100         /** Changes exception list for the method.
101          */

102         public void changeExceptions(Identifier[] exceptions) throws SourceException;
103     }
104     
105     /** Container interface that manages contained bindings. Currently only reorder operation
106      * is supported.
107      */

108     public interface Container {
109         /**
110          * Initializes a new binding for the element so the element is stored after the
111          * `previous' binding, if that matters to the binding implementation.
112          * @param toInitialize the binding that is being initialized & bound to the storage.
113          * @param previous marker spot, the binding that should precede the new one.
114          */

115         public void insert(Binding toInitialize, Binding previous) throws SourceException;
116         
117         /** Replaces the slot contents with another element (different type permitted ?)
118          */

119         public void replace(Binding oldBinding, Binding newBinding) throws SourceException;
120         
121         /** The map contains mapping from target places to their new contents.
122          */

123         public void reorder(Map fromToMap) throws SourceException;
124         
125         /** Determines, if the executing code is allowed to insert after the specified
126          * binding.
127          */

128         public boolean canInsertAfter(Binding b);
129
130         /**
131          * Changes container's contents as one operation, given the information in
132          * the event object.
133          */

134         public void changeMembers(MultiPropertyChangeEvent evt) throws SourceException;
135     }
136     
137     public interface Class extends Member, Container {
138         /**
139          * Changes the superclass' name.
140          */

141         public void changeSuperclass(Identifier id) throws SourceException;
142      
143         /** Rewrites some interfaces from class' implements property.
144          */

145         public void changeInterfaces(Identifier[] replaceWith) throws SourceException;
146
147         /** Changes class into an interface and vice-versa. Although classes and interfaces
148          * are clearly separated in the language specs, they represent the same concept with
149          * some minor differencies.
150          */

151         public void changeClassType(boolean properClass) throws SourceException;
152     }
153     
154     public interface Import extends Binding {
155         public void changeImport(org.openide.src.Import i) throws SourceException;
156     }
157     
158     public interface Source extends Binding {
159         public void changePackage(Identifier id) throws SourceException;
160         public Binding.Container getImportsSection();
161         public Binding.Container getClassSection();
162     }
163     
164     public void changeJavaDoc(JavaDoc content) throws SourceException;
165 }
166
167
Popular Tags