home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 January / PCO0198.ISO / 1&1 / java.z / java_301 / sun / audio / AudioStreamSequence.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-10-20  |  1.2 KB  |  56 lines

  1. package sun.audio;
  2.  
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5. import java.util.Enumeration;
  6.  
  7. public class AudioStreamSequence extends InputStream {
  8.    // $FF: renamed from: e java.util.Enumeration
  9.    Enumeration field_0;
  10.    // $FF: renamed from: in java.io.InputStream
  11.    InputStream field_1;
  12.  
  13.    public AudioStreamSequence(Enumeration e) {
  14.       this.field_0 = e;
  15.       this.field_1 = e.hasMoreElements() ? (InputStream)e.nextElement() : null;
  16.    }
  17.  
  18.    public int read() throws IOException {
  19.       if (this.field_1 == null) {
  20.          return -1;
  21.       } else {
  22.          int c = this.field_1.read();
  23.          if (c != -1) {
  24.             return c;
  25.          } else {
  26.             this.field_1.close();
  27.  
  28.             for(this.field_1 = null; this.field_0.hasMoreElements() && this.field_1 == null; this.field_1 = (InputStream)this.field_0.nextElement()) {
  29.             }
  30.  
  31.             return this.read();
  32.          }
  33.       }
  34.    }
  35.  
  36.    public int read(byte[] buf, int pos, int len) throws IOException {
  37.       if (this.field_1 == null) {
  38.          return -1;
  39.       } else {
  40.          int n = this.field_1.read(buf, pos, len);
  41.          if (n < len) {
  42.             if (n < 0) {
  43.                n = 0;
  44.             }
  45.  
  46.             this.field_1.close();
  47.             this.field_1 = this.field_0.hasMoreElements() ? (InputStream)this.field_0.nextElement() : null;
  48.             int m = this.read(buf, pos + n, len - n);
  49.             return m > 0 ? n + m : n;
  50.          } else {
  51.             return n;
  52.          }
  53.       }
  54.    }
  55. }
  56.