out.writeShort(attributes.size());
AttributeInfo.writeAll(attributes, out);
}
+
+ /**
+ * Get the Major version
+ *
+ * @return the major version
+ */
+ public int getMajorVersion()
+ {
+ return major;
+ }
+
+ /**
+ * Set the Major version
+ *
+ * @param major the major version
+ */
+ public void setMajorVersion(int major)
+ {
+ this.major = major;
+ }
+
+ /**
+ * Get the Minor version
+ *
+ * @return the minor version
+ */
+ public int getMinorVersion()
+ {
+ return minor;
+ }
+
+ /**
+ * Set the Minor version
+ *
+ * @param minor the minor version
+ */
+ public void setMinorVersion(int minor)
+ {
+ this.minor = minor;
+ }
}
import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import java.io.IOException;
-import java.util.Map;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import javassist.CtClass;
/**
}
}
+ /**
+ * Get all the class names
+ *
+ * @return a set of class names
+ */
+ public Set getClassNames()
+ {
+ HashSet result = new HashSet();
+ LongVector v = items;
+ int size = numOfItems;
+ for (int i = 1; i < size; ++i)
+ {
+ String className = ((ConstInfo) v.elementAt(i)).getClassName(this);
+ if (className != null)
+ result.add(className);
+ }
+ return result;
+ }
+
/**
* Replaces all occurrences of a class name.
*
abstract class ConstInfo {
public abstract int getTag();
+ public String getClassName(ConstPool cp) { return null; }
public void renameClass(ConstPool cp, String oldName, String newName) {}
public void renameClass(ConstPool cp, Map classnames) {}
public abstract int copy(ConstPool src, ConstPool dest, Map classnames);
public int getTag() { return tag; }
+ public String getClassName(ConstPool cp)
+ {
+ return cp.getUtf8Info(name);
+ };
+
public void renameClass(ConstPool cp, String oldName, String newName) {
String nameStr = cp.getUtf8Info(name);
if (nameStr.equals(oldName))