home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VPage / Java.bin / CLASSES.ZIP / sun / security / util / DerInputBuffer.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-07-08  |  1.9 KB  |  90 lines

  1. package sun.security.util;
  2.  
  3. import java.io.ByteArrayInputStream;
  4. import java.io.IOException;
  5.  
  6. class DerInputBuffer extends ByteArrayInputStream implements Cloneable {
  7.    DerInputBuffer(byte[] var1) {
  8.       super(var1);
  9.    }
  10.  
  11.    DerInputBuffer(byte[] var1, int var2, int var3) {
  12.       super(var1);
  13.    }
  14.  
  15.    DerInputBuffer dup() {
  16.       try {
  17.          DerInputBuffer var1 = (DerInputBuffer)this.clone();
  18.          ((ByteArrayInputStream)var1).mark(Integer.MAX_VALUE);
  19.          return var1;
  20.       } catch (CloneNotSupportedException var2) {
  21.          throw new IllegalArgumentException(((Throwable)var2).toString());
  22.       }
  23.    }
  24.  
  25.    int peek() throws IOException {
  26.       if (super.pos >= super.count) {
  27.          throw new IOException("out of data");
  28.       } else {
  29.          return super.buf[super.pos];
  30.       }
  31.    }
  32.  
  33.    public boolean equals(Object var1) {
  34.       return var1 instanceof DerInputBuffer ? this.equals((DerInputBuffer)var1) : false;
  35.    }
  36.  
  37.    boolean equals(DerInputBuffer var1) {
  38.       int var2 = ((ByteArrayInputStream)this).available();
  39.       if (this == var1) {
  40.          return true;
  41.       } else if (((ByteArrayInputStream)var1).available() != ((ByteArrayInputStream)this).available()) {
  42.          return false;
  43.       } else {
  44.          for(int var3 = 0; var3 < var2; ++var3) {
  45.             if (super.buf[super.pos + var3] != var1.buf[var1.pos + var3]) {
  46.                return false;
  47.             }
  48.          }
  49.  
  50.          return true;
  51.       }
  52.    }
  53.  
  54.    void truncate(int var1) throws IOException {
  55.       if (var1 > ((ByteArrayInputStream)this).available()) {
  56.          throw new IOException("insufficient data");
  57.       } else {
  58.          super.count = super.pos + var1;
  59.       }
  60.    }
  61.  
  62.    BigInt getUnsigned(int var1) throws IOException {
  63.       if (var1 > ((ByteArrayInputStream)this).available()) {
  64.          throw new IOException("short read, getInteger");
  65.       } else {
  66.          if (super.buf[super.pos] == 0) {
  67.             --var1;
  68.             ((ByteArrayInputStream)this).skip(1L);
  69.          }
  70.  
  71.          byte[] var2 = new byte[var1];
  72.          System.arraycopy(super.buf, super.pos, var2, 0, var1);
  73.          ((ByteArrayInputStream)this).skip((long)var1);
  74.          return new BigInt(var2);
  75.       }
  76.    }
  77.  
  78.    byte[] getBitString() {
  79.       if (super.pos < super.count && super.buf[super.pos] == 0) {
  80.          int var1 = ((ByteArrayInputStream)this).available();
  81.          byte[] var2 = new byte[var1 - 1];
  82.          System.arraycopy(super.buf, super.pos + 1, var2, 0, var1 - 1);
  83.          super.pos = super.count;
  84.          return var2;
  85.       } else {
  86.          return null;
  87.       }
  88.    }
  89. }
  90.