public abstract class AbstractParser<MessageType extends MessageLite> extends Object implements Parser<MessageType>
Parser
interface 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 Parser
interface. See Parser
for
related javadocs. Subclasses need to implement
Parser.parsePartialFrom(CodedInputStream, ExtensionRegistryLite)
Constructor and Description |
---|
AbstractParser() |
Modifier and Type | Method and Description |
---|---|
MessageType |
parseDelimitedFrom(InputStream input)
Like
Parser.parseFrom(InputStream) , but does not read util EOF. |
MessageType |
parseDelimitedFrom(InputStream input,
ExtensionRegistryLite extensionRegistry)
Like
Parser.parseDelimitedFrom(InputStream) but supporting extensions. |
MessageType |
parseFrom(byte[] data)
Parses
data as a message of MessageType . |
MessageType |
parseFrom(byte[] data,
ExtensionRegistryLite extensionRegistry)
Parses
data as a message of MessageType . |
MessageType |
parseFrom(byte[] data,
int off,
int len)
Parses
data as a message of MessageType . |
MessageType |
parseFrom(byte[] data,
int off,
int len,
ExtensionRegistryLite extensionRegistry)
Parses
data as a message of MessageType . |
MessageType |
parseFrom(ByteString data)
Parses
data as a message of MessageType . |
MessageType |
parseFrom(ByteString data,
ExtensionRegistryLite extensionRegistry)
Parses
data as a message of MessageType . |
MessageType |
parseFrom(CodedInputStream input)
Parses a message of
MessageType from the input. |
MessageType |
parseFrom(CodedInputStream input,
ExtensionRegistryLite extensionRegistry)
Like
Parser.parseFrom(CodedInputStream) , but also parses extensions. |
MessageType |
parseFrom(InputStream input)
Parse a message of
MessageType from input . |
MessageType |
parseFrom(InputStream input,
ExtensionRegistryLite extensionRegistry)
Parses a message of
MessageType from input . |
MessageType |
parsePartialDelimitedFrom(InputStream input)
Like
Parser.parseDelimitedFrom(InputStream) , but does not throw an exception if the message is missing required
fields. |
MessageType |
parsePartialDelimitedFrom(InputStream input,
ExtensionRegistryLite extensionRegistry)
Like
Parser.parseDelimitedFrom(InputStream, ExtensionRegistryLite) , but does not throw an exception if the
message is missing required fields. |
MessageType |
parsePartialFrom(byte[] data)
Like
Parser.parseFrom(byte[]) , but does not throw an exception if the message is missing required fields. |
MessageType |
parsePartialFrom(byte[] data,
ExtensionRegistryLite extensionRegistry)
Like
Parser.parseFrom(byte[], ExtensionRegistryLite) , but does not throw an exception if the message is missing
required fields. |
MessageType |
parsePartialFrom(byte[] data,
int off,
int len)
Like
Parser.parseFrom(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)
Like
Parser.parseFrom(ByteString, ExtensionRegistryLite) , but does not throw an exception if the message is
missing required fields. |
MessageType |
parsePartialFrom(ByteString data)
Like
Parser.parseFrom(ByteString) , but does not throw an exception if the message is missing required fields. |
MessageType |
parsePartialFrom(ByteString data,
ExtensionRegistryLite extensionRegistry)
Like
Parser.parseFrom(ByteString, ExtensionRegistryLite) , but does not throw an exception if the message is
missing required fields. |
MessageType |
parsePartialFrom(CodedInputStream input)
Like
Parser.parseFrom(CodedInputStream) , but does not throw an exception if the message is missing required
fields. |
MessageType |
parsePartialFrom(InputStream input)
Like
Parser.parseFrom(InputStream) , but does not throw an exception if the message is missing required fields. |
MessageType |
parsePartialFrom(InputStream input,
ExtensionRegistryLite extensionRegistry)
Like
Parser.parseFrom(InputStream, ExtensionRegistryLite) , but does not throw an exception if the message is
missing required fields. |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
parsePartialFrom
@Nullable public MessageType parseDelimitedFrom(InputStream input) throws InvalidProtocolBufferException
Parser
Parser.parseFrom(InputStream)
, but does not read util EOF. Instead, the size of message (encoded as a
varint) is read first, then the message data. Use MessageLite.writeDelimitedTo(java.io.OutputStream)
to
write messages in this format.parseDelimitedFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
@Nullable public MessageType parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Parser
Parser.parseDelimitedFrom(InputStream)
but supporting extensions.parseDelimitedFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parseFrom(byte[] data) throws InvalidProtocolBufferException
Parser
data
as a message of MessageType
. This is just a small wrapper around
Parser.parseFrom(CodedInputStream)
.parseFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Parser
data
as a message of MessageType
. This is just a small wrapper around
Parser.parseFrom(CodedInputStream, ExtensionRegistryLite)
.parseFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parseFrom(byte[] data, int off, int len) throws InvalidProtocolBufferException
Parser
data
as a message of MessageType
. This is just a small wrapper around
Parser.parseFrom(CodedInputStream)
.parseFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parseFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Parser
data
as a message of MessageType
. This is just a small wrapper around
Parser.parseFrom(CodedInputStream, ExtensionRegistryLite)
.parseFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parseFrom(ByteString data) throws InvalidProtocolBufferException
Parser
data
as a message of MessageType
. This is just a small wrapper around
Parser.parseFrom(CodedInputStream)
.parseFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Parser
data
as a message of MessageType
. This is just a small wrapper around
Parser.parseFrom(CodedInputStream, ExtensionRegistryLite)
.parseFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parseFrom(CodedInputStream input) throws InvalidProtocolBufferException
Parser
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.
parseFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Parser
Parser.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.parseFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parseFrom(InputStream input) throws InvalidProtocolBufferException
Parser
MessageType
from input
. This is just a small wrapper around
Parser.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, use MessageLite.writeDelimitedTo(java.io.OutputStream)
to write your message and
Parser.parseDelimitedFrom(InputStream)
to read it.
Despite usually reading the entire input, this does not close the stream.
parseFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Parser
MessageType
from input
. This is just a small wrapper around
Parser.parseFrom(CodedInputStream, ExtensionRegistryLite)
.parseFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
@Nullable public MessageType parsePartialDelimitedFrom(InputStream input) throws InvalidProtocolBufferException
Parser
Parser.parseDelimitedFrom(InputStream)
, but does not throw an exception if the message is missing required
fields. Instead, a partial message is returned.parsePartialDelimitedFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
@Nullable public MessageType parsePartialDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Parser
Parser.parseDelimitedFrom(InputStream, ExtensionRegistryLite)
, but does not throw an exception if the
message is missing required fields. Instead, a partial message is returned.parsePartialDelimitedFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parsePartialFrom(byte[] data) throws InvalidProtocolBufferException
Parser
Parser.parseFrom(byte[])
, but does not throw an exception if the message is missing required fields.
Instead, a partial message is returned.parsePartialFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parsePartialFrom(byte[] data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Parser
Parser.parseFrom(byte[], ExtensionRegistryLite)
, but does not throw an exception if the message is missing
required fields. Instead, a partial message is returned.parsePartialFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parsePartialFrom(byte[] data, int off, int len) throws InvalidProtocolBufferException
Parser
Parser.parseFrom(byte[], int, int)
, but does not throw an exception if the message is missing required
fields. Instead, a partial message is returned.parsePartialFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parsePartialFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Parser
Parser.parseFrom(ByteString, ExtensionRegistryLite)
, but does not throw an exception if the message is
missing required fields. Instead, a partial message is returned.parsePartialFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parsePartialFrom(ByteString data) throws InvalidProtocolBufferException
Parser
Parser.parseFrom(ByteString)
, but does not throw an exception if the message is missing required fields.
Instead, a partial message is returned.parsePartialFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parsePartialFrom(ByteString data, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Parser
Parser.parseFrom(ByteString, ExtensionRegistryLite)
, but does not throw an exception if the message is
missing required fields. Instead, a partial message is returned.parsePartialFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parsePartialFrom(CodedInputStream input) throws InvalidProtocolBufferException
Parser
Parser.parseFrom(CodedInputStream)
, but does not throw an exception if the message is missing required
fields. Instead, a partial message is returned.parsePartialFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parsePartialFrom(InputStream input) throws InvalidProtocolBufferException
Parser
Parser.parseFrom(InputStream)
, but does not throw an exception if the message is missing required fields.
Instead, a partial message is returned.parsePartialFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException
public MessageType parsePartialFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
Parser
Parser.parseFrom(InputStream, ExtensionRegistryLite)
, but does not throw an exception if the message is
missing required fields. Instead, a partial message is returned.parsePartialFrom
in interface Parser<MessageType extends MessageLite>
InvalidProtocolBufferException