Top Description Fields Constructors Methods
com.google.protobuf.nano

public abstract Class MessageNano

extends Object
Class Inheritance
Known Direct Subclasses
com.google.protobuf.nano.ExtendableMessageNano
Imports
java.io.IOException, java.util.Arrays

Abstract interface implemented by Protocol Message objects.
Author
[email protected] Wink Saville

Field Summary

Modifier and TypeField and Description
protected volatile int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public MessageNano
clone()

Overrides java.lang.Object.clone.

Provides support for cloning.
protected int
computeSerializedSize()

Computes the number of bytes required to encode this message.

public int
getCachedSize()

Get the number of bytes required to encode this message.

public int
getSerializedSize()

Computes the number of bytes required to encode this message.

public abstract MessageNano
mergeFrom(CodedInputByteBufferNano input)

Parse input as a message of this type and merge it with the message being built.

public static final <T extends MessageNano> T
mergeFrom(T msg, final byte[] data)

Parse data as a message of this type and merge it with the message being built.

public static final <T extends MessageNano> T
mergeFrom(T msg, final byte[] data, final int off, final int len)

Parse data as a message of this type and merge it with the message being built.

public static final boolean
messageNanoEquals(MessageNano a, MessageNano b)

Compares two MessageNanos and returns true if the message's are the same class and have serialized form equality (i.e. all of the field values are the same).

public static final byte[]

Returns:

byte array with the serialized data.
toByteArray
(MessageNano msg)

Serialize to a byte array.

public static final void
toByteArray(MessageNano msg, byte[] data, int offset, int length)

Serialize to a byte array starting at offset through length.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string that is (mostly) compatible with ProtoBuffer's TextFormat.
public void
writeTo(CodedOutputByteBufferNano
the output to receive the serialized form.
output
)

Serializes the message and writes it to output.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

cachedSizeback to summary
protected volatile int cachedSize

Constructor Detail

MessageNanoback to summary
public MessageNano()

Method Detail

cloneback to summary
public MessageNano clone() throws CloneNotSupportedException

Overrides java.lang.Object.clone.

Provides support for cloning. This only works if you specify the generate_clone method.

Returns:MessageNano

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
Exceptions
CloneNotSupportedException:

Doc from java.lang.Object.clone.

if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.

computeSerializedSizeback to summary
protected int computeSerializedSize()

Computes the number of bytes required to encode this message. This does not update the cached size.

getCachedSizeback to summary
public int getCachedSize()

Get the number of bytes required to encode this message. Returns the cached size or calls getSerializedSize which sets the cached size. This is used internally when serializing so the size is only computed once. If a member is modified then this could be stale call getSerializedSize if in doubt.

getSerializedSizeback to summary
public int getSerializedSize()

Computes the number of bytes required to encode this message. The size is cached and the cached result can be retrieved using getCachedSize().

mergeFromback to summary
public abstract MessageNano mergeFrom(CodedInputByteBufferNano input) throws IOException

Parse input as a message of this type and merge it with the message being built.

mergeFromback to summary
public static final <T extends MessageNano> T mergeFrom(T msg, final byte[] data) throws InvalidProtocolBufferNanoException

Parse data as a message of this type and merge it with the message being built.

mergeFromback to summary
public static final <T extends MessageNano> T mergeFrom(T msg, final byte[] data, final int off, final int len) throws InvalidProtocolBufferNanoException

Parse data as a message of this type and merge it with the message being built.

messageNanoEqualsback to summary
public static final boolean messageNanoEquals(MessageNano a, MessageNano b)

Compares two MessageNanos and returns true if the message's are the same class and have serialized form equality (i.e. all of the field values are the same).

toByteArrayback to summary
public static final byte[] toByteArray(MessageNano msg)

Serialize to a byte array.

Returns:byte[]

byte array with the serialized data.

toByteArrayback to summary
public static final void toByteArray(MessageNano msg, byte[] data, int offset, int length)

Serialize to a byte array starting at offset through length. The method getSerializedSize must have been called prior to calling this method so the proper length is know. If an attempt to write more than length bytes OutOfSpaceException will be thrown and if length bytes are not written then IllegalStateException is thrown.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string that is (mostly) compatible with ProtoBuffer's TextFormat. Note that groups (which are deprecated) are not serialized with the correct field name.

This is implemented using reflection, so it is not especially fast nor is it guaranteed to find all fields if you have method removal turned on for proguard.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override
writeToback to summary
public void writeTo(CodedOutputByteBufferNano output) throws IOException

Serializes the message and writes it to output.

Parameters
output:CodedOutputByteBufferNano

the output to receive the serialized form.

Exceptions
IOException:
if an error occurred writing to output.