1 15 16 package javassist; 17 18 22 public abstract class CtMember { 23 protected CtMember next; protected CtClass declaringClass; 25 26 protected CtMember(CtClass clazz) { declaringClass = clazz; } 27 28 static CtMember append(CtMember list, CtMember tail) { 29 tail.next = null; 30 if (list == null) 31 return tail; 32 else { 33 CtMember lst = list; 34 while (lst.next != null) 35 lst = lst.next; 36 37 lst.next = tail; 38 return list; 39 } 40 } 41 42 static int count(CtMember f) { 43 int n = 0; 44 while (f != null) { 45 ++n; 46 f = f.next; 47 } 48 49 return n; 50 } 51 52 static CtMember remove(CtMember list, CtMember m) { 53 CtMember top = list; 54 if (list == null) 55 return null; 56 else if (list == m) 57 return list.next; 58 else 59 while (list.next != null) { 60 if (list.next == m) { 61 list.next = list.next.next; 62 break; 63 } 64 65 list = list.next; 66 } 67 68 return top; 69 } 70 71 public String toString() { 72 StringBuffer buffer = new StringBuffer (getClass().getName()); 73 buffer.append("@"); 74 buffer.append(Integer.toHexString(hashCode())); 75 buffer.append("["); 76 buffer.append(Modifier.toString(getModifiers())); 77 extendToString(buffer); 78 buffer.append("]"); 79 return buffer.toString(); 80 } 81 82 89 protected abstract void extendToString(StringBuffer buffer); 90 91 94 public CtClass getDeclaringClass() { return declaringClass; } 95 96 103 public abstract int getModifiers(); 104 105 110 public abstract void setModifiers(int mod); 111 112 120 public abstract String getName(); 121 122 129 public abstract byte[] getAttribute(String name); 130 131 137 public abstract void setAttribute(String name, byte[] data); 138 } 139 | Popular Tags |