1 /*
   2  * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Sun designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Sun in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  22  * CA 95054 USA or visit www.sun.com if you need additional information or
  23  * have any questions.
  24  */
  25 
  26 package com.sun.mirror.util;
  27 
  28 /**
  29  * Utilities to create specialized <tt>DeclarationVisitor</tt> instances.
  30  *
  31  * @deprecated All components of this API have been superseded by the
  32  * standardized annotation processing API.  There is no direct
  33  * replacement for the functionality of this class in the standardized
  34  * API due to that API's different visitor structure.
  35  *
  36  * @author Joseph D. Darcy
  37  * @author Scott Seligman
  38  * @since 1.5
  39  */
  40 @Deprecated
  41 @SuppressWarnings("deprecation")
  42 public class DeclarationVisitors {
  43     private DeclarationVisitors(){} // do not instantiate.
  44 
  45     /**
  46      * A visitor that has no side effects and keeps no state.
  47      */
  48     public static final DeclarationVisitor NO_OP = new SimpleDeclarationVisitor();
  49 
  50     /**
  51      * Return a <tt>DeclarationVisitor</tt> that will scan the
  52      * declaration structure, visiting declarations contained in
  53      * another declaration.  For example, when visiting a class, the
  54      * fields, methods, constructors, etc. of the class are also
  55      * visited.  The order in which the contained declarations are scanned is
  56      * not specified.
  57      *
  58      * <p>The <tt>pre</tt> and <tt>post</tt>
  59      * <tt>DeclarationVisitor</tt> parameters specify,
  60      * respectively, the processing the scanner will do before or
  61      * after visiting the contained declarations.  If only one of pre
  62      * and post processing is needed, use {@link
  63      * DeclarationVisitors#NO_OP DeclarationVisitors.NO_OP} for the
  64      * other parameter.
  65      *
  66      * @param pre visitor representing processing to do before
  67      * visiting contained declarations.
  68      *
  69      * @param post visitor representing processing to do after
  70      * visiting contained declarations.
  71      */
  72     public static DeclarationVisitor getDeclarationScanner(DeclarationVisitor pre,
  73                                                            DeclarationVisitor post) {
  74         return new DeclarationScanner(pre, post);
  75     }
  76 
  77     /**
  78      * Return a <tt>DeclarationVisitor</tt> that will scan the
  79      * declaration structure, visiting declarations contained in
  80      * another declaration in source code order.  For example, when
  81      * visiting a class, the fields, methods, constructors, etc. of
  82      * the class are also visited.  The order in which the contained
  83      * declarations are visited is as close to source code order as
  84      * possible; declaration mirrors created from class files instead
  85      * of source code will not have source position information.
  86      *
  87      * <p>The <tt>pre</tt> and <tt>post</tt>
  88      * <tt>DeclarationVisitor</tt> parameters specify,
  89      * respectively, the processing the scanner will do before or
  90      * after visiting the contained declarations.  If only one of pre
  91      * and post processing is needed, use {@link
  92      * DeclarationVisitors#NO_OP DeclarationVisitors.NO_OP} for the other parameter.
  93      *
  94      * @param pre visitor representing processing to do before
  95      * visiting contained declarations.
  96      *
  97      * @param post visitor representing processing to do after
  98      * visiting contained declarations.
  99      */
 100     public static DeclarationVisitor getSourceOrderDeclarationScanner(DeclarationVisitor pre,
 101                                                                       DeclarationVisitor post) {
 102         return new SourceOrderDeclScanner(pre, post);
 103     }
 104 }