KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > alt > jiapi > instrumentor > AddInterfaceInstrumentor


1 /*
2  * Copyright (C) 2001 Mika Riekkinen, Joni Suominen
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package alt.jiapi.instrumentor;
20
21 import alt.jiapi.reflect.JiapiClass;
22 import alt.jiapi.reflect.InstructionList;
23
24 /**
25  * An instrumentor which adds an interface to a class which contains
26  * the current InstructionList.
27  *
28  * @author Mika Riekkinen
29  * @author Joni Suominen
30  * @version $Revision: 1.4 $ $Date: 2004/03/15 14:47:53 $
31  */

32 public class AddInterfaceInstrumentor extends AbstractInstrumentor {
33     private String JavaDoc[] interfaceNames;
34
35     public AddInterfaceInstrumentor(String JavaDoc interfaceName) {
36         this(new String JavaDoc[] {interfaceName});
37     }
38
39     public AddInterfaceInstrumentor(String JavaDoc[] interfaceNames) {
40         this.interfaceNames = interfaceNames;
41     }
42
43     public void instrument(InstructionList il) {
44         JiapiClass clazz = getCurrentClass();
45
46         for (int i = 0; i < interfaceNames.length; i++) {
47             clazz.addInterface(interfaceNames[i]);
48         }
49
50         forward(il);
51     }
52 }
53
54
Popular Tags