Interface Parser<MessageType> (3.19.4)

  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 java.io.IOException cause.

Type Parameter

Name
Description
MessageType

Methods

parseDelimitedFrom(InputStream input)

  public 
  
 abstract 
  
 MessageType 
  
 parseDelimitedFrom 
 ( 
 InputStream 
  
 input 
 ) 
 

Like #parseFrom(InputStream) , but does not read until 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.

Parameter
Name
Description
input
Returns
Type
Description
MessageType

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.

Exceptions
Type
Description

parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

  public 
  
 abstract 
  
 MessageType 
  
 parseDelimitedFrom 
 ( 
 InputStream 
  
 input 
 , 
  
 ExtensionRegistryLite 
  
 extensionRegistry 
 ) 
 

Like #parseDelimitedFrom(InputStream) but supporting extensions.

Parameters
Name
Description
input
extensionRegistry
Returns
Type
Description
MessageType
Exceptions
Type
Description

parseFrom(byte[] data)

  public 
  
 abstract 
  
 MessageType 
  
 parseFrom 
 ( 
 byte 
 [] 
  
 data 
 ) 
 

Parses data as a message of MessageType . This is just a small wrapper around #parseFrom(CodedInputStream) .

Parameter
Name
Description
data
byte []
Returns
Type
Description
MessageType
Exceptions
Type
Description

parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

  public 
  
 abstract 
  
 MessageType 
  
 parseFrom 
 ( 
 byte 
 [] 
  
 data 
 , 
  
 ExtensionRegistryLite 
  
 extensionRegistry 
 ) 
 

Parses data as a message of MessageType . This is just a small wrapper around #parseFrom(CodedInputStream, ExtensionRegistryLite) .

Parameters
Name
Description
data
byte []
extensionRegistry
Returns
Type
Description
MessageType
Exceptions
Type
Description

parseFrom(byte[] data, int off, int len)

  public 
  
 abstract 
  
 MessageType 
  
 parseFrom 
 ( 
 byte 
 [] 
  
 data 
 , 
  
 int 
  
 off 
 , 
  
 int 
  
 len 
 ) 
 

Parses data as a message of MessageType . This is just a small wrapper around #parseFrom(CodedInputStream) .

Parameters
Name
Description
data
byte []
off
int
len
int
Returns
Type
Description
MessageType
Exceptions
Type
Description

parseFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)

  public 
  
 abstract 
  
 MessageType 
  
 parseFrom 
 ( 
 byte 
 [] 
  
 data 
 , 
  
 int 
  
 off 
 , 
  
 int 
  
 len 
 , 
  
 ExtensionRegistryLite 
  
 extensionRegistry 
 ) 
 

Parses data as a message of MessageType . This is just a small wrapper around #parseFrom(CodedInputStream, ExtensionRegistryLite) .

Parameters
Name
Description
data
byte []
off
int
len
int
extensionRegistry
Returns
Type
Description
MessageType
Exceptions
Type
Description

parseFrom(ByteString data)

  public 
  
 abstract 
  
 MessageType 
  
 parseFrom 
 ( 
 ByteString 
  
 data 
 ) 
 

Parses data as a message of MessageType . This is just a small wrapper around #parseFrom(CodedInputStream) .

Parameter
Name
Description
data
Returns
Type
Description
MessageType
Exceptions
Type
Description

parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

  public 
  
 abstract 
  
 MessageType 
  
 parseFrom 
 ( 
 ByteString 
  
 data 
 , 
  
 ExtensionRegistryLite 
  
 extensionRegistry 
 ) 
 

Parses data as a message of MessageType . This is just a small wrapper around #parseFrom(CodedInputStream, ExtensionRegistryLite) .

Parameters
Name
Description
data
extensionRegistry
Returns
Type
Description
MessageType
Exceptions
Type
Description

parseFrom(CodedInputStream input)

  public 
  
 abstract 
  
 MessageType 
  
 parseFrom 
 ( 
 CodedInputStream 
  
 input 
 ) 
 

Parses a message of 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.

Parameter
Name
Description
Returns
Type
Description
MessageType
Exceptions
Type
Description

parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

  public 
  
 abstract 
  
 MessageType 
  
 parseFrom 
 ( 
 CodedInputStream 
  
 input 
 , 
  
 ExtensionRegistryLite 
  
 extensionRegistry 
 ) 
 

Like #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.

Parameters
Name
Description
extensionRegistry
Returns
Type
Description
MessageType
Exceptions
Type
Description

parseFrom(InputStream input)

  public 
  
 abstract 
  
 MessageType 
  
 parseFrom 
 ( 
 InputStream 
  
 input 
 ) 
 

Parse a message of MessageType from input . This is just a small wrapper around #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 #parseDelimitedFrom(InputStream) to read it.

Despite usually reading the entire input, this does not close the stream.

Parameter
Name
Description
input
Returns
Type
Description
MessageType
Exceptions
Type
Description

parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

  public 
  
 abstract 
  
 MessageType 
  
 parseFrom 
 ( 
 InputStream 
  
 input 
 , 
  
 ExtensionRegistryLite 
  
 extensionRegistry 
 ) 
 

Parses a message of MessageType from input . This is just a small wrapper around #parseFrom(CodedInputStream, ExtensionRegistryLite) .

Parameters
Name
Description
input
extensionRegistry
Returns
Type
Description
MessageType
Exceptions
Type
Description

parseFrom(ByteBuffer data)

  public 
  
 abstract 
  
 MessageType 
  
 parseFrom 
 ( 
 ByteBuffer 
  
 data 
 ) 
 

Parses data as a message of MessageType . This is just a small wrapper around #parseFrom(CodedInputStream) .

