home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / earthlink / nscomm / java40.jar / netscape / util / ClassInfo.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-11-03  |  1.6 KB  |  125 lines

  1. package netscape.util;
  2.  
  3. public class ClassInfo {
  4.    String className;
  5.    int classCount;
  6.    String[] classNames;
  7.    int[] classVersions;
  8.    int fieldCount;
  9.    String[] fieldNames;
  10.    byte[] fieldTypes;
  11.  
  12.    public ClassInfo(String var1) {
  13.       this.className = var1;
  14.       this.classNames = new String[8];
  15.       this.classVersions = new int[8];
  16.       this.fieldNames = new String[24];
  17.       this.fieldTypes = new byte[24];
  18.    }
  19.  
  20.    public void addClass(String var1, int var2) {
  21.       this.ensureClassCapacity(this.classCount);
  22.       this.classNames[this.classCount] = var1;
  23.       this.classVersions[this.classCount] = var2;
  24.       ++this.classCount;
  25.    }
  26.  
  27.    public void addField(String var1, byte var2) {
  28.       this.ensureFieldCapacity(this.fieldCount);
  29.       this.fieldNames[this.fieldCount] = var1;
  30.       this.fieldTypes[this.fieldCount] = var2;
  31.       ++this.fieldCount;
  32.    }
  33.  
  34.    public String className() {
  35.       return this.className;
  36.    }
  37.  
  38.    public int classCount() {
  39.       return this.classCount;
  40.    }
  41.  
  42.    public String[] classNames() {
  43.       String[] var1 = new String[this.classCount];
  44.       System.arraycopy(this.classNames, 0, var1, 0, this.classCount);
  45.       return var1;
  46.    }
  47.  
  48.    public int[] classVersions() {
  49.       int[] var1 = new int[this.classCount];
  50.       System.arraycopy(this.classVersions, 0, var1, 0, this.classCount);
  51.       return var1;
  52.    }
  53.  
  54.    public int fieldCount() {
  55.       return this.fieldCount;
  56.    }
  57.  
  58.    public String[] fieldNames() {
  59.       String[] var1 = new String[this.fieldCount];
  60.       System.arraycopy(this.fieldNames, 0, var1, 0, this.fieldCount);
  61.       return var1;
  62.    }
  63.  
  64.    public byte[] fieldTypes() {
  65.       byte[] var1 = new byte[this.fieldCount];
  66.       System.arraycopy(this.fieldTypes, 0, var1, 0, this.fieldCount);
  67.       return var1;
  68.    }
  69.  
  70.    protected void ensureClassCapacity(int var1) {
  71.       if (var1 >= this.classNames.length) {
  72.          int var2;
  73.          if (this.classNames.length == 0) {
  74.             var2 = 8;
  75.          } else {
  76.             var2 = 2 * this.classNames.length;
  77.          }
  78.  
  79.          while(var2 < var1) {
  80.             var2 = 2 * var2;
  81.          }
  82.  
  83.          int var3 = this.classNames.length;
  84.          String[] var4 = new String[var2];
  85.          int[] var5 = new int[var2];
  86.          System.arraycopy(this.classNames, 0, var4, 0, var3);
  87.          System.arraycopy(this.classVersions, 0, var5, 0, var3);
  88.          this.classNames = var4;
  89.          this.classVersions = var5;
  90.       }
  91.    }
  92.  
  93.    protected void ensureFieldCapacity(int var1) {
  94.       int var3 = this.fieldCapacityFor(var1);
  95.       if (var3 >= 0) {
  96.          int var4 = this.fieldNames.length;
  97.          String[] var2 = new String[var3];
  98.          byte[] var5 = new byte[var3];
  99.          System.arraycopy(this.fieldNames, 0, var2, 0, var4);
  100.          System.arraycopy(this.fieldTypes, 0, var5, 0, var4);
  101.          this.fieldNames = var2;
  102.          this.fieldTypes = var5;
  103.       }
  104.    }
  105.  
  106.    public int fieldCapacityFor(int var1) {
  107.       int var2 = 0;
  108.       if (var1 < this.fieldNames.length) {
  109.          return -1;
  110.       } else {
  111.          if (this.fieldNames.length == 0) {
  112.             var2 = 24;
  113.          } else {
  114.             var2 = 2 * this.fieldNames.length;
  115.          }
  116.  
  117.          while(var2 < var1) {
  118.             var2 = 2 * var2;
  119.          }
  120.  
  121.          return var2;
  122.       }
  123.    }
  124. }
  125.