home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 October / PCO1097.ISO / FilesBBS / WIN95 / IAVAZIP.EXE / DATA.Z / AttributeInfo.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-08-18  |  1.8 KB  |  61 lines

  1. package com.sfs.hardcore;
  2.  
  3. import java.io.DataInputStream;
  4. import java.io.DataOutputStream;
  5. import java.io.IOException;
  6.  
  7. public class AttributeInfo {
  8.    ConstantPoolInfo name;
  9.    byte[] data;
  10.  
  11.    public String toString(ConstantPoolInfo[] var1) {
  12.       StringBuffer var2 = new StringBuffer();
  13.       String var3 = this.name.toString();
  14.       if (var3.compareTo("ConstantValue") == 0) {
  15.          ConstantPoolInfo var5 = var1[this.indexFromBytes(this.data)];
  16.          return var5.toString();
  17.       } else if (var3.compareTo("SourceFile") == 0) {
  18.          ConstantPoolInfo var4 = var1[this.indexFromBytes(this.data)];
  19.          return var4.toString();
  20.       } else {
  21.          var2.append(var3 + "<" + this.data.length + " bytes>");
  22.          return var2.toString();
  23.       }
  24.    }
  25.  
  26.    public String toBoolean(ConstantPoolInfo[] var1) {
  27.       ConstantPoolInfo var2 = var1[this.indexFromBytes(this.data)];
  28.       return var2.intValue == 0 ? "= false" : "= true";
  29.    }
  30.  
  31.    public boolean read(DataInputStream var1, ConstantPoolInfo[] var2) throws IOException {
  32.       this.name = var2[var1.readShort()];
  33.       int var3 = var1.readInt();
  34.       this.data = new byte[var3];
  35.       var3 = var1.read(this.data);
  36.       return var3 == this.data.length;
  37.    }
  38.  
  39.    public String toString() {
  40.       return this.name.toString() + " <" + this.data.length + " bytes>";
  41.    }
  42.  
  43.    public AttributeInfo(ConstantPoolInfo var1, byte[] var2) {
  44.       this.name = this.name;
  45.       this.data = var2;
  46.    }
  47.  
  48.    public AttributeInfo() {
  49.    }
  50.  
  51.    public void write(DataOutputStream var1, ConstantPoolInfo[] var2) throws IOException, Exception {
  52.       var1.writeShort(ConstantPoolInfo.indexOf(this.name, var2));
  53.       var1.writeInt(this.data.length);
  54.       var1.write(this.data, 0, this.data.length);
  55.    }
  56.  
  57.    short indexFromBytes(byte[] var1) {
  58.       return (short)(var1[0] << 8 & '\uff00' | var1[1] & 255);
  59.    }
  60. }
  61.