KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > cglib > proxy > MixinEverythingEmitter


1 /*
2  * Copyright 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package net.sf.cglib.proxy;
17
18 import java.lang.reflect.Method JavaDoc;
19 import java.lang.reflect.Modifier JavaDoc;
20 import java.util.*;
21 import net.sf.cglib.core.CollectionUtils;
22 import net.sf.cglib.core.ReflectUtils;
23 import net.sf.cglib.core.RejectModifierPredicate;
24 import org.objectweb.asm.ClassVisitor;
25
26 /**
27  * @author Chris Nokleberg
28  * @version $Id: MixinEverythingEmitter.java,v 1.3 2004/06/24 21:15:19 herbyderby Exp $
29  */

30 class MixinEverythingEmitter extends MixinEmitter {
31
32     public MixinEverythingEmitter(ClassVisitor v, String JavaDoc className, Class JavaDoc[] classes) {
33         super(v, className, classes, null);
34     }
35
36     protected Class JavaDoc[] getInterfaces(Class JavaDoc[] classes) {
37         List list = new ArrayList();
38         for (int i = 0; i < classes.length; i++) {
39             ReflectUtils.addAllInterfaces(classes[i], list);
40         }
41         return (Class JavaDoc[])list.toArray(new Class JavaDoc[list.size()]);
42     }
43
44     protected Method JavaDoc[] getMethods(Class JavaDoc type) {
45         List methods = new ArrayList(Arrays.asList(type.getMethods()));
46         CollectionUtils.filter(methods, new RejectModifierPredicate(Modifier.FINAL | Modifier.STATIC));
47         return (Method JavaDoc[])methods.toArray(new Method JavaDoc[methods.size()]);
48     }
49 }
50
Popular Tags