home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 1999 March / maximum-cd-1999-03.iso / Feature / Lotus / ORGANIZE / COMPNENT / LTOUIN21.ZIP / sunw / demo / classfile / Exceptions.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-03-12  |  1.8 KB  |  83 lines

  1. package sunw.demo.classfile;
  2.  
  3. import java.io.DataOutputStream;
  4. import java.io.IOException;
  5.  
  6. class Exceptions extends Attribute {
  7.    private ClassConstant[] exceptions;
  8.  
  9.    Exceptions(Class[] var1, ClassFile var2) {
  10.       super("Exceptions", var2);
  11.       ClassConstant[] var3 = new ClassConstant[var1.length];
  12.  
  13.       for(int var4 = 0; var4 < var1.length; ++var4) {
  14.          var3[var4] = var2.addClassConstant(var1[var4].getName());
  15.       }
  16.  
  17.       this.exceptions = var3;
  18.    }
  19.  
  20.    Exceptions(ClassConstant[] var1, ClassFile var2) {
  21.       super("Exceptions", var2);
  22.       this.exceptions = var1;
  23.    }
  24.  
  25.    void addException(ClassConstant var1) {
  26.       if (this.exceptions == null) {
  27.          this.exceptions = new ClassConstant[1];
  28.          this.exceptions[0] = var1;
  29.       } else {
  30.          ClassConstant[] var2 = new ClassConstant[this.exceptions.length + 1];
  31.  
  32.          int var3;
  33.          for(var3 = 0; var3 < this.exceptions.length; ++var3) {
  34.             var2[var3] = this.exceptions[var3];
  35.          }
  36.  
  37.          var2[var3] = var1;
  38.          this.exceptions = var2;
  39.       }
  40.  
  41.    }
  42.  
  43.    public boolean equals(Object var1) {
  44.       if (var1 instanceof Exceptions) {
  45.          Exceptions var2 = (Exceptions)var1;
  46.          if (this.exceptions.length == var2.exceptions.length) {
  47.             for(int var3 = 0; var3 < this.exceptions.length; ++var3) {
  48.                if (!this.exceptions[var3].equals(var2.exceptions[var3])) {
  49.                   return false;
  50.                }
  51.             }
  52.  
  53.             return true;
  54.          }
  55.       }
  56.  
  57.       return false;
  58.    }
  59.  
  60.    int getLength() {
  61.       return this.exceptions.length * 2 + 2;
  62.    }
  63.  
  64.    public int hashCode() {
  65.       return this.exceptions.length;
  66.    }
  67.  
  68.    void write(DataOutputStream var1) throws IOException {
  69.       var1.writeShort(((Attribute)this).getNameConstantPoolIndex());
  70.       var1.writeInt(this.getLength());
  71.       if (this.exceptions != null && this.exceptions.length > 0) {
  72.          var1.writeShort(this.exceptions.length);
  73.  
  74.          for(int var2 = 0; var2 < this.exceptions.length; ++var2) {
  75.             var1.writeShort(this.exceptions[var2].getConstantPoolIndex());
  76.          }
  77.       } else {
  78.          var1.writeShort(0);
  79.       }
  80.  
  81.    }
  82. }
  83.