public interface Parser<MessageType>
Abstract interface for parsing Protocol Messages.
The implementation should be stateless and thread-safe.
All methods may throw InvalidProtocolBufferException. In the event of invalid data,
like an encoding error, the cause of the thrown exception will be null
. However, if an
I/O problem occurs, an exception is thrown with an java.io.IOException cause.
Type Parameter
Name | Description |
MessageType | |
Methods
public abstract MessageType parseDelimitedFrom(InputStream input)
Parameter
Returns
Type | Description |
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.
|
Exceptions
public abstract MessageType parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Returns
Type | Description |
MessageType | |
Exceptions
parseFrom(byte[] data)
public abstract MessageType parseFrom(byte[] data)
Parameter
Name | Description |
data | byte[]
|
Returns
Type | Description |
MessageType | |
Exceptions
parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
public abstract MessageType parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
Parameters
Returns
Type | Description |
MessageType | |
Exceptions
parseFrom(byte[] data, int off, int len)
public abstract MessageType parseFrom(byte[] data, int off, int len)
Parameters
Returns
Type | Description |
MessageType | |
Exceptions
parseFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)
public abstract MessageType parseFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)
Parameters
Returns
Type | Description |
MessageType | |
Exceptions
parseFrom(ByteString data)
public abstract MessageType parseFrom(ByteString data)
Parameter
Returns
Type | Description |
MessageType | |
Exceptions
parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
public abstract MessageType parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
Parameters
Returns
Type | Description |
MessageType | |
Exceptions
public abstract 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
Returns
Type | Description |
MessageType | |
Exceptions
public abstract 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
Returns
Type | Description |
MessageType | |
Exceptions
public abstract MessageType parseFrom(InputStream input)
Parameter
Returns
Type | Description |
MessageType | |
Exceptions
public abstract MessageType parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Returns
Type | Description |
MessageType | |
Exceptions
parseFrom(ByteBuffer data)
public abstract MessageType parseFrom(ByteBuffer data)
Parameter
Returns
Type | Description |
MessageType | |
Exceptions
parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)
public abstract MessageType parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)
Parameters
Returns
Type | Description |
MessageType | |
Exceptions
public abstract MessageType parsePartialDelimitedFrom(InputStream input)
Parameter
Returns
Type | Description |
MessageType | |
Exceptions
public abstract MessageType parsePartialDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Returns
Type | Description |
MessageType | |
Exceptions
parsePartialFrom(byte[] data)
public abstract 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
Name | Description |
data | byte[]
|
Returns
Type | Description |
MessageType | |
Exceptions
parsePartialFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
public abstract MessageType parsePartialFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
Parameters
Returns
Type | Description |
MessageType | |
Exceptions
parsePartialFrom(byte[] data, int off, int len)
public abstract 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
Returns
Type | Description |
MessageType | |
Exceptions
parsePartialFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)
public abstract MessageType parsePartialFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)
Parameters
Returns
Type | Description |
MessageType | |
Exceptions
parsePartialFrom(ByteString data)
public abstract 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
Returns
Type | Description |
MessageType | |
Exceptions
parsePartialFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
public abstract MessageType parsePartialFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
Parameters
Returns
Type | Description |
MessageType | |
Exceptions
public abstract 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
Returns
Type | Description |
MessageType | |
Exceptions
public abstract MessageType parsePartialFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Returns
Type | Description |
MessageType | |
Exceptions
public abstract 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
Returns
Type | Description |
MessageType | |
Exceptions
public abstract MessageType parsePartialFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Returns
Type | Description |
MessageType | |
Exceptions