Top Description Fields Constructors Methods
com.google.protobuf

public abstract Class AbstractParser<MessageType extends com.google.protobuf.MessageLite>

extends Object
implements Parser<MessageType extends MessageLite>
Class Inheritance
All Implemented Interfaces
com.google.protobuf.Parser
Known Direct Subclasses
com.google.protobuf.GeneratedMessageLite.DefaultInstanceBasedParser, com.google.protobuf.UnknownFieldSet.Parser
Imports
com.google.protobuf.AbstractMessageLite.Builder.LimitedInputStream, java.io.IOException, .InputStream, java.nio.ByteBuffer

A partial implementation of the Parser interface which implements as many methods of that interface as possible in terms of other methods.

Note

This class implements all the convenience methods in the Parser interface. See Parser for related javadocs. Subclasses need to implement Parser#parsePartialFrom(CodedInputStream, ExtensionRegistryLite)

Author
[email protected] (Pherl Liu)

Field Summary

Modifier and TypeField and Description
private static final ExtensionRegistryLite

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private MessageType

Returns:

The message to check.
checkMessageInitialized
(MessageType message)

Helper method to check if message is initialized.

private UninitializedMessageException
newUninitializedMessageException(MessageType message)

Creates an UninitializedMessageException for MessageType.

public MessageType
public MessageType
public MessageType
parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

Implements com.google.protobuf.Parser.parseFrom.

Like parseFrom(CodedInputStream), but also parses extensions.
public MessageType
parseFrom(CodedInputStream input)

Implements com.google.protobuf.Parser.parseFrom.

Parses a message of MessageType from the input.
public MessageType
parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

Implements com.google.protobuf.Parser.parseFrom.

Parses data as a message of MessageType.
public MessageType
parseFrom(ByteString data)

Implements com.google.protobuf.Parser.parseFrom.

Parses data as a message of MessageType.
public MessageType
parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)

Implements com.google.protobuf.Parser.parseFrom.

Parses data as a message of MessageType.
public MessageType
parseFrom(ByteBuffer data)

Implements com.google.protobuf.Parser.parseFrom.

Parses data as a message of MessageType.
public MessageType
parseFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)

Implements com.google.protobuf.Parser.parseFrom.

Parses data as a message of MessageType.
public MessageType
parseFrom(byte[] data, int off, int len)

Implements com.google.protobuf.Parser.parseFrom.

Parses data as a message of MessageType.
public MessageType
parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

Implements com.google.protobuf.Parser.parseFrom.

Parses data as a message of MessageType.
public MessageType
parseFrom(byte[] data)

Implements com.google.protobuf.Parser.parseFrom.

Parses data as a message of MessageType.
public MessageType
parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

Implements com.google.protobuf.Parser.parseFrom.

Parses a message of MessageType from input.
public MessageType
parseFrom(InputStream input)

Implements com.google.protobuf.Parser.parseFrom.

Parse a message of MessageType from input.
public MessageType
parsePartialDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

Implements com.google.protobuf.Parser.parsePartialDelimitedFrom.

Like parseDelimitedFrom(InputStream, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields.
public MessageType
parsePartialDelimitedFrom(InputStream input)

Implements com.google.protobuf.Parser.parsePartialDelimitedFrom.

Like parseDelimitedFrom(InputStream), but does not throw an exception if the message is missing required fields.
public MessageType
parsePartialFrom(CodedInputStream input)

Implements com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(CodedInputStream), but does not throw an exception if the message is missing required fields.
public MessageType
parsePartialFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

Implements com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(ByteString, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields.
public MessageType
parsePartialFrom(ByteString data)

Implements com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(ByteString), but does not throw an exception if the message is missing required fields.
public MessageType
parsePartialFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)

Implements com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(ByteString, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields.
public MessageType
parsePartialFrom(byte[] data, int off, int len)

Implements com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(byte[], int, int), but does not throw an exception if the message is missing required fields.
public MessageType
parsePartialFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

Implements com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(byte[], ExtensionRegistryLite), but does not throw an exception if the message is missing required fields.
public MessageType
parsePartialFrom(byte[] data)

Implements com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(byte[]), but does not throw an exception if the message is missing required fields.
public MessageType
parsePartialFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

Implements com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(InputStream, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields.
public MessageType
parsePartialFrom(InputStream input)

Implements com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(InputStream), but does not throw an exception if the message is missing required fields.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EMPTY_REGISTRYback to summary
private static final ExtensionRegistryLite EMPTY_REGISTRY

Constructor Detail

AbstractParserback to summary
public AbstractParser()

Method Detail

checkMessageInitializedback to summary
private MessageType checkMessageInitialized(MessageType message) throws InvalidProtocolBufferException

Helper method to check if message is initialized.

Returns:MessageType

The message to check.

Exceptions
InvalidProtocolBufferException:
if it is not initialized.
newUninitializedMessageExceptionback to summary
private UninitializedMessageException newUninitializedMessageException(MessageType message)

Creates an UninitializedMessageException for MessageType.

parseDelimitedFromback to summary
public MessageType parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parseDelimitedFrom.

Doc from com.google.protobuf.Parser.parseDelimitedFrom.

Like parseDelimitedFrom(InputStream) but supporting extensions.

Annotations
@Override
parseDelimitedFromback to summary
public MessageType parseDelimitedFrom(InputStream input) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parseDelimitedFrom.

Doc from com.google.protobuf.Parser.parseDelimitedFrom.

Like parseFrom(InputStream), but does not read until EOF. Instead, the size of message (encoded as a varint) is read first, then the message data. Use MessageLite#writeDelimitedTo(java.io.OutputStream) to write messages in this format.

Returns:MessageType

Parsed message if successful, or null if the stream is at EOF when the method starts. Any other error (including reaching EOF during parsing) will cause an exception to be thrown.

Annotations
@Override
parseFromback to summary
public MessageType parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parseFrom.

Doc from com.google.protobuf.Parser.parseFrom.

Like parseFrom(CodedInputStream), but also parses extensions. The extensions that you want to be able to parse must be registered in extensionRegistry. Extensions not in the registry will be treated as unknown fields.

Annotations
@Override
parseFromback to summary
public MessageType parseFrom(CodedInputStream input) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parseFrom.

Doc from com.google.protobuf.Parser.parseFrom.

Parses a message of MessageType from the input.

Note

The caller should call CodedInputStream#checkLastTagWas(int) after calling this to verify that the last tag seen was the appropriate end-group tag, or zero for EOF.

Annotations
@Override
parseFromback to summary
public MessageType parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parseFrom.

Doc from com.google.protobuf.Parser.parseFrom.

Parses data as a message of MessageType. This is just a small wrapper around parseFrom(CodedInputStream, ExtensionRegistryLite).

Annotations
@Override
parseFromback to summary
public MessageType parseFrom(ByteString data) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parseFrom.

Doc from com.google.protobuf.Parser.parseFrom.

Parses data as a message of MessageType. This is just a small wrapper around parseFrom(CodedInputStream).

Annotations
@Override
parseFromback to summary
public MessageType parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parseFrom.

Doc from com.google.protobuf.Parser.parseFrom.

Parses data as a message of MessageType. This is just a small wrapper around parseFrom(CodedInputStream, ExtensionRegistryLite).

Annotations
@Override
parseFromback to summary
public MessageType parseFrom(ByteBuffer data) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parseFrom.

Doc from com.google.protobuf.Parser.parseFrom.

Parses data as a message of MessageType. This is just a small wrapper around parseFrom(CodedInputStream).

Annotations
@Override
parseFromback to summary
public MessageType parseFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parseFrom.

Doc from com.google.protobuf.Parser.parseFrom.

Parses data as a message of MessageType. This is just a small wrapper around parseFrom(CodedInputStream, ExtensionRegistryLite).

Annotations
@Override
parseFromback to summary
public MessageType parseFrom(byte[] data, int off, int len) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parseFrom.

Doc from com.google.protobuf.Parser.parseFrom.

Parses data as a message of MessageType. This is just a small wrapper around parseFrom(CodedInputStream).

Annotations
@Override
parseFromback to summary
public MessageType parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parseFrom.

Doc from com.google.protobuf.Parser.parseFrom.

Parses data as a message of MessageType. This is just a small wrapper around parseFrom(CodedInputStream, ExtensionRegistryLite).

Annotations
@Override
parseFromback to summary
public MessageType parseFrom(byte[] data) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parseFrom.

Doc from com.google.protobuf.Parser.parseFrom.

Parses data as a message of MessageType. This is just a small wrapper around parseFrom(CodedInputStream).

Annotations
@Override
parseFromback to summary
public MessageType parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parseFrom.

Doc from com.google.protobuf.Parser.parseFrom.

Parses a message of MessageType from input. This is just a small wrapper around parseFrom(CodedInputStream, ExtensionRegistryLite).

Annotations
@Override
parseFromback to summary
public MessageType parseFrom(InputStream input) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parseFrom.

Doc from com.google.protobuf.Parser.parseFrom.

Parse a message of MessageType from input. This is just a small wrapper around parseFrom(CodedInputStream). Note that this method always reads the entire input (unless it throws an exception). If you want it to stop earlier, you will need to wrap your input in some wrapper stream that limits reading. Or, use MessageLite#writeDelimitedTo(java.io.OutputStream) to write your message and parseDelimitedFrom(InputStream) to read it.

Despite usually reading the entire input, this does not close the stream.

Annotations
@Override
parsePartialDelimitedFromback to summary
public MessageType parsePartialDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parsePartialDelimitedFrom.

Doc from com.google.protobuf.Parser.parsePartialDelimitedFrom.

Like parseDelimitedFrom(InputStream, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Annotations
@Override
parsePartialDelimitedFromback to summary
public MessageType parsePartialDelimitedFrom(InputStream input) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parsePartialDelimitedFrom.

Doc from com.google.protobuf.Parser.parsePartialDelimitedFrom.

Like parseDelimitedFrom(InputStream), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Annotations
@Override
parsePartialFromback to summary
public MessageType parsePartialFrom(CodedInputStream input) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parsePartialFrom.

Doc from com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(CodedInputStream), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Annotations
@Override
parsePartialFromback to summary
public MessageType parsePartialFrom(ByteString data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parsePartialFrom.

Doc from com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(ByteString, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Annotations
@Override
parsePartialFromback to summary
public MessageType parsePartialFrom(ByteString data) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parsePartialFrom.

Doc from com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(ByteString), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Annotations
@Override
parsePartialFromback to summary
public MessageType parsePartialFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parsePartialFrom.

Doc from com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(ByteString, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Annotations
@Override
parsePartialFromback to summary
public MessageType parsePartialFrom(byte[] data, int off, int len) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parsePartialFrom.

Doc from com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(byte[], int, int), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Annotations
@Override
parsePartialFromback to summary
public MessageType parsePartialFrom(byte[] data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parsePartialFrom.

Doc from com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(byte[], ExtensionRegistryLite), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Annotations
@Override
parsePartialFromback to summary
public MessageType parsePartialFrom(byte[] data) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parsePartialFrom.

Doc from com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(byte[]), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Annotations
@Override
parsePartialFromback to summary
public MessageType parsePartialFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parsePartialFrom.

Doc from com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(InputStream, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Annotations
@Override
parsePartialFromback to summary
public MessageType parsePartialFrom(InputStream input) throws InvalidProtocolBufferException

Implements com.google.protobuf.Parser.parsePartialFrom.

Doc from com.google.protobuf.Parser.parsePartialFrom.

Like parseFrom(InputStream), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Annotations
@Override