< prev index next >

src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java

Print this page




  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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.lang.model.util;
  27 
  28 import javax.lang.model.element.*;
  29 import javax.annotation.processing.SupportedSourceVersion;
  30 import javax.lang.model.SourceVersion;
  31 import static javax.lang.model.SourceVersion.*;
  32 
  33 
  34 /**
  35  * A scanning visitor of program elements with default behavior
  36  * appropriate for source versions {@link SourceVersion#RELEASE_9
  37  * RELEASE_9} through {@link SourceVersion#RELEASE_12 RELEASE_12}.
  38  *
  39  * The <code>visit<i>Xyz</i></code> methods in this
  40  * class scan their component elements by calling {@code scan} on
  41  * their {@linkplain Element#getEnclosedElements enclosed elements},
  42  * {@linkplain ExecutableElement#getParameters parameters}, etc., as
  43  * indicated in the individual method specifications.  A subclass can
  44  * control the order elements are visited by overriding the
  45  * <code>visit<i>Xyz</i></code> methods.  Note that clients of a scanner
  46  * may get the desired behavior be invoking {@code v.scan(e, p)} rather
  47  * than {@code v.visit(e, p)} on the root objects of interest.
  48  *
  49  * <p>When a subclass overrides a <code>visit<i>Xyz</i></code> method, the
  50  * new method can cause the enclosed elements to be scanned in the
  51  * default way by calling <code>super.visit<i>Xyz</i></code>.  In this
  52  * fashion, the concrete visitor can control the ordering of traversal
  53  * over the component elements with respect to the additional
  54  * processing; for example, consistently calling
  55  * <code>super.visit<i>Xyz</i></code> at the start of the overridden
  56  * methods will yield a preorder traversal, etc.  If the component
  57  * elements should be traversed in some other order, instead of


  75  * <p>When such a new visit method is added, the default
  76  * implementation in this class will be to call the {@link
  77  * #visitUnknown visitUnknown} method.  A new element scanner visitor
  78  * class will also be introduced to correspond to the new language
  79  * level; this visitor will have different default behavior for the
  80  * visit method in question.  When the new visitor is introduced, all
  81  * or portions of this visitor may be deprecated.
  82  *
  83  * @param <R> the return type of this visitor's methods.  Use {@link
  84  *            Void} for visitors that do not need to return results.
  85  * @param <P> the type of the additional parameter to this visitor's
  86  *            methods.  Use {@code Void} for visitors that do not need an
  87  *            additional parameter.
  88  *
  89  * @see ElementScanner6
  90  * @see ElementScanner7
  91  * @see ElementScanner8
  92  * @since 9
  93  * @spec JPMS
  94  */
  95 @SupportedSourceVersion(RELEASE_12)
  96 public class ElementScanner9<R, P> extends ElementScanner8<R, P> {
  97     /**
  98      * Constructor for concrete subclasses; uses {@code null} for the
  99      * default value.
 100      */
 101     protected ElementScanner9(){
 102         super(null);
 103     }
 104 
 105     /**
 106      * Constructor for concrete subclasses; uses the argument for the
 107      * default value.
 108      *
 109      * @param defaultValue the default value
 110      */
 111     protected ElementScanner9(R defaultValue){
 112         super(defaultValue);
 113     }
 114 
 115     /**


  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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.lang.model.util;
  27 
  28 import javax.lang.model.element.*;
  29 import javax.annotation.processing.SupportedSourceVersion;
  30 import javax.lang.model.SourceVersion;
  31 import static javax.lang.model.SourceVersion.*;
  32 
  33 
  34 /**
  35  * A scanning visitor of program elements with default behavior
  36  * appropriate for source versions {@link SourceVersion#RELEASE_9
  37  * RELEASE_9} through {@link SourceVersion#RELEASE_13 RELEASE_13}.
  38  *
  39  * The <code>visit<i>Xyz</i></code> methods in this
  40  * class scan their component elements by calling {@code scan} on
  41  * their {@linkplain Element#getEnclosedElements enclosed elements},
  42  * {@linkplain ExecutableElement#getParameters parameters}, etc., as
  43  * indicated in the individual method specifications.  A subclass can
  44  * control the order elements are visited by overriding the
  45  * <code>visit<i>Xyz</i></code> methods.  Note that clients of a scanner
  46  * may get the desired behavior be invoking {@code v.scan(e, p)} rather
  47  * than {@code v.visit(e, p)} on the root objects of interest.
  48  *
  49  * <p>When a subclass overrides a <code>visit<i>Xyz</i></code> method, the
  50  * new method can cause the enclosed elements to be scanned in the
  51  * default way by calling <code>super.visit<i>Xyz</i></code>.  In this
  52  * fashion, the concrete visitor can control the ordering of traversal
  53  * over the component elements with respect to the additional
  54  * processing; for example, consistently calling
  55  * <code>super.visit<i>Xyz</i></code> at the start of the overridden
  56  * methods will yield a preorder traversal, etc.  If the component
  57  * elements should be traversed in some other order, instead of


  75  * <p>When such a new visit method is added, the default
  76  * implementation in this class will be to call the {@link
  77  * #visitUnknown visitUnknown} method.  A new element scanner visitor
  78  * class will also be introduced to correspond to the new language
  79  * level; this visitor will have different default behavior for the
  80  * visit method in question.  When the new visitor is introduced, all
  81  * or portions of this visitor may be deprecated.
  82  *
  83  * @param <R> the return type of this visitor's methods.  Use {@link
  84  *            Void} for visitors that do not need to return results.
  85  * @param <P> the type of the additional parameter to this visitor's
  86  *            methods.  Use {@code Void} for visitors that do not need an
  87  *            additional parameter.
  88  *
  89  * @see ElementScanner6
  90  * @see ElementScanner7
  91  * @see ElementScanner8
  92  * @since 9
  93  * @spec JPMS
  94  */
  95 @SupportedSourceVersion(RELEASE_13)
  96 public class ElementScanner9<R, P> extends ElementScanner8<R, P> {
  97     /**
  98      * Constructor for concrete subclasses; uses {@code null} for the
  99      * default value.
 100      */
 101     protected ElementScanner9(){
 102         super(null);
 103     }
 104 
 105     /**
 106      * Constructor for concrete subclasses; uses the argument for the
 107      * default value.
 108      *
 109      * @param defaultValue the default value
 110      */
 111     protected ElementScanner9(R defaultValue){
 112         super(defaultValue);
 113     }
 114 
 115     /**
< prev index next >