public CodedOutputStream(Buffer data) { super(new BufferOutputStream(data)); }
public void write(int b) throws IOException { int newPos = pos + 1; checkCapacity(newPos); buffer[pos] = (byte) b; pos = newPos; }
public Buffer getNextBuffer(int size) throws IOException { if( bos==null ) { return null; } return bos.getNextBuffer(size); }
static public Buffer toFramedBuffer(MessageBuffer message) { try { int size = message.serializedSizeFramed(); BufferOutputStream baos = new BufferOutputStream(size); CodedOutputStream output = new CodedOutputStream(baos); message.writeFramed(output); Buffer rc = baos.toBuffer(); assert rc.length==size : "Did not write as much data as expected."; return rc; } catch (IOException e) { throw new RuntimeException("Serializing to a byte array threw an IOException " + "(should never happen).", e); } }
public byte[] toByteArray() { return toBuffer().toByteArray(); }
static public Buffer toUnframedBuffer(MessageBuffer message) { try { int size = message.serializedSizeUnframed(); BufferOutputStream baos = new BufferOutputStream(size); CodedOutputStream output = new CodedOutputStream(baos); message.writeUnframed(output); Buffer rc = baos.toBuffer(); assert rc.length == size : "Did not write as much data as expected."; return rc; } catch (IOException e) { throw new RuntimeException("Serializing to a byte array threw an IOException " + "(should never happen).", e); } }
public byte[] toByteArray() { return toBuffer().toByteArray(); }
static public Buffer toFramedBuffer(MessageBuffer message) { try { int size = message.serializedSizeFramed(); BufferOutputStream baos = new BufferOutputStream(size); CodedOutputStream output = new CodedOutputStream(baos); message.writeFramed(output); Buffer rc = baos.toBuffer(); assert rc.length==size : "Did not write as much data as expected."; return rc; } catch (IOException e) { throw new RuntimeException("Serializing to a byte array threw an IOException " + "(should never happen).", e); } }
public void write(int b) throws IOException { int newPos = pos + 1; checkCapacity(newPos); buffer[pos] = (byte) b; pos = newPos; }
final public BufferOutputStream newOutput() { return new BufferOutputStream(this); }
public Buffer getNextBuffer(int size) throws IOException { if( bos==null ) { return null; } return bos.getNextBuffer(size); }
public byte[] toByteArray() { return toBuffer().toByteArray(); }
static public Buffer toFramedBuffer(MessageBuffer message) { try { int size = message.serializedSizeFramed(); BufferOutputStream baos = new BufferOutputStream(size); CodedOutputStream output = new CodedOutputStream(baos); message.writeFramed(output); Buffer rc = baos.toBuffer(); assert rc.length==size : "Did not write as much data as expected."; return rc; } catch (IOException e) { throw new RuntimeException("Serializing to a byte array threw an IOException " + "(should never happen).", e); } }
public void write(int b) throws IOException { int newPos = pos + 1; checkCapacity(newPos); buffer[pos] = (byte) b; pos = newPos; }
public CodedOutputStream(Buffer data) { super(new BufferOutputStream(data)); }
public Buffer getNextBuffer(int size) throws IOException { if( bos==null ) { return null; } return bos.getNextBuffer(size); }
public Buffer toUnframedBuffer() { try { int size = serializedSizeUnframed(); BufferOutputStream baos = new BufferOutputStream(size); CodedOutputStream output = new CodedOutputStream(baos); writeUnframed(output); Buffer rc = baos.toBuffer(); if( rc.length != size ) { throw new IllegalStateException("Did not write as much data as expected."); } return rc; } catch (IOException e) { throw new RuntimeException("Serializing to a byte array threw an IOException " + "(should never happen).", e); } }
public void write(byte b[], int off, int len) throws IOException { int newPos = pos + len; checkCapacity(newPos); System.arraycopy(b, off, buffer, pos, len); pos = newPos; }
public CodedOutputStream(byte[] data) { super(new BufferOutputStream(data)); }
public Buffer toFramedBuffer() { try { int size = serializedSizeFramed(); BufferOutputStream baos = new BufferOutputStream(size); CodedOutputStream output = new CodedOutputStream(baos); writeFramed(output); Buffer rc = baos.toBuffer(); if( rc.length != size ) { throw new IllegalStateException("Did not write as much data as expected."); } return rc; } catch (IOException e) { throw new RuntimeException("Serializing to a byte array threw an IOException " + "(should never happen).", e); } }