/Users/lyon/j4p/src/javassist/Translator.java
|
1 /*
2 * Javassist, a Java-bytecode translator toolkit.
3 * Copyright (C) 1999-2003 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 javassist;
17
18 /**
19 * An observer of <code>ClassPool</code>.
20 * The users can define a class implementing this
21 * interface and attach an instance of that class to a
22 * <code>ClassPool</code> object so that it can translate a class file
23 * when the class file is loaded into the JVM, for example.
24 *
25 * @see ClassPool#ClassPool(ClassPool,Translator)
26 * @see ClassPool#getDefault(Translator)
27 */
28 public interface Translator {
29 /**
30 * Is invoked by a <code>ClassPool</code> for initialization
31 * when the object is attached to a <code>ClassPool</code> object.
32 *
33 * @param pool the <code>ClassPool</code> that this translator
34 * is attached to.
35 *
36 * @see ClassPool#ClassPool(ClassPool,Translator)
37 * @see ClassPool#getDefault(Translator)
38 */
39 void start(ClassPool pool)
40 throws NotFoundException, CannotCompileException;
41
42 /**
43 * Is invoked by a <code>ClassPool</code> for notifying that
44 * a class is written out to an output stream.
45 *
46 * <p>If CtClass.frozen() is true, that is, if the class has been
47 * already modified and written, then onWrite() is not invoked.
48 *
49 * @param pool the <code>ClassPool</code> that this translator
50 * is attached to.
51 * @param classname a fully-qualified class name
52 *
53 * @see ClassPool#writeFile(String)
54 * @see ClassPool#writeFile(String, String)
55 * @see ClassPool#write(String)
56 * @see ClassPool#write(String,DataOutputStream)
57 */
58 void onWrite(ClassPool pool, String classname)
59 throws NotFoundException, CannotCompileException;
60 }
61