class ByteAccumulator {

    public void copyChunk(byte[] buf, int offset, int length) {
        if (this.length + length > maxSize) {
            String err = String.format("Resulting message size [%,d] is too large for configured max of [%,d]", this.length + length, maxSize);
            throw new MessageTooLargeException(err);
        }

        byte[] copy = new byte[length - offset];
        System.arraycopy(buf, offset, copy, 0, length);

        chunks.add(copy);
        this.length += length;
    }

    public  ByteAccumulator(int maxOverallBufferSize);

}