Home | History | Annotate | Download | only in preproc
      1 /*
      2  * Javassist, a Java-bytecode translator toolkit.
      3  * Copyright (C) 1999-2005 Shigeru Chiba. All Rights Reserved.
      4  *
      5  * The contents of this file are subject to the Mozilla Public License Version
      6  * 1.1 (the "License"); you may not use this file except in compliance with
      7  * the License.  Alternatively, the contents of this file may be used under
      8  * the terms of the GNU Lesser General Public License Version 2.1 or later.
      9  *
     10  * Software distributed under the License is distributed on an "AS IS" basis,
     11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
     12  * for the specific language governing rights and limitations under the
     13  * License.
     14  */
     15 
     16 package sample.preproc;
     17 
     18 import javassist.CtClass;
     19 import javassist.CannotCompileException;
     20 import javassist.ClassPool;
     21 
     22 /**
     23  * This is an interface for objects invoked by the
     24  * Javassist preprocessor when the preprocessor encounters an annotated
     25  * import declaration.
     26  *
     27  * @see sample.preproc.Compiler
     28  */
     29 public interface Assistant {
     30     /**
     31      * Is called when the Javassist preprocessor encounters an
     32      * import declaration annotated with the "by" keyword.
     33      *
     34      * <p>The original import declaration is replaced with new import
     35      * declarations of classes returned by this method.  For example,
     36      * the following implementation does not change the original
     37      * declaration:
     38      *
     39      * <ul><pre>
     40      * public CtClass[] assist(ClassPool cp, String importname, String[] args) {
     41      *     return new CtClass[] { cp.get(importname) };
     42      * }
     43      * </pre></uL>
     44      *
     45      * @param cp                class pool
     46      * @param importname        the class imported by the declaration
     47      * @param args              the parameters specified by the annotation
     48      * @return                  the classes imported in the java source
     49      *                          program produced by the preprocessor.
     50      */
     51     public CtClass[] assist(ClassPool cp, String importname,
     52                             String[] args) throws CannotCompileException;
     53 }
     54