package rabbit.zip;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

/** The ending state of gzip packing.
 *
 * @author <a href="mailto:robo@khelekore.org">Robert Olofsson</a>
 */
class TrailerWriter implements GZipPackState {
    private final GZipPackListener listener;
    private final int crc;
    private final int totalIn;
    private boolean finished = false;

    public TrailerWriter (GZipPackListener listener, int crc, int totalIn) {
	this.listener = listener;
	this.crc = crc;
	this.totalIn = totalIn;
    }
    
    public boolean needsInput () {
	return false;
    }

    public void handleBuffer (GZipPacker packer, byte[] buf, int off, int len) {
	throw new IllegalStateException ("Does not need input");
    }

    public void handleCurrentData (GZipPacker packer) {
	finished = true;
	byte[] packed = listener.getBuffer ();
	    ByteBuffer bb = ByteBuffer.wrap (packed);
	    bb.order (ByteOrder.LITTLE_ENDIAN);
	    bb.putInt (crc);
	    bb.putInt (totalIn);
	    listener.packed (packed, 0, 8);
	    listener.finished ();
    }

    public void finish () {
	// ignore
    }

    public boolean finished () {
	return finished;
    }
}

@@ -846,20 +846,16 @@
 er ();%0A%09
-    
 ByteBuff
@@ -889,20 +889,16 @@
 cked);%0A%09
-    
 bb.order
@@ -922,28 +922,24 @@
 E_ENDIAN);%0A%09
-    
 bb.putInt (c
@@ -944,20 +944,16 @@
 (crc);%0A%09
-    
 bb.putIn
@@ -962,28 +962,24 @@
 (totalIn);%0A%09
-    
 listener.pac
@@ -999,20 +999,16 @@
 0, 8);%0A%09
-    
 listener

Fix broken indentation.