KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > source > tree > Tree


1 /*
2  * @(#)Tree.java 1.8 06/08/03
3  *
4  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  *
7  * Use and Distribution is subject to the Java Research License available
8  * at <http://wwws.sun.com/software/communitysource/jrl.html>.
9  */

10
11 package com.sun.source.tree;
12
13 /**
14  * Common interface for all nodes in an abstract syntax tree.
15  *
16  * <p><b>WARNING:</b> This interface and its sub-interfaces are
17  * subject to change as the Java&trade; programming language evolves.
18  * These interfaces are implemented by Sun's Java compiler (javac)
19  * and should not be implemented either directly or indirectly by
20  * other applications.
21  *
22  * @author Peter von der Ah&eacute;
23  * @author Jonathan Gibbons
24  *
25  * @since 1.6
26  */

27 public interface Tree {
28     
29     /**
30      * Enumerates all kinds of trees.
31      */

32     public enum Kind {
33         /**
34          * Used for instances of {@link AnnotationTree}.
35          */

36         ANNOTATION(AnnotationTree.class),
37
38         /**
39          * Used for instances of {@link ArrayAccessTree}.
40          */

41         ARRAY_ACCESS(ArrayAccessTree.class),
42
43         /**
44          * Used for instances of {@link ArrayTypeTree}.
45          */

46         ARRAY_TYPE(ArrayTypeTree.class),
47
48         /**
49          * Used for instances of {@link AssertTree}.
50          */

51         ASSERT(AssertTree.class),
52
53         /**
54          * Used for instances of {@link AssignmentTree}.
55          */

56         ASSIGNMENT(AssignmentTree.class),
57
58         /**
59          * Used for instances of {@link BlockTree}.
60          */

61         BLOCK(BlockTree.class),
62
63         /**
64          * Used for instances of {@link BreakTree}.
65          */

66         BREAK(BreakTree.class),
67
68         /**
69          * Used for instances of {@link CaseTree}.
70          */

71         CASE(CaseTree.class),
72
73         /**
74          * Used for instances of {@link CatchTree}.
75          */

76         CATCH(CatchTree.class),
77
78         /**
79          * Used for instances of {@link ClassTree}.
80          */

81         CLASS(ClassTree.class),
82
83         /**
84          * Used for instances of {@link CompilationUnitTree}.
85          */

86         COMPILATION_UNIT(CompilationUnitTree.class),
87
88         /**
89          * Used for instances of {@link ConditionalExpressionTree}.
90          */

91         CONDITIONAL_EXPRESSION(ConditionalExpressionTree.class),
92
93         /**
94          * Used for instances of {@link ContinueTree}.
95          */

96         CONTINUE(ContinueTree.class),
97
98         /**
99          * Used for instances of {@link DoWhileLoopTree}.
100          */

101         DO_WHILE_LOOP(DoWhileLoopTree.class),
102
103         /**
104          * Used for instances of {@link EnhancedForLoopTree}.
105          */

106         ENHANCED_FOR_LOOP(EnhancedForLoopTree.class),
107
108         /**
109          * Used for instances of {@link ExpressionStatementTree}.
110          */

111         EXPRESSION_STATEMENT(ExpressionStatementTree.class),
112
113         /**
114          * Used for instances of {@link MemberSelectTree}.
115          */

116         MEMBER_SELECT(MemberSelectTree.class),
117
118         /**
119          * Used for instances of {@link ForLoopTree}.
120          */

121         FOR_LOOP(ForLoopTree.class),
122
123         /**
124          * Used for instances of {@link IdentifierTree}.
125          */

126         IDENTIFIER(IdentifierTree.class),
127
128         /**
129          * Used for instances of {@link IfTree}.
130          */

131         IF(IfTree.class),
132
133         /**
134          * Used for instances of {@link ImportTree}.
135          */

136         IMPORT(ImportTree.class),
137
138         /**
139          * Used for instances of {@link InstanceOfTree}.
140          */

141         INSTANCE_OF(InstanceOfTree.class),
142
143         /**
144          * Used for instances of {@link LabeledStatementTree}.
145          */

146         LABELED_STATEMENT(LabeledStatementTree.class),
147
148         /**
149          * Used for instances of {@link MethodTree}.
150          */

151         METHOD(MethodTree.class),
152
153         /**
154          * Used for instances of {@link MethodInvocationTree}.
155          */

156         METHOD_INVOCATION(MethodInvocationTree.class),
157
158         /**
159          * Used for instances of {@link ModifiersTree}.
160          */

161         MODIFIERS(ModifiersTree.class),
162
163         /**
164          * Used for instances of {@link NewArrayTree}.
165          */

166         NEW_ARRAY(NewArrayTree.class),
167
168         /**
169          * Used for instances of {@link NewClassTree}.
170          */

171         NEW_CLASS(NewClassTree.class),
172
173         /**
174          * Used for instances of {@link ParenthesizedTree}.
175          */

176         PARENTHESIZED(ParenthesizedTree.class),
177
178         /**
179          * Used for instances of {@link PrimitiveTypeTree}.
180          */

181         PRIMITIVE_TYPE(PrimitiveTypeTree.class),
182
183         /**
184          * Used for instances of {@link ReturnTree}.
185          */

186         RETURN(ReturnTree.class),
187
188         /**
189          * Used for instances of {@link EmptyStatementTree}.
190          */

191         EMPTY_STATEMENT(EmptyStatementTree.class),
192
193         /**
194          * Used for instances of {@link SwitchTree}.
195          */

196         SWITCH(SwitchTree.class),
197
198         /**
199          * Used for instances of {@link SynchronizedTree}.
200          */

201         SYNCHRONIZED(SynchronizedTree.class),
202
203         /**
204          * Used for instances of {@link ThrowTree}.
205          */

206         THROW(ThrowTree.class),
207
208         /**
209          * Used for instances of {@link TryTree}.
210          */

211         TRY(TryTree.class),
212
213         /**
214          * Used for instances of {@link ParameterizedTypeTree}.
215          */

216         PARAMETERIZED_TYPE(ParameterizedTypeTree.class),
217
218         /**
219          * Used for instances of {@link TypeCastTree}.
220          */

221         TYPE_CAST(TypeCastTree.class),
222
223         /**
224          * Used for instances of {@link TypeParameterTree}.
225          */

226         TYPE_PARAMETER(TypeParameterTree.class),
227
228         /**
229          * Used for instances of {@link VariableTree}.
230          */

231         VARIABLE(VariableTree.class),
232
233         /**
234          * Used for instances of {@link WhileLoopTree}.
235          */

236         WHILE_LOOP(WhileLoopTree.class),
237
238         /**
239          * Used for instances of {@link UnaryTree} representing postfix
240          * increment operator {@code ++}.
241          */

242         POSTFIX_INCREMENT(UnaryTree.class),
243
244         /**
245          * Used for instances of {@link UnaryTree} representing postfix
246          * decrement operator {@code --}.
247          */

248         POSTFIX_DECREMENT(UnaryTree.class),
249
250         /**
251          * Used for instances of {@link UnaryTree} representing prefix
252          * increment operator {@code ++}.
253          */

254         PREFIX_INCREMENT(UnaryTree.class),
255
256         /**
257          * Used for instances of {@link UnaryTree} representing prefix
258          * decrement operator {@code --}.
259          */

260         PREFIX_DECREMENT(UnaryTree.class),
261
262         /**
263          * Used for instances of {@link UnaryTree} representing unary plus
264          * operator {@code +}.
265          */

266         UNARY_PLUS(UnaryTree.class),
267
268         /**
269          * Used for instances of {@link UnaryTree} representing unary minus
270          * operator {@code -}.
271          */

272         UNARY_MINUS(UnaryTree.class),
273
274         /**
275          * Used for instances of {@link UnaryTree} representing bitwise
276          * complement operator {@code ~}.
277          */

278         BITWISE_COMPLEMENT(UnaryTree.class),
279
280         /**
281          * Used for instances of {@link UnaryTree} representing logical
282          * complement operator {@code !}.
283          */

284         LOGICAL_COMPLEMENT(UnaryTree.class),
285
286         /**
287          * Used for instances of {@link BinaryTree} representing
288          * multiplication {@code *}.
289          */

290         MULTIPLY(BinaryTree.class),
291
292         /**
293          * Used for instances of {@link BinaryTree} representing
294          * division {@code /}.
295          */

296         DIVIDE(BinaryTree.class),
297
298         /**
299          * Used for instances of {@link BinaryTree} representing
300          * remainder {@code %}.
301          */

302         REMAINDER(BinaryTree.class),
303
304         /**
305          * Used for instances of {@link BinaryTree} representing
306          * addition or string concatenation {@code +}.
307          */

308         PLUS(BinaryTree.class),
309
310         /**
311          * Used for instances of {@link BinaryTree} representing
312          * subtraction {@code -}.
313          */

314         MINUS(BinaryTree.class),
315
316         /**
317          * Used for instances of {@link BinaryTree} representing
318          * left shift {@code <<}.
319          */

320         LEFT_SHIFT(BinaryTree.class),
321
322         /**
323          * Used for instances of {@link BinaryTree} representing
324          * right shift {@code >>}.
325          */

326         RIGHT_SHIFT(BinaryTree.class),
327
328         /**
329          * Used for instances of {@link BinaryTree} representing
330          * unsigned right shift {@code >>>}.
331          */

332         UNSIGNED_RIGHT_SHIFT(BinaryTree.class),
333
334         /**
335          * Used for instances of {@link BinaryTree} representing
336          * less-than {@code <}.
337          */

338         LESS_THAN(BinaryTree.class),
339
340         /**
341          * Used for instances of {@link BinaryTree} representing
342          * greater-than {@code >}.
343          */

344         GREATER_THAN(BinaryTree.class),
345
346         /**
347          * Used for instances of {@link BinaryTree} representing
348          * less-than-equal {@code <=}.
349          */

350         LESS_THAN_EQUAL(BinaryTree.class),
351
352         /**
353          * Used for instances of {@link BinaryTree} representing
354          * greater-than-equal {@code >=}.
355          */

356         GREATER_THAN_EQUAL(BinaryTree.class),
357
358         /**
359          * Used for instances of {@link BinaryTree} representing
360          * equal-to {@code ==}.
361          */

362         EQUAL_TO(BinaryTree.class),
363
364         /**
365          * Used for instances of {@link BinaryTree} representing
366          * not-equal-to {@code !=}.
367          */

368         NOT_EQUAL_TO(BinaryTree.class),
369
370         /**
371          * Used for instances of {@link BinaryTree} representing
372          * bitwise and logical "and" {@code &}.
373          */

374         AND(BinaryTree.class),
375
376         /**
377          * Used for instances of {@link BinaryTree} representing
378          * bitwise and logical "xor" {@code ^}.
379          */

380         XOR(BinaryTree.class),
381
382         /**
383          * Used for instances of {@link BinaryTree} representing
384          * bitwise and logical "or" {@code |}.
385          */

386         OR(BinaryTree.class),
387
388         /**
389          * Used for instances of {@link BinaryTree} representing
390          * conditional-and {@code &&}.
391          */

392         CONDITIONAL_AND(BinaryTree.class),
393
394         /**
395          * Used for instances of {@link BinaryTree} representing
396          * conditional-or {@code ||}.
397          */

398         CONDITIONAL_OR(BinaryTree.class),
399
400         /**
401          * Used for instances of {@link CompoundAssignmentTree} representing
402          * multiplication assignment {@code *=}.
403          */

404         MULTIPLY_ASSIGNMENT(CompoundAssignmentTree.class),
405
406         /**
407          * Used for instances of {@link CompoundAssignmentTree} representing
408          * division assignment {@code /=}.
409          */

410         DIVIDE_ASSIGNMENT(CompoundAssignmentTree.class),
411
412         /**
413          * Used for instances of {@link CompoundAssignmentTree} representing
414          * remainder assignment {@code %=}.
415          */

416         REMAINDER_ASSIGNMENT(CompoundAssignmentTree.class),
417
418         /**
419          * Used for instances of {@link CompoundAssignmentTree} representing
420          * addition or string concatenation assignment {@code +=}.
421          */

422         PLUS_ASSIGNMENT(CompoundAssignmentTree.class),
423
424         /**
425          * Used for instances of {@link CompoundAssignmentTree} representing
426          * subtraction assignment {@code -=}.
427          */

428         MINUS_ASSIGNMENT(CompoundAssignmentTree.class),
429
430         /**
431          * Used for instances of {@link CompoundAssignmentTree} representing
432          * left shift assignment {@code <<=}.
433          */

434         LEFT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
435
436         /**
437          * Used for instances of {@link CompoundAssignmentTree} representing
438          * right shift assignment {@code >>=}.
439          */

440         RIGHT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
441
442         /**
443          * Used for instances of {@link CompoundAssignmentTree} representing
444          * unsigned right shift assignment {@code >>>=}.
445          */

446         UNSIGNED_RIGHT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
447
448         /**
449          * Used for instances of {@link CompoundAssignmentTree} representing
450          * bitwise and logical "and" assignment {@code &=}.
451          */

452         AND_ASSIGNMENT(CompoundAssignmentTree.class),
453
454         /**
455          * Used for instances of {@link CompoundAssignmentTree} representing
456          * bitwise and logical "xor" assignment {@code ^=}.
457          */

458         XOR_ASSIGNMENT(CompoundAssignmentTree.class),
459
460         /**
461          * Used for instances of {@link CompoundAssignmentTree} representing
462          * bitwise and logical "or" assignment {@code |=}.
463          */

464         OR_ASSIGNMENT(CompoundAssignmentTree.class),
465
466         /**
467          * Used for instances of {@link LiteralTree} representing
468          * an integral literal expression of type {@code int}.
469          */

470         INT_LITERAL(LiteralTree.class),
471
472         /**
473          * Used for instances of {@link LiteralTree} representing
474          * an integral literal expression of type {@code long}.
475          */

476         LONG_LITERAL(LiteralTree.class),
477
478         /**
479          * Used for instances of {@link LiteralTree} representing
480          * a floating-point literal expression of type {@code float}.
481          */

482         FLOAT_LITERAL(LiteralTree.class),
483
484         /**
485          * Used for instances of {@link LiteralTree} representing
486          * a floating-point literal expression of type {@code double}.
487          */

488         DOUBLE_LITERAL(LiteralTree.class),
489
490         /**
491          * Used for instances of {@link LiteralTree} representing
492          * a boolean literal expression of type {@code boolean}.
493          */

494         BOOLEAN_LITERAL(LiteralTree.class),
495
496         /**
497          * Used for instances of {@link LiteralTree} representing
498          * a character literal expression of type {@code char}.
499          */

500         CHAR_LITERAL(LiteralTree.class),
501
502         /**
503          * Used for instances of {@link LiteralTree} representing
504          * a string literal expression of type {@link String}.
505          */

506         STRING_LITERAL(LiteralTree.class),
507     
508     /**
509      * Used for instances of {@link LiteralTree} representing
510      * the use of {@code null}.
511      */

512     NULL_LITERAL(LiteralTree.class),
513
514         /**
515          * Used for instances of {@link WildcardTree} representing
516          * an unbounded wildcard type argument.
517          */

518         UNBOUNDED_WILDCARD(WildcardTree.class),
519
520         /**
521          * Used for instances of {@link WildcardTree} representing
522          * an extends bounded wildcard type argument.
523          */

524         EXTENDS_WILDCARD(WildcardTree.class),
525
526         /**
527          * Used for instances of {@link WildcardTree} representing
528          * a super bounded wildcard type argument.
529          */

530         SUPER_WILDCARD(WildcardTree.class),
531
532         /**
533          * Used for instances of {@link ErroneousTree}.
534          */

535         ERRONEOUS(ErroneousTree.class),
536
537         /**
538          * An implementation-reserved node. This is the not the node
539          * you are looking for.
540          */

541         OTHER(null);
542                 
543         
544         Kind(Class JavaDoc<? extends Tree> intf) {
545             associatedInterface = intf;
546         }
547                 
548         public Class JavaDoc<? extends Tree> asInterface() {
549             return associatedInterface;
550         }
551         
552         private final Class JavaDoc<? extends Tree> associatedInterface;
553     }
554     
555     /**
556      * Gets the kind of this tree.
557      *
558      * @return the kind of this tree.
559      */

560     Kind getKind();
561     
562     /**
563      * Accept method used to implement the visitor pattern. The
564      * visitor pattern is used to implement operations on trees.
565      *
566      * @param <R> result type of this operation.
567      * @param <D> type of additonal data.
568      */

569     <R,D> R accept(TreeVisitor<R,D> visitor, D data);
570 }
571
Popular Tags