public Definition getDefinition() {
return definition;
}
public int writeBlock(Block block, OutputStream os) throws IOException {
ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream();
block.bytes = writeData(baos, block.data, block.method);
block.dataBytes = block.data.length;
ExposedByteArrayOutputStream baos2 = new ExposedByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos2);
dos.writeByte(block.contentType);
dos.writeShort(block.contentId);
dos.writeByte(block.method);
dos.writeInt(block.bytes);
dos.writeInt(block.dataBytes);
int len = 1 + 2 + 1 + 4 + 4;
dos.write(baos.getBuffer(), 0, baos.size());
len += block.bytes;
dos.close();
os.write(baos2.getBuffer(), 0, baos2.size());
// System.out.printf("block written: %d, %d, %d, %d, %d, %s\n",
// block.contentType, block.contentId, block.method, block.bytes,
// block.dataBytes, flanksToHex(block.data, 10));
return len;