Home » openjdk-7 » javax.lang » model » element » [javadoc | source]

    1   /*
    2    * Copyright (c) 2005, 2006, Oracle and/or its affiliates. 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.  Oracle designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Oracle 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 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.element;
   27   
   28   
   29   import java.util.List;
   30   
   31   import javax.lang.model.type.TypeMirror;
   32   
   33   
   34   /**
   35    * A visitor of the values of annotation type elements, using a
   36    * variant of the visitor design pattern.  Unlike a standard visitor
   37    * which dispatches based on the concrete type of a member of a type
   38    * hierarchy, this visitor dispatches based on the type of data
   39    * stored; there are no distinct subclasses for storing, for example,
   40    * {@code boolean} values versus {@code int} values.  Classes
   41    * implementing this interface are used to operate on a value when the
   42    * type of that value is unknown at compile time.  When a visitor is
   43    * passed to a value's {@link AnnotationValue#accept accept} method,
   44    * the <tt>visit<i>XYZ</i></tt> method applicable to that value is
   45    * invoked.
   46    *
   47    * <p> Classes implementing this interface may or may not throw a
   48    * {@code NullPointerException} if the additional parameter {@code p}
   49    * is {@code null}; see documentation of the implementing class for
   50    * details.
   51    *
   52    * <p> <b>WARNING:</b> It is possible that methods will be added to
   53    * this interface to accommodate new, currently unknown, language
   54    * structures added to future versions of the Java&trade; programming
   55    * language.  Therefore, visitor classes directly implementing this
   56    * interface may be source incompatible with future versions of the
   57    * platform.  To avoid this source incompatibility, visitor
   58    * implementations are encouraged to instead extend the appropriate
   59    * abstract visitor class that implements this interface.  However, an
   60    * API should generally use this visitor interface as the type for
   61    * parameters, return type, etc. rather than one of the abstract
   62    * classes.
   63    *
   64    * @param <R> the return type of this visitor's methods
   65    * @param <P> the type of the additional parameter to this visitor's methods.
   66    * @author Joseph D. Darcy
   67    * @author Scott Seligman
   68    * @author Peter von der Ah&eacute;
   69    * @since 1.6
   70    */
   71   public interface AnnotationValueVisitor<R, P> {
   72       /**
   73        * Visits an annotation value.
   74        * @param av the value to visit
   75        * @param p a visitor-specified parameter
   76        * @return  a visitor-specified result
   77        */
   78       R visit(AnnotationValue av, P p);
   79   
   80       /**
   81        * A convenience method equivalent to {@code v.visit(av, null)}.
   82        * @param av the value to visit
   83        * @return  a visitor-specified result
   84        */
   85       R visit(AnnotationValue av);
   86   
   87       /**
   88        * Visits a {@code boolean} value in an annotation.
   89        * @param b the value being visited
   90        * @param p a visitor-specified parameter
   91        * @return the result of the visit
   92        */
   93       R visitBoolean(boolean b, P p);
   94   
   95       /**
   96        * Visits a {@code byte} value in an annotation.
   97        * @param  b the value being visited
   98        * @param  p a visitor-specified parameter
   99        * @return the result of the visit
  100        */
  101       R visitByte(byte b, P p);
  102   
  103       /**
  104        * Visits a {@code char} value in an annotation.
  105        * @param  c the value being visited
  106        * @param  p a visitor-specified parameter
  107        * @return the result of the visit
  108        */
  109       R visitChar(char c, P p);
  110   
  111       /**
  112        * Visits a {@code double} value in an annotation.
  113        * @param  d the value being visited
  114        * @param  p a visitor-specified parameter
  115        * @return the result of the visit
  116        */
  117       R visitDouble(double d, P p);
  118   
  119       /**
  120        * Visits a {@code float} value in an annotation.
  121        * @param  f the value being visited
  122        * @param  p a visitor-specified parameter
  123        * @return the result of the visit
  124        */
  125       R visitFloat(float f, P p);
  126   
  127       /**
  128        * Visits an {@code int} value in an annotation.
  129        * @param  i the value being visited
  130        * @param  p a visitor-specified parameter
  131        * @return the result of the visit
  132        */
  133       R visitInt(int i, P p);
  134   
  135       /**
  136        * Visits a {@code long} value in an annotation.
  137        * @param  i the value being visited
  138        * @param  p a visitor-specified parameter
  139        * @return the result of the visit
  140        */
  141       R visitLong(long i, P p);
  142   
  143       /**
  144        * Visits a {@code short} value in an annotation.
  145        * @param  s the value being visited
  146        * @param  p a visitor-specified parameter
  147        * @return the result of the visit
  148        */
  149       R visitShort(short s, P p);
  150   
  151       /**
  152        * Visits a string value in an annotation.
  153        * @param  s the value being visited
  154        * @param  p a visitor-specified parameter
  155        * @return the result of the visit
  156        */
  157       R visitString(String s, P p);
  158   
  159       /**
  160        * Visits a type value in an annotation.
  161        * @param  t the value being visited
  162        * @param  p a visitor-specified parameter
  163        * @return the result of the visit
  164        */
  165       R visitType(TypeMirror t, P p);
  166   
  167       /**
  168        * Visits an {@code enum} value in an annotation.
  169        * @param  c the value being visited
  170        * @param  p a visitor-specified parameter
  171        * @return the result of the visit
  172        */
  173       R visitEnumConstant(VariableElement c, P p);
  174   
  175       /**
  176        * Visits an annotation value in an annotation.
  177        * @param  a the value being visited
  178        * @param  p a visitor-specified parameter
  179        * @return the result of the visit
  180        */
  181       R visitAnnotation(AnnotationMirror a, P p);
  182   
  183       /**
  184        * Visits an array value in an annotation.
  185        * @param  vals the value being visited
  186        * @param  p a visitor-specified parameter
  187        * @return the result of the visit
  188        */
  189       R visitArray(List<? extends AnnotationValue> vals, P p);
  190   
  191       /**
  192        * Visits an unknown kind of annotation value.
  193        * This can occur if the language evolves and new kinds
  194        * of value can be stored in an annotation.
  195        * @param  av the unknown value being visited
  196        * @param  p a visitor-specified parameter
  197        * @return the result of the visit
  198        * @throws UnknownAnnotationValueException
  199        *  a visitor implementation may optionally throw this exception
  200        */
  201       R visitUnknown(AnnotationValue av, P p);
  202   }

Home » openjdk-7 » javax.lang » model » element » [javadoc | source]