/** * Creates a protobuf pipe from a byte array. */ public static Pipe newPipe(byte[] data, int offset, int len) { final ByteArrayInput byteArrayInput = new ByteArrayInput(data, offset, len, false); return new Pipe() { protected Input begin(Pipe.Schema<?> pipeSchema) throws IOException { return byteArrayInput; } protected void end(Pipe.Schema<?> pipeSchema, Input input, boolean cleanupOnly) throws IOException { if(cleanupOnly) return; assert input == byteArrayInput; } }; }
/** * Creates a protostuff pipe from a byte array. */ public static Pipe newPipe(byte[] data, int offset, int len) { final ByteArrayInput byteArrayInput = new ByteArrayInput(data, offset, len, true); return new Pipe() { protected Input begin(Pipe.Schema<?> pipeSchema) throws IOException { return byteArrayInput; } protected void end(Pipe.Schema<?> pipeSchema, Input input, boolean cleanupOnly) throws IOException { if(cleanupOnly) return; assert input == byteArrayInput; } }; }
public Protostuff(RpcProtocol protocol, RpcWorker worker, WriteSession session, int nextBufferSize) { super("protostuff", true); output = new ProtostuffOutput(session.head, DUMMY_OUT, this, nextBufferSize); response = new Response(worker, output, protocol); inBuffer = session.head.buffer; input = new ByteArrayInput(inBuffer, 0, 0, true); }
/** * Merges the {@code message} with the byte array using the given {@code schema}. */ static <T> void mergeFrom(byte[] data, int offset, int length, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup) { try { final ByteArrayInput input = new ByteArrayInput(data, offset, length, decodeNestedMessageAsGroup); schema.mergeFrom(input, message); input.checkLastTagWas(0); } catch(ArrayIndexOutOfBoundsException ae) { throw new RuntimeException("Truncated.", ProtobufException.truncatedMessage(ae)); } catch (IOException e) { throw new RuntimeException("Reading from a byte array threw an IOException (should " + "never happen).",e); } }
/** * Merges the {@code message} with the byte array using the given {@code schema}. */ public static <T> void mergeFrom(byte[] data, int offset, int length, T message, Schema<T> schema) { try { final ByteArrayInput input = new ByteArrayInput(data, offset, length, true); final GraphByteArrayInput graphInput = new GraphByteArrayInput(input); schema.mergeFrom(graphInput, message); input.checkLastTagWas(0); } catch(ArrayIndexOutOfBoundsException ae) { throw new RuntimeException("Truncated.", ProtobufException.truncatedMessage(ae)); } catch (IOException e) { throw new RuntimeException("Reading from a byte array threw an IOException (should " + "never happen).",e); } }
final ByteArrayInput input = new ByteArrayInput(buffer.buffer, buffer.offset, size, true); try
final ByteArrayInput input = new ByteArrayInput(buffer.buffer, buffer.offset, size, false); try
final ByteArrayInput input = new ByteArrayInput(buf, 0, len, decodeNestedMessageAsGroup); try
final ByteArrayInput input = new ByteArrayInput(buffer.buffer, buffer.offset, size, true); final GraphByteArrayInput graphInput = new GraphByteArrayInput(input);
final ByteArrayInput input = new ByteArrayInput(buf, 0, len, false); try
final ByteArrayInput input = new ByteArrayInput(buf, 0, len, decodeNestedMessageAsGroup); try
final ByteArrayInput input = new ByteArrayInput(buf, 0, len, true); final GraphByteArrayInput graphInput = new GraphByteArrayInput(input);
final ByteArrayInput input = new ByteArrayInput(buf, 0, len, decodeNestedMessageAsGroup); try
final ByteArrayInput input = new ByteArrayInput(buf, 0, len, true); final GraphByteArrayInput graphInput = new GraphByteArrayInput(input);
final ByteArrayInput input = new ByteArrayInput(buf, 0, len, true); final GraphByteArrayInput graphInput = new GraphByteArrayInput(input);
new ByteArrayInput(inBuffer, offset, limit, true);