KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > mirror > util > DeclarationVisitors


1 /*
2  * @(#)DeclarationVisitors.java 1.4 04/07/13
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.mirror.util;
9
10 /**
11  * Utilities to create specialized <tt>DeclarationVisitor</tt> instances.
12  *
13  * @author Joseph D. Darcy
14  * @author Scott Seligman
15  * @version 1.4 04/07/13
16  * @since 1.5
17  */

18 public class DeclarationVisitors {
19     private DeclarationVisitors(){} // do not instantiate.
20

21     /**
22      * A visitor that has no side effects and keeps no state.
23      */

24     public static final DeclarationVisitor NO_OP = new SimpleDeclarationVisitor();
25
26     /**
27      * Return a <tt>DeclarationVisitor</tt> that will scan the
28      * declaration structure, visiting declarations contained in
29      * another declaration. For example, when visiting a class, the
30      * fields, methods, constructors, etc. of the class are also
31      * visited. The order in which the contained declarations are scanned is
32      * not specified.
33      *
34      * <p>The <tt>pre</tt> and <tt>post</tt>
35      * <tt>DeclarationVisitor</tt> parameters specify,
36      * respectively, the processing the scanner will do before or
37      * after visiting the contained declarations. If only one of pre
38      * and post processing is needed, use {@link
39      * DeclarationVisitors#NO_OP DeclarationVisitors.NO_OP} for the
40      * other parameter.
41      *
42      * @param pre visitor representing processing to do before
43      * visiting contained declarations.
44      *
45      * @param post visitor representing processing to do after
46      * visiting contained declarations.
47      */

48     public static DeclarationVisitor getDeclarationScanner(DeclarationVisitor pre,
49                                DeclarationVisitor post) {
50     return new DeclarationScanner(pre, post);
51     }
52
53     /**
54      * Return a <tt>DeclarationVisitor</tt> that will scan the
55      * declaration structure, visiting declarations contained in
56      * another declaration in source code order. For example, when
57      * visiting a class, the fields, methods, constructors, etc. of
58      * the class are also visited. The order in which the contained
59      * declarations are visited is as close to source code order as
60      * possible; declaration mirrors created from class files instead
61      * of source code will not have source position information.
62      *
63      * <p>The <tt>pre</tt> and <tt>post</tt>
64      * <tt>DeclarationVisitor</tt> parameters specify,
65      * respectively, the processing the scanner will do before or
66      * after visiting the contained declarations. If only one of pre
67      * and post processing is needed, use {@link
68      * DeclarationVisitors#NO_OP DeclarationVisitors.NO_OP} for the other parameter.
69      *
70      * @param pre visitor representing processing to do before
71      * visiting contained declarations.
72      *
73      * @param post visitor representing processing to do after
74      * visiting contained declarations.
75      */

76     public static DeclarationVisitor getSourceOrderDeclarationScanner(DeclarationVisitor pre,
77                                       DeclarationVisitor post) {
78     return new SourceOrderDeclScanner(pre, post);
79     }
80 }
81
Popular Tags