1 17 package org.apache.bcel.generic; 18 19 import java.util.ArrayList ; 20 import java.util.List ; 21 import org.apache.bcel.Constants; 22 import org.apache.bcel.classfile.AccessFlags; 23 import org.apache.bcel.classfile.Attribute; 24 25 32 public abstract class FieldGenOrMethodGen extends AccessFlags implements NamedAndTyped, Cloneable { 33 34 protected String name; 35 protected Type type; 36 protected ConstantPoolGen cp; 37 private List attribute_vec = new ArrayList (); 38 39 40 protected FieldGenOrMethodGen() { 41 } 42 43 44 public void setType( Type type ) { 45 if (type.getType() == Constants.T_ADDRESS) { 46 throw new IllegalArgumentException ("Type can not be " + type); 47 } 48 this.type = type; 49 } 50 51 52 public Type getType() { 53 return type; 54 } 55 56 57 59 public String getName() { 60 return name; 61 } 62 63 64 public void setName( String name ) { 65 this.name = name; 66 } 67 68 69 public ConstantPoolGen getConstantPool() { 70 return cp; 71 } 72 73 74 public void setConstantPool( ConstantPoolGen cp ) { 75 this.cp = cp; 76 } 77 78 79 87 public void addAttribute( Attribute a ) { 88 attribute_vec.add(a); 89 } 90 91 92 95 public void removeAttribute( Attribute a ) { 96 attribute_vec.remove(a); 97 } 98 99 100 103 public void removeAttributes() { 104 attribute_vec.clear(); 105 } 106 107 108 111 public Attribute[] getAttributes() { 112 Attribute[] attributes = new Attribute[attribute_vec.size()]; 113 attribute_vec.toArray(attributes); 114 return attributes; 115 } 116 117 118 120 public abstract String getSignature(); 121 122 123 public Object clone() { 124 try { 125 return super.clone(); 126 } catch (CloneNotSupportedException e) { 127 System.err.println(e); 128 return null; 129 } 130 } 131 } 132 | Popular Tags |