Package com.google.protobuf
Class AbstractParser<MessageType extends MessageLite>
- java.lang.Object
-
- com.google.protobuf.AbstractParser<MessageType>
-
- All Implemented Interfaces:
Parser<MessageType>
- Direct Known Subclasses:
GeneratedMessageLite.DefaultInstanceBasedParser,UnknownFieldSet.Parser
public abstract class AbstractParser<MessageType extends MessageLite> extends java.lang.Object implements Parser<MessageType>
A partial implementation of theParserinterface 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
Parserinterface. SeeParserfor related javadocs. Subclasses need to implementParser.parsePartialFrom(CodedInputStream, ExtensionRegistryLite)
-
-
Constructor Summary
Constructors Constructor Description AbstractParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MessageTypeparseDelimitedFrom(java.io.InputStream input)LikeParser.parseFrom(InputStream), but does not read until EOF.MessageTypeparseDelimitedFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry)LikeParser.parseDelimitedFrom(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)LikeParser.parseFrom(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)LikeParser.parseDelimitedFrom(InputStream), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialDelimitedFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry)LikeParser.parseDelimitedFrom(InputStream, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(byte[] data)LikeParser.parseFrom(byte[]), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(byte[] data, int off, int len)LikeParser.parseFrom(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)LikeParser.parseFrom(ByteString, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(byte[] data, ExtensionRegistryLite extensionRegistry)LikeParser.parseFrom(byte[], ExtensionRegistryLite), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(ByteString data)LikeParser.parseFrom(ByteString), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(ByteString data, ExtensionRegistryLite extensionRegistry)LikeParser.parseFrom(ByteString, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(CodedInputStream input)LikeParser.parseFrom(CodedInputStream), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(java.io.InputStream input)LikeParser.parseFrom(InputStream), but does not throw an exception if the message is missing required fields.MessageTypeparsePartialFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry)LikeParser.parseFrom(InputStream, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.protobuf.Parser
parsePartialFrom
-
-
-
-
Method Detail
-
parsePartialFrom
public MessageType parsePartialFrom(CodedInputStream input) throws InvalidProtocolBufferException
Description copied from interface:ParserLikeParser.parseFrom(CodedInputStream), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Specified by:
parsePartialFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parseFrom
public MessageType parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Description copied from interface:ParserLikeParser.parseFrom(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.- Specified by:
parseFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parseFrom
public MessageType parseFrom(CodedInputStream input) throws InvalidProtocolBufferException
Description copied from interface:ParserParses 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.- Specified by:
parseFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
public MessageType parsePartialFrom(ByteString data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Description copied from interface:ParserLikeParser.parseFrom(ByteString, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Specified by:
parsePartialFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
public MessageType parsePartialFrom(ByteString data) throws InvalidProtocolBufferException
Description copied from interface:ParserLikeParser.parseFrom(ByteString), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Specified by:
parsePartialFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parseFrom
public MessageType parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Description copied from interface:ParserParsesdataas a message ofMessageType. This is just a small wrapper aroundParser.parseFrom(CodedInputStream, ExtensionRegistryLite).- Specified by:
parseFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parseFrom
public MessageType parseFrom(ByteString data) throws InvalidProtocolBufferException
Description copied from interface:ParserParsesdataas a message ofMessageType. This is just a small wrapper aroundParser.parseFrom(CodedInputStream).- Specified by:
parseFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parseFrom
public MessageType parseFrom(java.nio.ByteBuffer data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Description copied from interface:ParserParsesdataas a message ofMessageType. This is just a small wrapper aroundParser.parseFrom(CodedInputStream, ExtensionRegistryLite).- Specified by:
parseFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parseFrom
public MessageType parseFrom(java.nio.ByteBuffer data) throws InvalidProtocolBufferException
Description copied from interface:ParserParsesdataas a message ofMessageType. This is just a small wrapper aroundParser.parseFrom(CodedInputStream).- Specified by:
parseFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
public MessageType parsePartialFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Description copied from interface:ParserLikeParser.parseFrom(ByteString, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Specified by:
parsePartialFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
public MessageType parsePartialFrom(byte[] data, int off, int len) throws InvalidProtocolBufferException
Description copied from interface:ParserLikeParser.parseFrom(byte[], int, int), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Specified by:
parsePartialFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
public MessageType parsePartialFrom(byte[] data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Description copied from interface:ParserLikeParser.parseFrom(byte[], ExtensionRegistryLite), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Specified by:
parsePartialFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
public MessageType parsePartialFrom(byte[] data) throws InvalidProtocolBufferException
Description copied from interface:ParserLikeParser.parseFrom(byte[]), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Specified by:
parsePartialFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parseFrom
public MessageType parseFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Description copied from interface:ParserParsesdataas a message ofMessageType. This is just a small wrapper aroundParser.parseFrom(CodedInputStream, ExtensionRegistryLite).- Specified by:
parseFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parseFrom
public MessageType parseFrom(byte[] data, int off, int len) throws InvalidProtocolBufferException
Description copied from interface:ParserParsesdataas a message ofMessageType. This is just a small wrapper aroundParser.parseFrom(CodedInputStream).- Specified by:
parseFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parseFrom
public MessageType parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Description copied from interface:ParserParsesdataas a message ofMessageType. This is just a small wrapper aroundParser.parseFrom(CodedInputStream, ExtensionRegistryLite).- Specified by:
parseFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parseFrom
public MessageType parseFrom(byte[] data) throws InvalidProtocolBufferException
Description copied from interface:ParserParsesdataas a message ofMessageType. This is just a small wrapper aroundParser.parseFrom(CodedInputStream).- Specified by:
parseFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
public MessageType parsePartialFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Description copied from interface:ParserLikeParser.parseFrom(InputStream, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Specified by:
parsePartialFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parsePartialFrom
public MessageType parsePartialFrom(java.io.InputStream input) throws InvalidProtocolBufferException
Description copied from interface:ParserLikeParser.parseFrom(InputStream), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Specified by:
parsePartialFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parseFrom
public MessageType parseFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Description copied from interface:ParserParses a message ofMessageTypefrominput. This is just a small wrapper aroundParser.parseFrom(CodedInputStream, ExtensionRegistryLite).- Specified by:
parseFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parseFrom
public MessageType parseFrom(java.io.InputStream input) throws InvalidProtocolBufferException
Description copied from interface:ParserParse a message ofMessageTypefrominput. This is just a small wrapper aroundParser.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, useMessageLite.writeDelimitedTo(java.io.OutputStream)to write your message andParser.parseDelimitedFrom(InputStream)to read it.Despite usually reading the entire input, this does not close the stream.
- Specified by:
parseFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parsePartialDelimitedFrom
public MessageType parsePartialDelimitedFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Description copied from interface:ParserLikeParser.parseDelimitedFrom(InputStream, ExtensionRegistryLite), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Specified by:
parsePartialDelimitedFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parsePartialDelimitedFrom
public MessageType parsePartialDelimitedFrom(java.io.InputStream input) throws InvalidProtocolBufferException
Description copied from interface:ParserLikeParser.parseDelimitedFrom(InputStream), but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.- Specified by:
parsePartialDelimitedFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parseDelimitedFrom
public MessageType parseDelimitedFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Description copied from interface:ParserLikeParser.parseDelimitedFrom(InputStream)but supporting extensions.- Specified by:
parseDelimitedFromin interfaceParser<MessageType extends MessageLite>- Throws:
InvalidProtocolBufferException
-
parseDelimitedFrom
public MessageType parseDelimitedFrom(java.io.InputStream input) throws InvalidProtocolBufferException
Description copied from interface:ParserLikeParser.parseFrom(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.- Specified by:
parseDelimitedFromin interfaceParser<MessageType extends MessageLite>- 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
-
-