DeflaterSink.java 3.54 KB
package okio;

import java.io.IOException;
import java.util.zip.Deflater;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import tx;
import ty;
import ua;

public final class DeflaterSink
  implements Sink
{
  private final BufferedSink a;
  private final Deflater b;
  private boolean c;
  
  DeflaterSink(BufferedSink paramBufferedSink, Deflater paramDeflater)
  {
    if (paramBufferedSink == null) {
      throw new IllegalArgumentException("source == null");
    }
    if (paramDeflater == null) {
      throw new IllegalArgumentException("inflater == null");
    }
    this.a = paramBufferedSink;
    this.b = paramDeflater;
  }
  
  public DeflaterSink(Sink paramSink, Deflater paramDeflater)
  {
    this(Okio.buffer(paramSink), paramDeflater);
  }
  
  @IgnoreJRERequirement
  private void a(boolean paramBoolean)
    throws IOException
  {
    Buffer localBuffer = this.a.buffer();
    tx localtx;
    label119:
    do
    {
      localtx = localBuffer.a(1);
      if (paramBoolean) {}
      for (int i = this.b.deflate(localtx.a, localtx.c, 2048 - localtx.c, 2);; i = this.b.deflate(localtx.a, localtx.c, 2048 - localtx.c))
      {
        if (i <= 0) {
          break label119;
        }
        localtx.c += i;
        localBuffer.b += i;
        this.a.emitCompleteSegments();
        break;
      }
    } while (!this.b.needsInput());
    if (localtx.b == localtx.c)
    {
      localBuffer.a = localtx.a();
      ty.a(localtx);
    }
  }
  
  final void a()
    throws IOException
  {
    this.b.finish();
    a(false);
  }
  
  public final void close()
    throws IOException
  {
    if (this.c) {}
    for (;;)
    {
      return;
      Object localObject3 = null;
      try
      {
        a();
        try
        {
          this.b.end();
          localObject1 = localObject3;
        }
        catch (Throwable localThrowable1)
        {
          for (;;)
          {
            Object localObject1;
            label34:
            if (localObject3 != null) {
              localObject2 = localObject3;
            }
          }
        }
        try
        {
          this.a.close();
          localObject3 = localObject1;
        }
        catch (Throwable localThrowable3)
        {
          localObject3 = localObject2;
          if (localObject2 != null) {
            break label34;
          }
          localObject3 = localThrowable3;
          break label34;
        }
        this.c = true;
        if (localObject3 == null) {
          continue;
        }
        ua.a((Throwable)localObject3);
        return;
      }
      catch (Throwable localThrowable2)
      {
        Object localObject2;
        for (;;) {}
      }
    }
  }
  
  public final void flush()
    throws IOException
  {
    a(true);
    this.a.flush();
  }
  
  public final Timeout timeout()
  {
    return this.a.timeout();
  }
  
  public final String toString()
  {
    return "DeflaterSink(" + this.a + ")";
  }
  
  public final void write(Buffer paramBuffer, long paramLong)
    throws IOException
  {
    ua.a(paramBuffer.b, 0L, paramLong);
    while (paramLong > 0L)
    {
      tx localtx = paramBuffer.a;
      int i = (int)Math.min(paramLong, localtx.c - localtx.b);
      this.b.setInput(localtx.a, localtx.b, i);
      a(false);
      paramBuffer.b -= i;
      localtx.b += i;
      if (localtx.b == localtx.c)
      {
        paramBuffer.a = localtx.a();
        ty.a(localtx);
      }
      paramLong -= i;
    }
  }
}


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