package net.pixelcop.sewer;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * Simple Event implementation wrapping a byte array
 *
 * @author chetan
 *
 */
public class ByteArrayEvent implements Event {

    private byte[] body;

    public ByteArrayEvent() {
    }

    public ByteArrayEvent(byte[] body) {
        this.body = body;
    }

    public ByteArrayEvent(DataInput in) throws IOException {
        readFields(in);
    }

    @Override
    public void write(DataOutput out) throws IOException {
        out.writeInt(body.length);
        out.write(body);
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        this.body = new byte[in.readInt()];
        in.readFully(body);
    }

    @Override
    public String toString() {
      return new String(body);
    }

}

@@ -253,20 +253,124 @@
 ate 
-byte%5B%5D body;
+static final String NULL = %22null%22;%0A%0A    private byte%5B%5D body; // TODO use re-usable buffer for reading sequence files
 %0A%0A  
@@ -906,24 +906,79 @@
 oString() %7B%0A
+      if (body == null) %7B%0A        return NULL;%0A      %7D%0A
       return

handle NPE in toString()