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 benull. However, if an I/O problem occurs, an exception is thrown with anIOExceptioncause.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description MessageTypeparseDelimitedFrom(java.io.InputStream input)LikeparseFrom(InputStream), but does not read until EOF.MessageTypeparseDelimitedFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry)LikeparseDelimitedFrom(InputStream)but supporting extensions.MessageTypeparseFrom(byte[] data)Parsesdataas a message ofMessageType.MessageTypeparseFrom(byte[] data, int off, int len)Parsesdataas a message ofMessageType.MessageTypeparseFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)Parsesdataas a message ofMessageType.MessageTypeparseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)Parsesdataas a message ofMessageType.MessageTypeparseFrom(ByteString data)Parsesdataas a message ofMessageType.MessageTypeparseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)Parsesdataas a message ofMessageType.MessageTypeparseFrom(CodedInputStream input)Parses a message ofMessageTypefrom the input.MessageTypeparseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)LikeparseFrom(CodedInputStream), but also parses extensions.MessageTypeparseFrom(java.io.InputStream input)Parse a message ofMessageTypefrominput.MessageTypeparseFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry)Parses a message ofMessageTypefrominput.MessageTypeparseFrom(java.nio.ByteBuffer data)Parsesdataas a message ofMessageType.MessageTypeparseFrom(java.nio.ByteBuffer data, ExtensionRegistryLite extensionRegistry)Parsesdataas a message ofMessageType.MessageTypeparsePartialDelimitedFrom(java.io.InputStream input)LikeparseDelimitedFrom(InputStream), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialDelimitedFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry)LikeparseDelimitedFrom(InputStream, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(byte[] data)LikeparseFrom(byte[]), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(byte[] data, int off, int len)LikeparseFrom(byte[], int, int), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)LikeparseFrom(ByteString, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(byte[] data, ExtensionRegistryLite extensionRegistry)LikeparseFrom(byte[], ExtensionRegistryLite), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(ByteString data)LikeparseFrom(ByteString), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(ByteString data, ExtensionRegistryLite extensionRegistry)LikeparseFrom(ByteString, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(CodedInputStream input)LikeparseFrom(CodedInputStream), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)LikeparseFrom(CodedInputStream input, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(java.io.InputStream input)LikeparseFrom(InputStream), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(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 ofMessageTypefrom 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
Parsesdataas a message ofMessageType. This is just a small wrapper aroundparseFrom(CodedInputStream).- Throws:
InvalidProtocolBufferException
-
parseFrom
MessageType parseFrom(java.nio.ByteBuffer data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Parsesdataas a message ofMessageType. This is just a small wrapper aroundparseFrom(CodedInputStream, ExtensionRegistryLite).- Throws:
InvalidProtocolBufferException
-
parseFrom
MessageType parseFrom(ByteString data) throws InvalidProtocolBufferException
Parsesdataas a message ofMessageType. This is just a small wrapper aroundparseFrom(CodedInputStream).- Throws:
InvalidProtocolBufferException
-
parseFrom
MessageType parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Parsesdataas 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
Parsesdataas 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
Parsesdataas a message ofMessageType. This is just a small wrapper aroundparseFrom(CodedInputStream, ExtensionRegistryLite).- Throws:
InvalidProtocolBufferException
-
parseFrom
MessageType parseFrom(byte[] data) throws InvalidProtocolBufferException
Parsesdataas a message ofMessageType. This is just a small wrapper aroundparseFrom(CodedInputStream).- Throws:
InvalidProtocolBufferException
-
parseFrom
MessageType parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Parsesdataas 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 ofMessageTypefrominput. 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 ofMessageTypefrominput. 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
-
-