/** Read an embedded message field value from the stream. */ public <T extends MessageLite> T readMessage( final Parser<T> parser, final ExtensionRegistryLite extensionRegistry) throws IOException { int length = readRawVarint32(); if (recursionDepth >= recursionLimit) { throw InvalidProtocolBufferException.recursionLimitExceeded(); } final int oldLimit = pushLimit(length); ++recursionDepth; T result = parser.parsePartialFrom(this, extensionRegistry); checkLastTagWas(0); --recursionDepth; popLimit(oldLimit); return result; }
public MessageType parsePartialFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException { CodedInputStream codedInput = CodedInputStream.newInstance(input); MessageType message = parsePartialFrom(codedInput, extensionRegistry); try { codedInput.checkLastTagWas(0); } catch (InvalidProtocolBufferException e) { throw e.setUnfinishedMessage(message); } return message; }
@Override public MessageType parsePartialFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException { CodedInputStream codedInput = CodedInputStream.newInstance(input); MessageType message = parsePartialFrom(codedInput, extensionRegistry); try { codedInput.checkLastTagWas(0); } catch (InvalidProtocolBufferException e) { throw e.setUnfinishedMessage(message); } return message; }
/** Read an embedded message field value from the stream. */ public void readMessage(final MessageLite.Builder builder, final ExtensionRegistryLite extensionRegistry) throws IOException { final int length = readRawVarint32(); if (recursionDepth >= recursionLimit) { throw InvalidProtocolBufferException.recursionLimitExceeded(); } final int oldLimit = pushLimit(length); ++recursionDepth; builder.mergeFrom(this, extensionRegistry); checkLastTagWas(0); --recursionDepth; popLimit(oldLimit); }
/** * Parse an {@code UnknownFieldSet} from {@code input} and merge it with the * set being built. This is just a small wrapper around * {@link #mergeFrom(CodedInputStream)}. */ public Builder mergeFrom(final InputStream input) throws IOException { final CodedInputStream codedInput = CodedInputStream.newInstance(input); mergeFrom(codedInput); codedInput.checkLastTagWas(0); return this; }
public BuilderType mergeFrom(final InputStream input) throws IOException { final CodedInputStream codedInput = CodedInputStream.newInstance(input); mergeFrom(codedInput); codedInput.checkLastTagWas(0); return (BuilderType) this; }
public BuilderType mergeFrom(final ByteString data) throws InvalidProtocolBufferException { try { final CodedInputStream input = data.newCodedInput(); mergeFrom(input); input.checkLastTagWas(0); return (BuilderType) this; } catch (InvalidProtocolBufferException e) { throw e; } catch (IOException e) { throw new RuntimeException( "Reading from a ByteString threw an IOException (should " + "never happen).", e); } }
public BuilderType mergeFrom( final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException { final CodedInputStream codedInput = CodedInputStream.newInstance(input); mergeFrom(codedInput, extensionRegistry); codedInput.checkLastTagWas(0); return (BuilderType) this; }
@Override public Builder mergeFrom(byte[] data, int off, int len) throws InvalidProtocolBufferException { try { final CodedInputStream input = CodedInputStream.newInstance(data, off, len); mergeFrom(input); input.checkLastTagWas(0); return this; } catch (InvalidProtocolBufferException e) { throw e; } catch (IOException e) { throw new RuntimeException( "Reading from a byte array threw an IOException (should " + "never happen).", e); } }
public Builder mergeFrom(byte[] data, int off, int len) throws InvalidProtocolBufferException { try { final CodedInputStream input = CodedInputStream.newInstance(data, off, len); mergeFrom(input); input.checkLastTagWas(0); return this; } catch (InvalidProtocolBufferException e) { throw e; } catch (IOException e) { throw new RuntimeException( "Reading from a byte array threw an IOException (should " + "never happen).", e); } }
/** * Parse an {@code UnknownFieldSet} from {@code input} and merge it with the * set being built. This is just a small wrapper around * {@link #mergeFrom(CodedInputStream)}. */ @Override public Builder mergeFrom(final InputStream input) throws IOException { final CodedInputStream codedInput = CodedInputStream.newInstance(input); mergeFrom(codedInput); codedInput.checkLastTagWas(0); return this; }
@Override public BuilderType mergeFrom(final InputStream input) throws IOException { final CodedInputStream codedInput = CodedInputStream.newInstance(input); mergeFrom(codedInput); codedInput.checkLastTagWas(0); return (BuilderType) this; }
@Override public BuilderType mergeFrom( final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException { final CodedInputStream codedInput = CodedInputStream.newInstance(input); mergeFrom(codedInput, extensionRegistry); codedInput.checkLastTagWas(0); return (BuilderType) this; }
/** Read a {@code group} field value from the stream. */ public <T extends MessageLite> T readGroup( final int fieldNumber, final Parser<T> parser, final ExtensionRegistryLite extensionRegistry) throws IOException { if (recursionDepth >= recursionLimit) { throw InvalidProtocolBufferException.recursionLimitExceeded(); } ++recursionDepth; T result = parser.parsePartialFrom(this, extensionRegistry); checkLastTagWas( WireFormat.makeTag(fieldNumber, WireFormat.WIRETYPE_END_GROUP)); --recursionDepth; return result; }
@Override public BuilderType mergeFrom(final ByteString data) throws InvalidProtocolBufferException { try { final CodedInputStream input = data.newCodedInput(); mergeFrom(input); input.checkLastTagWas(0); return (BuilderType) this; } catch (InvalidProtocolBufferException e) { throw e; } catch (IOException e) { throw new RuntimeException(getReadingExceptionMessage("ByteString"), e); } }
@Override public BuilderType mergeFrom( final ByteString data, final ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException { try { final CodedInputStream input = data.newCodedInput(); mergeFrom(input, extensionRegistry); input.checkLastTagWas(0); return (BuilderType) this; } catch (InvalidProtocolBufferException e) { throw e; } catch (IOException e) { throw new RuntimeException(getReadingExceptionMessage("ByteString"), e); } }
@Override public BuilderType mergeFrom(final byte[] data, final int off, final int len) throws InvalidProtocolBufferException { try { final CodedInputStream input = CodedInputStream.newInstance(data, off, len); mergeFrom(input); input.checkLastTagWas(0); return (BuilderType) this; } catch (InvalidProtocolBufferException e) { throw e; } catch (IOException e) { throw new RuntimeException(getReadingExceptionMessage("byte array"), e); } }
/** * This version of protobuf's mergeFrom avoids the hard-coded 64MB limit for decoding * buffers when working with byte arrays * @param builder current message builder * @param b byte array * @throws IOException */ public static void mergeFrom(Message.Builder builder, byte[] b) throws IOException { final CodedInputStream codedInput = CodedInputStream.newInstance(b); codedInput.setSizeLimit(b.length); builder.mergeFrom(codedInput); codedInput.checkLastTagWas(0); }
/** Read a {@code group} field value from the stream. */ public void readGroup(final int fieldNumber, final MessageLite.Builder builder, final ExtensionRegistryLite extensionRegistry) throws IOException { if (recursionDepth >= recursionLimit) { throw InvalidProtocolBufferException.recursionLimitExceeded(); } ++recursionDepth; builder.mergeFrom(this, extensionRegistry); checkLastTagWas( WireFormat.makeTag(fieldNumber, WireFormat.WIRETYPE_END_GROUP)); --recursionDepth; }
/** * This version of protobuf's mergeFrom avoids the hard-coded 64MB limit for decoding * buffers when working with byte arrays * @param builder current message builder * @param b byte array * @param offset * @param length * @throws IOException */ public static void mergeFrom(Message.Builder builder, byte[] b, int offset, int length) throws IOException { final CodedInputStream codedInput = CodedInputStream.newInstance(b, offset, length); codedInput.setSizeLimit(length); builder.mergeFrom(codedInput); codedInput.checkLastTagWas(0); }