Language

ProtoOutputStream Class

Definition

Class to write to a protobuf stream.

[Android.Runtime.Register("android/util/proto/ProtoOutputStream", ApiSince=30, DoNotGenerateAcw=true)]
public sealed class ProtoOutputStream : Java.Lang.Object
[<Android.Runtime.Register("android/util/proto/ProtoOutputStream", ApiSince=30, DoNotGenerateAcw=true)>]
type ProtoOutputStream = class
    inherit Object
Inheritance
ProtoOutputStream
Attributes

Remarks

Class to write to a protobuf stream.

This API is not as convenient or type safe as the standard protobuf classes. If possible, the best recommended library is to use protobuf lite. However, in environments (such as the Android platform itself), a more memory efficient version is necessary.

Each write method takes an ID code from the protoc generated classes and the value to write. To make a nested object, call #start(long) and then #end(long) when you are done.

The ID codes have type information embedded into them, so if you call the incorrect function you will get an IllegalArgumentException.

To retrieve the encoded protobuf stream, call #getBytes().

stream as the top-level objects are finished.

Java documentation for android.util.proto.ProtoOutputStream.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Name Description
ProtoOutputStream()

Construct a ProtoOutputStream with the default chunk size.

ProtoOutputStream(Int32)

Construct a ProtoOutputStream with the given chunk size.

ProtoOutputStream(Stream)

Construct a ProtoOutputStream that sits on top of an OutputStream.

Fields

Name Description
FieldCountMask

Bit mask for selecting the field count when reading a field id that is used with a ProtoOutputStream.write(...) method.

FieldCountPacked

Repeated packed field count, encoded into a field id used with a ProtoOutputStream.write(...) method.

FieldCountRepeated

Repeated field count, encoded into a field id used with a ProtoOutputStream.write(...) method.

FieldCountShift

Bit offset for building a field id to be used with a ProtoOutputStream.write(...).

FieldCountSingle

Single field count, encoded into a field id used with a ProtoOutputStream.write(...) method.

FieldCountUnknown

Unknown field count, encoded into a field id used with a ProtoOutputStream.write(...) method.

FieldIdShift

Number of bits to shift the field number to form a tag.

FieldTypeBool

Field type code for bool fields.

FieldTypeBytes

Field type code for bytes fields.

FieldTypeDouble

Field type code for double fields.

FieldTypeEnum

Field type code for enum fields.

FieldTypeFixed32

Field type code for fixed32 fields.

FieldTypeFixed64

Field type code for fixed64 fields.

FieldTypeFloat

Field type code for float fields.

FieldTypeInt32

Field type code for int32 fields.

FieldTypeInt64

Field type code for int64 fields.

FieldTypeMask

Mask for the field types stored in a fieldId.

FieldTypeMessage

Field type code for message fields.

FieldTypeSfixed32

Field type code for sfixed32 fields.

FieldTypeSfixed64

Field type code for sfixed64 fields.

FieldTypeShift

Position of the field type in a (long) fieldId.

FieldTypeSint32

Field type code for sint32 fields.

FieldTypeSint64

Field type code for sint64 fields.

FieldTypeString

Field type code for string fields.

FieldTypeUint32

Field type code for uint32 fields.

FieldTypeUint64

Field type code for uint64 fields.

WireTypeEndGroup
Obsolete.

End group wire type code.

WireTypeFixed32
Obsolete.

Fixed32 wire type code.

WireTypeFixed64
Obsolete.

Fixed64 wire type code.

WireTypeLengthDelimited
Obsolete.

Length delimited wire type code.

WireTypeMask
Obsolete.

Mask to select the wire type from a tag.

WireTypeStartGroup
Obsolete.

Start group wire type code.

WireTypeVarint
Obsolete.

Varint wire type code.

Properties

Name Description
Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode

Gets the identity hash code assigned to this Java peer by the interop runtime.

(Inherited from Object)
JniManagedPeerState (Inherited from JavaObject)
JniPeerMembers
PeerReference

Gets the JNI object reference for this Java peer.

(Inherited from Object)
RawSize

Returns the total size of the data that has been written, after full protobuf encoding has occurred.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)

Methods

Name Description
CheckFieldId(Int64, Int64)

Validates that the fieldId provided is of the type and count from expectedType.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Construct(JniObjectReference, JniObjectReferenceOptions) (Inherited from JavaObject)
Dispose()

Releases the resources held by this Java peer.

(Inherited from Object)
Dispose(Boolean)

Releases the resources held by this Java peer.

(Inherited from Object)
DisposeUnlessReferenced() (Inherited from JavaObject)
Dump(String)

Dump debugging data about the buffers with the given log tag.

End(Int64)

End the object started by start() that returned token.

Equals(Object) (Inherited from JavaObject)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
Flush()

Write remaining data to the output stream.

GetBytes()

Finish the encoding of the data, and return a byte[] with the protobuf formatted data.

GetFieldCountString(Int64)

Get the developer-usable name of a field count.

GetFieldIdString(Int64)

Get a debug string for a fieldId.

GetFieldTypeString(Int64)

Get the developer-usable name of a field type.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetWireTypeString(Int32)

Get the developer-usable name of a wire type.

JavaFinalize()
Obsolete.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
MakeFieldId(Int32, Int64)

Combine a fieldId (the field keys in the proto file) and the field flags.

MakeToken(Int32, Boolean, Int32, Int32, Int32)

Make a token.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetPeerReference(JniObjectReference, JniObjectReferenceOptions) (Inherited from JavaObject)
Start(Int64)

Start a sub object.

ToArray<T>()

Creates a managed array from this Java array wrapper.

(Inherited from Object)
Token2String(Int64)

Return a debugging string of a token.

ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime()

Unregisters this Java peer from the interop runtime.

(Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Write(Int64, Boolean)

Write a boolean value for the given fieldId.

Write(Int64, Byte[])

Write a byte[] value for the given fieldId.

Write(Int64, Double)

Write a value for the given fieldId.

Write(Int64, Int32)

Write a value for the given fieldId.

Write(Int64, Int64)

Write a value for the given fieldId.

Write(Int64, Single)

Write a value for the given fieldId.

Write(Int64, String)

Write a string value for the given fieldId.

WriteTag(Int32, Int32)

Write an individual field tag by hand.

Explicit Interface Implementations

Name Description
IJavaPeerable.Disposed() (Inherited from JavaObject)
IJavaPeerable.Finalized() (Inherited from JavaObject)
IJavaPeerable.JniObjectReferenceControlBlock (Inherited from JavaObject)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from JavaObject)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from JavaObject)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from JavaObject)

Extension Methods

Name Description
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to