Package com.google.protobuf
Interface Parser<MessageType>
-
- All Known Implementing Classes:
AbstractParser
,GeneratedMessageLite.DefaultInstanceBasedParser
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 benull
. However, if an I/O problem occurs, an exception is thrown with anIOException
cause.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description MessageType
parseDelimitedFrom(java.io.InputStream input)
LikeparseFrom(InputStream)
, but does not read until EOF.MessageType
parseDelimitedFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry)
LikeparseDelimitedFrom(InputStream)
but supporting extensions.MessageType
parseFrom(byte[] data)
Parsesdata
as a message ofMessageType
.MessageType
parseFrom(byte[] data, int off, int len)
Parsesdata
as a message ofMessageType
.MessageType
parseFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)
Parsesdata
as a message ofMessageType
.MessageType
parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
Parsesdata
as a message ofMessageType
.MessageType
parseFrom(ByteString data)
Parsesdata
as a message ofMessageType
.MessageType
parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
Parsesdata
as a message ofMessageType
.MessageType
parseFrom(CodedInputStream input)
Parses a message ofMessageType
from the input.MessageType
parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
LikeparseFrom(CodedInputStream)
, but also parses extensions.MessageType
parseFrom(java.io.InputStream input)
Parse a message ofMessageType
frominput
.MessageType
parseFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry)
Parses a message ofMessageType
frominput
.MessageType
parseFrom(java.nio.ByteBuffer data)
Parsesdata
as a message ofMessageType
.MessageType
parseFrom(java.nio.ByteBuffer data, ExtensionRegistryLite extensionRegistry)
Parsesdata
as a message ofMessageType
.MessageType
parsePartialDelimitedFrom(java.io.InputStream input)
LikeparseDelimitedFrom(InputStream)
, but does not throw an exception if the message is missing required fields.MessageType
parsePartialDelimitedFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry)
LikeparseDelimitedFrom(InputStream, ExtensionRegistryLite)
, but does not throw an exception if the message is missing required fields.MessageType
parsePartialFrom(byte[] data)
LikeparseFrom(byte[])
, but does not throw an exception if the message is missing required fields.MessageType
parsePartialFrom(byte[] data, int off, int len)
LikeparseFrom(byte[], int, int)
, but does not throw an exception if the message is missing required fields.MessageType
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.MessageType
parsePartialFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
LikeparseFrom(byte[], ExtensionRegistryLite)
, but does not throw an exception if the message is missing required fields.MessageType
parsePartialFrom(ByteString data)
LikeparseFrom(ByteString)
, but does not throw an exception if the message is missing required fields.MessageType
parsePartialFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
LikeparseFrom(ByteString, ExtensionRegistryLite)
, but does not throw an exception if the message is missing required fields.MessageType
parsePartialFrom(CodedInputStream input)
LikeparseFrom(CodedInputStream)
, but does not throw an exception if the message is missing required fields.MessageType
parsePartialFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
LikeparseFrom(CodedInputStream input, ExtensionRegistryLite)
, but does not throw an exception if the message is missing required fields.MessageType
parsePartialFrom(java.io.InputStream input)
LikeparseFrom(InputStream)
, but does not throw an exception if the message is missing required fields.MessageType
parsePartialFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry)
LikeparseFrom(InputStream, ExtensionRegistryLite)
, but does not throw an exception if the message is missing required fields.
-
-
-
Method Detail
-
parseFrom
MessageType parseFrom(CodedInputStream input) throws InvalidProtocolBufferException
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
MessageType parsePartialFrom(CodedInputStream input) throws InvalidProtocolBufferException
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
MessageType parseFrom(java.nio.ByteBuffer data) throws InvalidProtocolBufferException
Parsesdata
as a message ofMessageType
. This is just a small wrapper aroundparseFrom(CodedInputStream)
.- Throws:
InvalidProtocolBufferException
-
parseFrom
MessageType parseFrom(java.nio.ByteBuffer data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Parsesdata
as a message ofMessageType
. This is just a small wrapper aroundparseFrom(CodedInputStream, ExtensionRegistryLite)
.- Throws:
InvalidProtocolBufferException
-
parseFrom
MessageType parseFrom(ByteString data) throws InvalidProtocolBufferException
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
MessageType parsePartialFrom(ByteString data) throws InvalidProtocolBufferException
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
MessageType parseFrom(byte[] data, int off, int len) throws InvalidProtocolBufferException
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
MessageType parseFrom(byte[] data) throws InvalidProtocolBufferException
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
MessageType parsePartialFrom(byte[] data, int off, int len) throws InvalidProtocolBufferException
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
MessageType parsePartialFrom(byte[] data) throws InvalidProtocolBufferException
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
MessageType parseFrom(java.io.InputStream input) throws InvalidProtocolBufferException
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(java.io.InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Parses a message ofMessageType
frominput
. This is just a small wrapper aroundparseFrom(CodedInputStream, ExtensionRegistryLite)
.- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
MessageType parsePartialFrom(java.io.InputStream input) throws InvalidProtocolBufferException
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(java.io.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
MessageType parseDelimitedFrom(java.io.InputStream input) throws InvalidProtocolBufferException
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(java.io.InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
LikeparseDelimitedFrom(InputStream)
but supporting extensions.- Throws:
InvalidProtocolBufferException
-
parsePartialDelimitedFrom
MessageType parsePartialDelimitedFrom(java.io.InputStream input) throws InvalidProtocolBufferException
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(java.io.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
-
-