Class AbstractMessageLite<MessageType,BuilderType> (3.19.4)

  public 
  
 abstract 
  
 class 
 AbstractMessageLite<MessageType 
 , 
 BuilderType 
>  
 implements 
  
 MessageLite 
 

A partial implementation of the MessageLite interface which implements as many methods of that interface as possible in terms of other methods.

Inheritance

java.lang.Object > AbstractMessageLite<MessageType,BuilderType>

Implements

MessageLite

Type Parameters

Name
Description
MessageType
BuilderType

Static Methods

<T>addAll(Iterable<T> values, Collection<? super T> list)

  protected 
  
 static 
  
 void 
  
< T>addAll 
 ( 
 Iterable<T> 
  
 values 
 , 
  
 Collection 
< ? 
  
 super 
  
 T 
>  
 list 
 ) 
 
Parameters
Name
Description
values
Iterable < T >
list
Collection < ? super T >

<T>addAll(Iterable<T> values, List<? super T> list)

  protected 
  
 static 
  
 void 
  
< T>addAll 
 ( 
 Iterable<T> 
  
 values 
 , 
  
 List 
< ? 
  
 super 
  
 T 
>  
 list 
 ) 
 
Parameters
Name
Description
values
Iterable < T >
list
List < ? super T >

checkByteStringIsUtf8(ByteString byteString)

  protected 
  
 static 
  
 void 
  
 checkByteStringIsUtf8 
 ( 
 ByteString 
  
 byteString 
 ) 
 
Parameter
Name
Description
byteString
Exceptions
Type
Description

Constructors

AbstractMessageLite()

  public 
  
 AbstractMessageLite 
 () 
 

Fields

memoizedHashCode

  protected 
  
 int 
  
 memoizedHashCode 
 
Field Value
Type
Description
int

Methods

toByteArray()

  public 
  
 byte 
 [] 
  
 toByteArray 
 () 
 

Serializes the message to a byte array and returns it. This is just a trivial wrapper around #writeTo(CodedOutputStream) .

If this message requires more than Integer.MAX_VALUE bytes to encode, the behavior is unpredictable. It may throw a runtime exception or truncate or slice the data.

Returns
Type
Description
byte []

toByteString()

  public 
  
 ByteString 
  
 toByteString 
 () 
 

Serializes the message to a ByteString and returns it. This is just a trivial wrapper around #writeTo(CodedOutputStream) .

If this message requires more than Integer.MAX_VALUE bytes to encode, the behavior is unpredictable. It may throw a runtime exception or truncate or slice the data.

Returns
Type
Description

writeDelimitedTo(OutputStream output)

  public 
  
 void 
  
 writeDelimitedTo 
 ( 
 OutputStream 
  
 output 
 ) 
 

Like #writeTo(OutputStream) , but writes the size of the message as a varint before writing the data. This allows more data to be written to the stream after the message without the need to delimit the message data yourself. Use Builder#mergeDelimitedFrom(InputStream) (or the static method YourMessageType.parseDelimitedFrom(InputStream) ) to parse messages written by this method.

Parameter
Name
Description
output
Exceptions
Type
Description

writeTo(OutputStream output)

  public 
  
 void 
  
 writeTo 
 ( 
 OutputStream 
  
 output 
 ) 
 

Serializes the message and writes it to output . This is just a trivial wrapper around #writeTo(CodedOutputStream) . This does not flush or close the stream.

NOTE: Protocol Buffers are not self-delimiting. Therefore, if you write any more data to the stream after the message, you must somehow ensure that the parser on the receiving end does not interpret this as being part of the protocol message. This can be done e.g. by writing the size of the message before the data, then making sure to limit the input to that size on the receiving end (e.g. by wrapping the InputStream in one which limits the input). Alternatively, just use #writeDelimitedTo(OutputStream) .

Parameter
Name
Description
output
Exceptions
Type
Description
Design a Mobile Site
View Site in Mobile | Classic
Share by: