Class AbstractParser<MessageType>

public abstract class AbstractParser<MessageType> implements Parser<MessageType>

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)

Inheritance

java.lang.Object > AbstractParser<MessageType>

Implements

com.google.protobuf.Parser<MessageType>

Type Parameter

NameDescription
MessageType

Constructors

AbstractParser()

public AbstractParser()

Methods

parseDelimitedFrom(InputStream input)

public MessageType parseDelimitedFrom(InputStream input)

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.

Parameter
NameDescription
inputInputStream
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public MessageType parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

Like #parseDelimitedFrom(InputStream) but supporting extensions.

Parameters
NameDescription
inputInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(byte[] data)

public MessageType parseFrom(byte[] data)

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

Parameter
NameDescription
databyte[]
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

public MessageType parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

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

Parameters
NameDescription
databyte[]
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(byte[] data, int off, int len)

public MessageType parseFrom(byte[] data, int off, int len)

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

Parameters
NameDescription
databyte[]
offint
lenint
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)

public MessageType parseFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)

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

Parameters
NameDescription
databyte[]
offint
lenint
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteString data)

public MessageType parseFrom(ByteString data)

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

Parameter
NameDescription
dataByteString
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

public MessageType parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

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

Parameters
NameDescription
dataByteString
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(CodedInputStream input)

public MessageType parseFrom(CodedInputStream input)

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.

Parameter
NameDescription
inputCodedInputStream
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public MessageType parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

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.

Parameters
NameDescription
inputCodedInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(InputStream input)

public MessageType parseFrom(InputStream input)

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.

Parameter
NameDescription
inputInputStream
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public MessageType parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

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

Parameters
NameDescription
inputInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteBuffer data)

public MessageType parseFrom(ByteBuffer data)

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

Parameter
NameDescription
dataByteBuffer
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)

public MessageType parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)

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

Parameters
NameDescription
dataByteBuffer
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parsePartialDelimitedFrom(InputStream input)

public MessageType parsePartialDelimitedFrom(InputStream input)

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

Parameter
NameDescription
inputInputStream
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parsePartialDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public MessageType parsePartialDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

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

Parameters
NameDescription
inputInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parsePartialFrom(byte[] data)

public MessageType parsePartialFrom(byte[] data)

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

Parameter
NameDescription
databyte[]
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parsePartialFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

public MessageType parsePartialFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

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

Parameters
NameDescription
databyte[]
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parsePartialFrom(byte[] data, int off, int len)

public MessageType parsePartialFrom(byte[] data, int off, int len)

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

Parameters
NameDescription
databyte[]
offint
lenint
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parsePartialFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)

public MessageType parsePartialFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)

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

Parameters
NameDescription
databyte[]
offint
lenint
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parsePartialFrom(ByteString data)

public MessageType parsePartialFrom(ByteString data)

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

Parameter
NameDescription
dataByteString
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parsePartialFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

public MessageType parsePartialFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

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

Parameters
NameDescription
dataByteString
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parsePartialFrom(CodedInputStream input)

public MessageType parsePartialFrom(CodedInputStream input)

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

Parameter
NameDescription
inputCodedInputStream
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parsePartialFrom(InputStream input)

public MessageType parsePartialFrom(InputStream input)

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

Parameter
NameDescription
inputInputStream
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException

parsePartialFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public MessageType parsePartialFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

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

Parameters
NameDescription
inputInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
MessageType
Exceptions
TypeDescription
InvalidProtocolBufferException