1 34 35 package org.logicalcobwebs.asm.tree; 36 37 import org.logicalcobwebs.asm.ClassVisitor; 38 import org.logicalcobwebs.asm.Attribute; 39 40 import java.util.List ; 41 import java.util.ArrayList ; 42 import java.util.Arrays ; 43 44 47 48 public class ClassNode { 49 50 54 55 public int access; 56 57 61 62 public String name; 63 64 70 71 public String superName; 72 73 78 79 public final List interfaces; 80 81 85 86 public String sourceFile; 87 88 92 93 public final List innerClasses; 94 95 99 100 public final List fields; 101 102 106 107 public final List methods; 108 109 112 113 public Attribute attrs; 114 115 132 133 public ClassNode ( 134 final int access, 135 final String name, 136 final String superName, 137 final String [] interfaces, 138 final String sourceFile) 139 { 140 this.access = access; 141 this.name = name; 142 this.superName = superName; 143 this.interfaces = new ArrayList (); 144 this.sourceFile = sourceFile; 145 this.innerClasses = new ArrayList (); 146 this.fields = new ArrayList (); 147 this.methods = new ArrayList (); 148 if (interfaces != null) { 149 this.interfaces.addAll(Arrays.asList(interfaces)); 150 } 151 } 152 153 158 159 public void accept (final ClassVisitor cv) { 160 String [] interfaces = new String [this.interfaces.size()]; 162 this.interfaces.toArray(interfaces); 163 cv.visit(access, name, superName, interfaces, sourceFile); 164 int i; 166 for (i = 0; i < innerClasses.size(); ++i) { 167 ((InnerClassNode)innerClasses.get(i)).accept(cv); 168 } 169 for (i = 0; i < fields.size(); ++i) { 171 ((FieldNode)fields.get(i)).accept(cv); 172 } 173 for (i = 0; i < methods.size(); ++i) { 175 ((MethodNode)methods.get(i)).accept(cv); 176 } 177 Attribute attrs = this.attrs; 179 while (attrs != null) { 180 cv.visitAttribute(attrs); 181 attrs = attrs.next; 182 } 183 cv.visitEnd(); 185 } 186 } 187 | Popular Tags |