Package com.google.protobuf
Interface Parser<MessageType>
- All Known Implementing Classes:
AbstractParser
,GeneratedMessageLite.DefaultInstanceBasedParser
,UnknownFieldSet.Parser
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 IOException
cause.
-
Method Summary
Modifier and TypeMethodDescriptionparseDelimitedFrom
(InputStream input) LikeparseFrom(InputStream)
, but does not read until EOF.parseDelimitedFrom
(InputStream input, ExtensionRegistryLite extensionRegistry) LikeparseDelimitedFrom(InputStream)
but supporting extensions.parseFrom
(byte[] data) Parsesdata
as a message ofMessageType
.parseFrom
(byte[] data, int off, int len) Parsesdata
as a message ofMessageType
.parseFrom
(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry) Parsesdata
as a message ofMessageType
.parseFrom
(byte[] data, ExtensionRegistryLite extensionRegistry) Parsesdata
as a message ofMessageType
.parseFrom
(ByteString data) Parsesdata
as a message ofMessageType
.parseFrom
(ByteString data, ExtensionRegistryLite extensionRegistry) Parsesdata
as a message ofMessageType
.parseFrom
(CodedInputStream input) Parses a message ofMessageType
from the input.parseFrom
(CodedInputStream input, ExtensionRegistryLite extensionRegistry) LikeparseFrom(CodedInputStream)
, but also parses extensions.parseFrom
(InputStream input) Parse a message ofMessageType
frominput
.parseFrom
(InputStream input, ExtensionRegistryLite extensionRegistry) Parses a message ofMessageType
frominput
.parseFrom
(ByteBuffer data) Parsesdata
as a message ofMessageType
.parseFrom
(ByteBuffer data, ExtensionRegistryLite extensionRegistry) Parsesdata
as a message ofMessageType
.LikeparseDelimitedFrom(InputStream)
, but does not throw an exception if the message is missing required fields.parsePartialDelimitedFrom
(InputStream input, ExtensionRegistryLite extensionRegistry) LikeparseDelimitedFrom(InputStream, ExtensionRegistryLite)
, but does not throw an exception if the message is missing required fields.parsePartialFrom
(byte[] data) LikeparseFrom(byte[])
, but does not throw an exception if the message is missing required fields.parsePartialFrom
(byte[] data, int off, int len) LikeparseFrom(byte[], int, int)
, but does not throw an exception if the message is missing required fields.parsePartialFrom
(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry) LikeparseFrom(ByteString, ExtensionRegistryLite)
, but does not throw an exception if the message is missing required fields.parsePartialFrom
(byte[] data, ExtensionRegistryLite extensionRegistry) LikeparseFrom(byte[], ExtensionRegistryLite)
, but does not throw an exception if the message is missing required fields.parsePartialFrom
(ByteString data) LikeparseFrom(ByteString)
, but does not throw an exception if the message is missing required fields.parsePartialFrom
(ByteString data, ExtensionRegistryLite extensionRegistry) LikeparseFrom(ByteString, ExtensionRegistryLite)
, but does not throw an exception if the message is missing required fields.parsePartialFrom
(CodedInputStream input) LikeparseFrom(CodedInputStream)
, but does not throw an exception if the message is missing required fields.parsePartialFrom
(CodedInputStream input, ExtensionRegistryLite extensionRegistry) LikeparseFrom(CodedInputStream input, ExtensionRegistryLite)
, but does not throw an exception if the message is missing required fields.parsePartialFrom
(InputStream input) LikeparseFrom(InputStream)
, but does not throw an exception if the message is missing required fields.parsePartialFrom
(InputStream input, ExtensionRegistryLite extensionRegistry) LikeparseFrom(InputStream, ExtensionRegistryLite)
, but does not throw an exception if the message is missing required fields.
-
Method Details
-
parseFrom
Parses a message ofMessageType
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.- Throws:
InvalidProtocolBufferException
-
parseFrom
MessageType parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException LikeparseFrom(CodedInputStream)
, but also parses extensions. The extensions that you want to be able to parse must be registered inextensionRegistry
. Extensions not in the registry will be treated as unknown fields.- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
LikeparseFrom(CodedInputStream)
, but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
MessageType parsePartialFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException LikeparseFrom(CodedInputStream input, ExtensionRegistryLite)
, but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Throws:
InvalidProtocolBufferException
-
parseFrom
Parsesdata
as a message ofMessageType
. This is just a small wrapper aroundparseFrom(CodedInputStream)
.- Throws:
InvalidProtocolBufferException
-
parseFrom
MessageType parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException Parsesdata
as a message ofMessageType
. This is just a small wrapper aroundparseFrom(CodedInputStream, ExtensionRegistryLite)
.- Throws:
InvalidProtocolBufferException
-
parseFrom
Parsesdata
as a message ofMessageType
. This is just a small wrapper aroundparseFrom(CodedInputStream)
.- Throws:
InvalidProtocolBufferException
-
parseFrom
MessageType parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException Parsesdata
as a message ofMessageType
. This is just a small wrapper aroundparseFrom(CodedInputStream, ExtensionRegistryLite)
.- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
LikeparseFrom(ByteString)
, but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
MessageType parsePartialFrom(ByteString data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException LikeparseFrom(ByteString, ExtensionRegistryLite)
, but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Throws:
InvalidProtocolBufferException
-
parseFrom
Parsesdata
as a message ofMessageType
. This is just a small wrapper aroundparseFrom(CodedInputStream)
.- Throws:
InvalidProtocolBufferException
-
parseFrom
MessageType parseFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException Parsesdata
as a message ofMessageType
. This is just a small wrapper aroundparseFrom(CodedInputStream, ExtensionRegistryLite)
.- Throws:
InvalidProtocolBufferException
-
parseFrom
Parsesdata
as a message ofMessageType
. This is just a small wrapper aroundparseFrom(CodedInputStream)
.- Throws:
InvalidProtocolBufferException
-
parseFrom
MessageType parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException Parsesdata
as a message ofMessageType
. This is just a small wrapper aroundparseFrom(CodedInputStream, ExtensionRegistryLite)
.- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
LikeparseFrom(byte[], int, int)
, but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
MessageType parsePartialFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException LikeparseFrom(ByteString, ExtensionRegistryLite)
, but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
LikeparseFrom(byte[])
, but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
MessageType parsePartialFrom(byte[] data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException LikeparseFrom(byte[], ExtensionRegistryLite)
, but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Throws:
InvalidProtocolBufferException
-
parseFrom
Parse a message ofMessageType
frominput
. This is just a small wrapper aroundparseFrom(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, useMessageLite.writeDelimitedTo(java.io.OutputStream)
to write your message andparseDelimitedFrom(InputStream)
to read it.Despite usually reading the entire input, this does not close the stream.
- Throws:
InvalidProtocolBufferException
-
parseFrom
MessageType parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException Parses a message ofMessageType
frominput
. This is just a small wrapper aroundparseFrom(CodedInputStream, ExtensionRegistryLite)
.- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
LikeparseFrom(InputStream)
, but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
MessageType parsePartialFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException LikeparseFrom(InputStream, ExtensionRegistryLite)
, but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Throws:
InvalidProtocolBufferException
-
parseDelimitedFrom
LikeparseFrom(InputStream)
, but does not read until EOF. Instead, the size of message (encoded as a varint) is read first, then the message data. UseMessageLite.writeDelimitedTo(java.io.OutputStream)
to write messages in this format.- Returns:
- 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.
- Throws:
InvalidProtocolBufferException
-
parseDelimitedFrom
MessageType parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException LikeparseDelimitedFrom(InputStream)
but supporting extensions.- Throws:
InvalidProtocolBufferException
-
parsePartialDelimitedFrom
LikeparseDelimitedFrom(InputStream)
, but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Throws:
InvalidProtocolBufferException
-
parsePartialDelimitedFrom
MessageType parsePartialDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException LikeparseDelimitedFrom(InputStream, ExtensionRegistryLite)
, but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Throws:
InvalidProtocolBufferException
-