1 /* 2 * Javassist, a Java-bytecode translator toolkit. 3 * Copyright (C) 1999- 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 * or the Apache License Version 2.0. 10 * 11 * Software distributed under the License is distributed on an "AS IS" basis, 12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 13 * for the specific language governing rights and limitations under the 14 * License. 15 */ 16 17 package sample.preproc; 18 19 import javassist.CtClass; 20 import javassist.CannotCompileException; 21 import javassist.ClassPool; 22 23 /** 24 * This is an interface for objects invoked by the 25 * Javassist preprocessor when the preprocessor encounters an annotated 26 * import declaration. 27 * 28 * @see sample.preproc.Compiler 29 */ 30 public interface Assistant { 31 /** 32 * Is called when the Javassist preprocessor encounters an 33 * import declaration annotated with the "by" keyword. 34 * 35 * <p>The original import declaration is replaced with new import 36 * declarations of classes returned by this method. For example, 37 * the following implementation does not change the original 38 * declaration: 39 * 40 * <ul><pre> 41 * public CtClass[] assist(ClassPool cp, String importname, String[] args) { 42 * return new CtClass[] { cp.get(importname) }; 43 * } 44 * </pre></uL> 45 * 46 * @param cp class pool 47 * @param importname the class imported by the declaration 48 * @param args the parameters specified by the annotation 49 * @return the classes imported in the java source 50 * program produced by the preprocessor. 51 */ assist(ClassPool cp, String importname, String[] args)52 public CtClass[] assist(ClassPool cp, String importname, 53 String[] args) throws CannotCompileException; 54 } 55