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(byte[] body) {
        this.setBody(body);
    }
    
    public ByteArrayEvent(DataInput in) throws IOException {
        readFields(in);
    }

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

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

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

    public byte[] getBody() {
        return body;
    }
    
}

@@ -163,18 +163,17 @@
 array%0A *
- 
 %0A
+
  * @auth
@@ -236,21 +236,17 @@
 Event %7B%0A
-    
 %0A
+
     priv
@@ -262,20 +262,53 @@
 %5D body;%0A
+%0A
     
+public ByteArrayEvent() %7B%0A    %7D%0A
 %0A    pub
@@ -375,20 +375,16 @@
 ;%0A    %7D%0A
-    
 %0A    pub
@@ -904,15 +904,94 @@
 ;%0A    %7D%0A
+%0A
     
+@Override%0A    public String toString() %7B%0A      return new String(body);%0A    %7D%0A
 %0A%7D%0A

make usable in SequenceFiles