home *** CD-ROM | disk | FTP | other *** search
- package sunw.demo.classfile;
-
- import java.io.DataOutputStream;
- import java.io.IOException;
-
- class Exceptions extends Attribute {
- private ClassConstant[] exceptions;
-
- Exceptions(Class[] var1, ClassFile var2) {
- super("Exceptions", var2);
- ClassConstant[] var3 = new ClassConstant[var1.length];
-
- for(int var4 = 0; var4 < var1.length; ++var4) {
- var3[var4] = var2.addClassConstant(var1[var4].getName());
- }
-
- this.exceptions = var3;
- }
-
- Exceptions(ClassConstant[] var1, ClassFile var2) {
- super("Exceptions", var2);
- this.exceptions = var1;
- }
-
- void addException(ClassConstant var1) {
- if (this.exceptions == null) {
- this.exceptions = new ClassConstant[1];
- this.exceptions[0] = var1;
- } else {
- ClassConstant[] var2 = new ClassConstant[this.exceptions.length + 1];
-
- int var3;
- for(var3 = 0; var3 < this.exceptions.length; ++var3) {
- var2[var3] = this.exceptions[var3];
- }
-
- var2[var3] = var1;
- this.exceptions = var2;
- }
-
- }
-
- public boolean equals(Object var1) {
- if (var1 instanceof Exceptions) {
- Exceptions var2 = (Exceptions)var1;
- if (this.exceptions.length == var2.exceptions.length) {
- for(int var3 = 0; var3 < this.exceptions.length; ++var3) {
- if (!this.exceptions[var3].equals(var2.exceptions[var3])) {
- return false;
- }
- }
-
- return true;
- }
- }
-
- return false;
- }
-
- int getLength() {
- return this.exceptions.length * 2 + 2;
- }
-
- public int hashCode() {
- return this.exceptions.length;
- }
-
- void write(DataOutputStream var1) throws IOException {
- var1.writeShort(((Attribute)this).getNameConstantPoolIndex());
- var1.writeInt(this.getLength());
- if (this.exceptions != null && this.exceptions.length > 0) {
- var1.writeShort(this.exceptions.length);
-
- for(int var2 = 0; var2 < this.exceptions.length; ++var2) {
- var1.writeShort(this.exceptions[var2].getConstantPoolIndex());
- }
- } else {
- var1.writeShort(0);
- }
-
- }
- }
-