Methods Summary |
---|
public void | addAttribute(com.sun.org.apache.bcel.internal.classfile.Attribute a)Add an attribute to this class. attribute_vec.add(a);
|
public void | addEmptyConstructor(int access_flags)Convenience method.
Add an empty constructor to this class that does nothing but calling super().
InstructionList il = new InstructionList();
il.append(InstructionConstants.THIS); // Push `this'
il.append(new INVOKESPECIAL(cp.addMethodref(super_class_name,
"<init>", "()V")));
il.append(InstructionConstants.RETURN);
MethodGen mg = new MethodGen(access_flags, Type.VOID, Type.NO_ARGS, null,
"<init>", class_name, il, cp);
mg.setMaxStack(1);
addMethod(mg.getMethod());
|
public void | addField(com.sun.org.apache.bcel.internal.classfile.Field f)Add a field to this class. field_vec.add(f);
|
public void | addInterface(java.lang.String name)Add an interface to this class, i.e., this class has to implement it.
interface_vec.add(name);
|
public void | addMethod(com.sun.org.apache.bcel.internal.classfile.Method m)Add a method to this class. method_vec.add(m);
|
public void | addObserver(com.sun.org.apache.bcel.internal.generic.ClassObserver o)Add observer for this object.
if(observers == null)
observers = new ArrayList();
observers.add(o);
|
public java.lang.Object | clone()
try {
return super.clone();
} catch(CloneNotSupportedException e) {
System.err.println(e);
return null;
}
|
public boolean | containsField(com.sun.org.apache.bcel.internal.classfile.Field f) return field_vec.contains(f);
|
public com.sun.org.apache.bcel.internal.classfile.Field | containsField(java.lang.String name)
for(Iterator e=field_vec.iterator(); e.hasNext(); ) {
Field f = (Field)e.next();
if(f.getName().equals(name))
return f;
}
return null;
|
public com.sun.org.apache.bcel.internal.classfile.Method | containsMethod(java.lang.String name, java.lang.String signature)
for(Iterator e=method_vec.iterator(); e.hasNext();) {
Method m = (Method)e.next();
if(m.getName().equals(name) && m.getSignature().equals(signature))
return m;
}
return null;
|
public com.sun.org.apache.bcel.internal.classfile.Attribute[] | getAttributes()
Attribute[] attributes = new Attribute[attribute_vec.size()];
attribute_vec.toArray(attributes);
return attributes;
|
public java.lang.String | getClassName() return class_name;
|
public int | getClassNameIndex() return class_name_index;
|
public com.sun.org.apache.bcel.internal.generic.ConstantPoolGen | getConstantPool() return cp;
|
public com.sun.org.apache.bcel.internal.classfile.Field[] | getFields()
Field[] fields = new Field[field_vec.size()];
field_vec.toArray(fields);
return fields;
|
public java.lang.String | getFileName() return file_name;
|
public java.lang.String[] | getInterfaceNames()
int size = interface_vec.size();
String[] interfaces = new String[size];
interface_vec.toArray(interfaces);
return interfaces;
|
public int[] | getInterfaces()
int size = interface_vec.size();
int[] interfaces = new int[size];
for(int i=0; i < size; i++)
interfaces[i] = cp.addClass((String)interface_vec.get(i));
return interfaces;
|
public com.sun.org.apache.bcel.internal.classfile.JavaClass | getJavaClass()
int[] interfaces = getInterfaces();
Field[] fields = getFields();
Method[] methods = getMethods();
Attribute[] attributes = getAttributes();
// Must be last since the above calls may still add something to it
ConstantPool cp = this.cp.getFinalConstantPool();
return new JavaClass(class_name_index, superclass_name_index,
file_name, major, minor, access_flags,
cp, interfaces, fields, methods, attributes);
|
public int | getMajor() return major;
|
public com.sun.org.apache.bcel.internal.classfile.Method | getMethodAt(int pos)
return (Method)method_vec.get(pos);
|
public com.sun.org.apache.bcel.internal.classfile.Method[] | getMethods()
Method[] methods = new Method[method_vec.size()];
method_vec.toArray(methods);
return methods;
|
public int | getMinor() return minor;
|
public java.lang.String | getSuperclassName() return super_class_name;
|
public int | getSuperclassNameIndex() return superclass_name_index;
|
public void | removeAttribute(com.sun.org.apache.bcel.internal.classfile.Attribute a)Remove an attribute from this class. attribute_vec.remove(a);
|
public void | removeField(com.sun.org.apache.bcel.internal.classfile.Field f)Remove a field to this class. field_vec.remove(f);
|
public void | removeInterface(java.lang.String name)Remove an interface from this class.
interface_vec.remove(name);
|
public void | removeMethod(com.sun.org.apache.bcel.internal.classfile.Method m)Remove a method from this class. method_vec.remove(m);
|
public void | removeObserver(com.sun.org.apache.bcel.internal.generic.ClassObserver o)Remove observer for this object.
if(observers != null)
observers.remove(o);
|
public void | replaceField(com.sun.org.apache.bcel.internal.classfile.Field old, com.sun.org.apache.bcel.internal.classfile.Field new_)Replace given field with new one. If the old one does not exist
add the new_ field to the class anyway.
if(new_ == null)
throw new ClassGenException("Replacement method must not be null");
int i = field_vec.indexOf(old);
if(i < 0)
field_vec.add(new_);
else
field_vec.set(i, new_);
|
public void | replaceMethod(com.sun.org.apache.bcel.internal.classfile.Method old, com.sun.org.apache.bcel.internal.classfile.Method new_)Replace given method with new one. If the old one does not exist
add the new_ method to the class anyway.
if(new_ == null)
throw new ClassGenException("Replacement method must not be null");
int i = method_vec.indexOf(old);
if(i < 0)
method_vec.add(new_);
else
method_vec.set(i, new_);
|
public void | setClassName(java.lang.String name)
class_name = name.replace('/", '.");
class_name_index = cp.addClass(name);
|
public void | setClassNameIndex(int class_name_index)
this.class_name_index = class_name_index;
class_name = cp.getConstantPool().
getConstantString(class_name_index, Constants.CONSTANT_Class).replace('/", '.");
|
public void | setConstantPool(com.sun.org.apache.bcel.internal.generic.ConstantPoolGen constant_pool)
cp = constant_pool;
|
public void | setMajor(int major)Set major version number of class file, default value is 45 (JDK 1.1)
this.major = major;
|
public void | setMethodAt(com.sun.org.apache.bcel.internal.classfile.Method method, int pos)
method_vec.set(pos, method);
|
public void | setMethods(com.sun.org.apache.bcel.internal.classfile.Method[] methods)
method_vec.clear();
for(int m=0; m<methods.length; m++)
addMethod(methods[m]);
|
public void | setMinor(int minor)Set minor version number of class file, default value is 3 (JDK 1.1)
this.minor = minor;
|
public void | setSuperclassName(java.lang.String name)
super_class_name = name.replace('/", '.");
superclass_name_index = cp.addClass(name);
|
public void | setSuperclassNameIndex(int superclass_name_index)
this.superclass_name_index = superclass_name_index;
super_class_name = cp.getConstantPool().
getConstantString(superclass_name_index, Constants.CONSTANT_Class).replace('/", '.");
|
public void | update()Call notify() method on all observers. This method is not called
automatically whenever the state has changed, but has to be
called by the user after he has finished editing the object.
if(observers != null)
for(Iterator e = observers.iterator(); e.hasNext(); )
((ClassObserver)e.next()).notify(this);
|