Parameter
Name
Description
data
Returns
Type
Description
MessageType
Exceptions
Type
Description

parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)

  public 
  
 abstract 
  
 MessageType 
  
 parseFrom 
 ( 
 ByteBuffer 
  
 data 
 , 
  
 ExtensionRegistryLite 
  
 extensionRegistry 
 ) 
 

Parses data as a message of MessageType . This is just a small wrapper around #parseFrom(CodedInputStream, ExtensionRegistryLite) .

Parameters
Name
Description
data
extensionRegistry
Returns
Type
Description
MessageType
Exceptions
Type
Description

parsePartialDelimitedFrom(InputStream input)

  public 
  
 abstract 
  
 MessageType 
  
 parsePartialDelimitedFrom 
 ( 
 InputStream 
  
 input 
 ) 
 

Like #parseDelimitedFrom(InputStream) , but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Parameter
Name
Description
input
Returns
Type
Description
MessageType
Exceptions
Type
Description

parsePartialDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

  public 
  
 abstract 
  
 MessageType 
  
 parsePartialDelimitedFrom 
 ( 
 InputStream 
  
 input 
 , 
  
 ExtensionRegistryLite 
  
 extensionRegistry 
 ) 
 

Like #parseDelimitedFrom(InputStream, ExtensionRegistryLite) , but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Parameters
Name
Description
input
extensionRegistry
Returns
Type
Description
MessageType
Exceptions
Type
Description

parsePartialFrom(byte[] data)

  public 
  
 abstract 
  
 MessageType 
  
 parsePartialFrom 
 ( 
 byte 
 [] 
  
 data 
 ) 
 

Like #parseFrom(byte[]) , but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Parameter
Name
Description
data
byte []
Returns
Type
Description
MessageType
Exceptions
Type
Description

parsePartialFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

  public 
  
 abstract 
  
 MessageType 
  
 parsePartialFrom 
 ( 
 byte 
 [] 
  
 data 
 , 
  
 ExtensionRegistryLite 
  
 extensionRegistry 
 ) 
 

Like #parseFrom(byte[], ExtensionRegistryLite) , but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Parameters
Name
Description
data
byte []
extensionRegistry
Returns
Type
Description
MessageType
Exceptions
Type
Description

parsePartialFrom(byte[] data, int off, int len)

  public 
  
 abstract 
  
 MessageType 
  
 parsePartialFrom 
 ( 
 byte 
 [] 
  
 data 
 , 
  
 int 
  
 off 
 , 
  
 int 
  
 len 
 ) 
 

Like #parseFrom(byte[], int, int) , but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Parameters
Name
Description
data
byte []
off
int
len
int
Returns
Type
Description
MessageType
Exceptions
Type
Description

parsePartialFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)

  public 
  
 abstract 
  
 MessageType 
  
 parsePartialFrom 
 ( 
 byte 
 [] 
  
 data 
 , 
  
 int 
  
 off 
 , 
  
 int 
  
 len 
 , 
  
 ExtensionRegistryLite 
  
 extensionRegistry 
 ) 
 

Like #parseFrom(ByteString, ExtensionRegistryLite) , but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Parameters
Name
Description
data
byte []
off
int
len
int
extensionRegistry
Returns
Type
Description
MessageType
Exceptions
Type
Description

parsePartialFrom(ByteString data)

  public 
  
 abstract 
  
 MessageType 
  
 parsePartialFrom 
 ( 
 ByteString 
  
 data 
 ) 
 

Like #parseFrom(ByteString) , but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Parameter
Name
Description
data
Returns
Type
Description
MessageType
Exceptions
Type
Description

parsePartialFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

  public 
  
 abstract 
  
 MessageType 
  
 parsePartialFrom 
 ( 
 ByteString 
  
 data 
 , 
  
 ExtensionRegistryLite 
  
 extensionRegistry 
 ) 
 

Like #parseFrom(ByteString, ExtensionRegistryLite) , but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Parameters
Name
Description
data
extensionRegistry
Returns
Type
Description
MessageType
Exceptions
Type
Description

parsePartialFrom(CodedInputStream input)

  public 
  
 abstract 
  
 MessageType 
  
 parsePartialFrom 
 ( 
 CodedInputStream 
  
 input 
 ) 
 

Like #parseFrom(CodedInputStream) , but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Parameter
Name
Description
Returns
Type
Description
MessageType
Exceptions
Type
Description

parsePartialFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

  public 
  
 abstract 
  
 MessageType 
  
 parsePartialFrom 
 ( 
 CodedInputStream 
  
 input 
 , 
  
 ExtensionRegistryLite 
  
 extensionRegistry 
 ) 
 

Like #parseFrom(CodedInputStream input, ExtensionRegistryLite) , but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Parameters
Name
Description
extensionRegistry
Returns
Type
Description
MessageType
Exceptions
Type
Description

parsePartialFrom(InputStream input)

  public 
  
 abstract 
  
 MessageType 
  
 parsePartialFrom 
 ( 
 InputStream 
  
 input 
 ) 
 

Like #parseFrom(InputStream) , but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Parameter
Name
Description
input
Returns
Type
Description
MessageType
Exceptions
Type
Description

parsePartialFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

  public 
  
 abstract 
  
 MessageType 
  
 parsePartialFrom 
 ( 
 InputStream 
  
 input 
 , 
  
 ExtensionRegistryLite 
  
 extensionRegistry 
 ) 
 

Like #parseFrom(InputStream, ExtensionRegistryLite) , but does not throw an exception if the message is missing required fields. Instead, a partial message is returned.

Parameters
Name
Description
input
extensionRegistry
Returns
Type
Description
MessageType
Exceptions
Type
Description
Design a Mobile Site
View Site in Mobile | Classic
Share by: