/** * Merges the {@code message} from the {@link InputStream} with the supplied * {@code buf} to use. */ static <T> void mergeFrom(InputStream in, byte[] buf, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup) throws IOException { final CodedInput input = new CodedInput(in, buf, decodeNestedMessageAsGroup); schema.mergeFrom(input, message); input.checkLastTagWas(0); }
/** * Merges the {@code message} from the {@link InputStream} using the given {@code schema}. */ static <T> void mergeFrom(InputStream in, T message, Schema<T> schema, boolean decodeNestedMessageAsGroup) throws IOException { final CodedInput input = new CodedInput(in, decodeNestedMessageAsGroup); schema.mergeFrom(input, message); input.checkLastTagWas(0); }
/** * Merges the {@code message} from the {@link InputStream} using * the given {@code schema}. */ public static <T> void mergeFrom(InputStream in, T message, Schema<T> schema) throws IOException { final CodedInput input = new CodedInput(in, true); final GraphCodedInput graphInput = new GraphCodedInput(input); schema.mergeFrom(graphInput, message); input.checkLastTagWas(0); }
/** * Parses the {@code messages} (delimited) from the {@link InputStream} * using the given {@code schema}. * * @return the list containing the messages. */ public static <T> List<T> parseListFrom(final InputStream in, final Schema<T> schema) throws IOException { int size = in.read(); if(size == -1) return Collections.emptyList(); if(size > 0x7f) size = CodedInput.readRawVarint32(in, size); final ArrayList<T> list = new ArrayList<T>(size); final CodedInput input = new CodedInput(in, true); for(int i = 0; i < size; i++) { final T message = schema.newMessage(); list.add(message); schema.mergeFrom(input, message); input.checkLastTagWas(0); } assert in.read() == -1; return list; }
/** * Merges the {@code message} from the {@link InputStream} using * the given {@code schema}. * * The {@code buffer}'s internal byte array will be used for reading the message. */ public static <T> void mergeFrom(InputStream in, T message, Schema<T> schema, LinkedBuffer buffer) throws IOException { final CodedInput input = new CodedInput(in, buffer.buffer, true); final GraphCodedInput graphInput = new GraphCodedInput(input); schema.mergeFrom(graphInput, message); input.checkLastTagWas(0); }
/** Reads a message field value from the stream (using the {@code group} encoding). */ private <T> T mergeObjectEncodedAsGroup(T value, final Schema<T> schema) throws IOException { //if (recursionDepth >= recursionLimit) { // throw ProtobufException.recursionLimitExceeded(); //} //++recursionDepth; if(value == null) { value = schema.newMessage(); } schema.mergeFrom(this, value); if(!schema.isInitialized(value)) { throw new UninitializedMessageException(value, schema); } // handling is in #readFieldNumber checkLastTagWas(0); //--recursionDepth; return value; }
final CodedInput input = new CodedInput(lin.limit(len), false); schema.mergeFrom(input, message); input.checkLastTagWas(0); continue;
decodeNestedMessageAsGroup); schema.mergeFrom(input, message); input.checkLastTagWas(0); return len;
public <T> T mergeObject(T value, final Schema<T> schema) throws IOException { if(decodeNestedMessageAsGroup) return mergeObjectEncodedAsGroup(value, schema); final int length = readRawVarint32(); //if (recursionDepth >= recursionLimit) { // throw ProtobufException.recursionLimitExceeded(); //} final int oldLimit = pushLimit(length); //++recursionDepth; if(value == null) { value = schema.newMessage(); } schema.mergeFrom(this, value); if(!schema.isInitialized(value)) { throw new UninitializedMessageException(value, schema); } checkLastTagWas(0); //--recursionDepth; popLimit(oldLimit); return value; }
decodeNestedMessageAsGroup); schema.mergeFrom(input, message); input.checkLastTagWas(0);
final GraphCodedInput graphInput = new GraphCodedInput(input); schema.mergeFrom(graphInput, message); input.checkLastTagWas(0);
case WireFormat.WIRETYPE_START_GROUP: skipMessage(); checkLastTagWas( WireFormat.makeTag(WireFormat.getTagFieldNumber(tag), WireFormat.WIRETYPE_END_GROUP));
final GraphCodedInput graphInput = new GraphCodedInput(input); schema.mergeFrom(graphInput, message); input.checkLastTagWas(0); return len;