InflaterSource.java 2.87 KB
package okio;

import java.io.EOFException;
import java.io.IOException;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
import tx;
import ty;

public final class InflaterSource
  implements Source
{
  private final BufferedSource a;
  private final Inflater b;
  private int c;
  private boolean d;
  
  InflaterSource(BufferedSource paramBufferedSource, Inflater paramInflater)
  {
    if (paramBufferedSource == null) {
      throw new IllegalArgumentException("source == null");
    }
    if (paramInflater == null) {
      throw new IllegalArgumentException("inflater == null");
    }
    this.a = paramBufferedSource;
    this.b = paramInflater;
  }
  
  public InflaterSource(Source paramSource, Inflater paramInflater)
  {
    this(Okio.buffer(paramSource), paramInflater);
  }
  
  private void a()
    throws IOException
  {
    if (this.c == 0) {
      return;
    }
    int i = this.c - this.b.getRemaining();
    this.c -= i;
    this.a.skip(i);
  }
  
  public final void close()
    throws IOException
  {
    if (this.d) {
      return;
    }
    this.b.end();
    this.d = true;
    this.a.close();
  }
  
  public final long read(Buffer paramBuffer, long paramLong)
    throws IOException
  {
    if (paramLong < 0L) {
      throw new IllegalArgumentException("byteCount < 0: " + paramLong);
    }
    if (this.d) {
      throw new IllegalStateException("closed");
    }
    if (paramLong == 0L) {
      return 0L;
    }
    for (;;)
    {
      boolean bool = refill();
      try
      {
        tx localtx = paramBuffer.a(1);
        int i = this.b.inflate(localtx.a, localtx.c, 2048 - localtx.c);
        if (i > 0)
        {
          localtx.c += i;
          paramBuffer.b += i;
          return i;
        }
        if ((this.b.finished()) || (this.b.needsDictionary()))
        {
          a();
          if (localtx.b == localtx.c)
          {
            paramBuffer.a = localtx.a();
            ty.a(localtx);
          }
        }
        else
        {
          if (!bool) {
            continue;
          }
          throw new EOFException("source exhausted prematurely");
        }
      }
      catch (DataFormatException paramBuffer)
      {
        throw new IOException(paramBuffer);
      }
    }
    return -1L;
  }
  
  public final boolean refill()
    throws IOException
  {
    if (!this.b.needsInput()) {
      return false;
    }
    a();
    if (this.b.getRemaining() != 0) {
      throw new IllegalStateException("?");
    }
    if (this.a.exhausted()) {
      return true;
    }
    tx localtx = this.a.buffer().a;
    this.c = (localtx.c - localtx.b);
    this.b.setInput(localtx.a, localtx.b, this.c);
    return false;
  }
  
  public final Timeout timeout()
  {
    return this.a.timeout();
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/okio/InflaterSource.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */