FileDocCategorySizeDatePackage
FilterClassAdapter.javaAPI DocAndroid 1.5 API4749Wed May 06 22:41:10 BST 2009com.android.mkstubs

FilterClassAdapter

public class FilterClassAdapter extends org.objectweb.asm.ClassAdapter
A class visitor that filters out all members (fields, methods and inner classes) that are either private or rejected by the {@link Filter}.

Fields Summary
private final Filter
mFilter
private String
mClassName
Constructors Summary
public FilterClassAdapter(org.objectweb.asm.ClassVisitor writer, Filter filter)

        super(writer);
        mFilter = filter;
    
Methods Summary
public voidvisit(int version, int access, java.lang.String name, java.lang.String signature, java.lang.String superName, java.lang.String[] interfaces)


        mClassName = name;
        super.visit(version, access, name, signature, superName, interfaces);
    
public org.objectweb.asm.AnnotationVisitorvisitAnnotation(java.lang.String desc, boolean visible)

        
        // TODO produce an error if a filtered annotation type is being used
        return super.visitAnnotation(desc, visible);
    
public voidvisitAttribute(org.objectweb.asm.Attribute attr)

        // pass
    
public voidvisitEnd()

        super.visitEnd();
    
public org.objectweb.asm.FieldVisitorvisitField(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.Object value)
Visits a field. {@inheritDoc} Examples: name = mArg desc = Ljava/Lang/String; signature = null (not a template) or template type

        // exclude private fields
        if ((access & Opcodes.ACC_PRIVATE) != 0) {
            return null;
        }
        
        // filter on field name
        String filterName = String.format("%s#%s", mClassName, name);

        if (!mFilter.accept(filterName)) {
            System.out.println("- Remove field " + filterName);
            return null;
        }
        
        // TODO we should produce an error if a filtered desc/signature is being used.

        return super.visitField(access, name, desc, signature, value);
    
public voidvisitInnerClass(java.lang.String name, java.lang.String outerName, java.lang.String innerName, int access)


        // exclude private methods
        if ((access & Opcodes.ACC_PRIVATE) != 0) {
            return;
        }

        // filter on name
        if (!mFilter.accept(name)) {
            return;
        }

        super.visitInnerClass(name, outerName, innerName, access);
    
public org.objectweb.asm.MethodVisitorvisitMethod(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.String[] exceptions)
Visits a method. {@inheritDoc} Examples: name = desc = ()V signature = null (not a template) or template type


        // exclude private methods
        if ((access & Opcodes.ACC_PRIVATE) != 0) {
            return null;
        }
        
        // filter on method name using the non-generic descriptor
        String filterName = String.format("%s#%s%s", mClassName, name, desc);

        if (!mFilter.accept(filterName)) {
            System.out.println("- Remove method " + filterName);
            return null;
        }

        // filter on method name using the generic signature
        if (signature != null) {
            filterName = String.format("%s#%s%s", mClassName, name, signature);
    
            if (!mFilter.accept(filterName)) {
                System.out.println("- Remove method " + filterName);
                return null;
            }
        }

        // TODO we should produce an error if a filtered desc/signature/exception is being used.

        return super.visitMethod(access, name, desc, signature, exceptions);
    
public voidvisitOuterClass(java.lang.String owner, java.lang.String name, java.lang.String desc)

        // pass
    
public voidvisitSource(java.lang.String source, java.lang.String debug)

        // pass