Top Description Constructors Methods
com.google.protobuf

public abstract Class ByteOutput

extends Object
Class Inheritance
Known Direct Subclasses
com.google.protobuf.CodedOutputStream
Annotations
@ExperimentalApi
Imports
java.io.IOException, java.nio.ByteBuffer

An output target for raw bytes. This interface provides semantics that support two types of writing:

Traditional write operations: (as defined by java.io.OutputStream) where the target method is responsible for either copying the data or completing the write before returning from the method call.

Lazy write operations: where the caller guarantees that it will never modify the provided buffer and it can therefore be considered immutable. The target method is free to maintain a reference to the buffer beyond the scope of the method call (e.g. until the write operation completes).

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract void
write(byte
the byte to be written
value
)

Writes a single byte.

public abstract void
write(byte[]
the bytes to be written
value
,
int
the offset of the start of the writable range
offset
,
int
the number of bytes to write starting from offset
length
)

Writes a sequence of bytes.

public abstract void
write(ByteBuffer
the bytes to be written. Upon returning from this call, the position of this buffer will be set to the limit
value
)

Writes a sequence of bytes.

public abstract void
writeLazy(byte[]
the bytes to be written
value
,
int
the offset of the start of the writable range
offset
,
int
the number of bytes to write starting from offset
length
)

Writes a sequence of bytes.

public abstract void
writeLazy(ByteBuffer
the bytes to be written. Upon returning from this call, the position of this buffer will be set to the limit
value
)

Writes a sequence of bytes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ByteOutputback to summary
public ByteOutput()

Method Detail

writeback to summary
public abstract void write(byte value) throws IOException

Writes a single byte.

Parameters
value:byte

the byte to be written

Exceptions
IOException:
thrown if an error occurred while writing
writeback to summary
public abstract void write(byte[] value, int offset, int length) throws IOException

Writes a sequence of bytes. The ByteOutput must copy value if it will not be processed prior to the return of this method call, since value may be reused/altered by the caller.

Note

This method MUST NOT modify the value. Doing so is a programming error and will lead to data corruption which will be difficult to debug.

Parameters
value:byte[]

the bytes to be written

offset:int

the offset of the start of the writable range

length:int

the number of bytes to write starting from offset

Exceptions
IOException:
thrown if an error occurred while writing
writeback to summary
public abstract void write(ByteBuffer value) throws IOException

Writes a sequence of bytes. The ByteOutput must copy value if it will not be processed prior to the return of this method call, since value may be reused/altered by the caller.

Note

This method MUST NOT modify the value. Doing so is a programming error and will lead to data corruption which will be difficult to debug.

Parameters
value:ByteBuffer

the bytes to be written. Upon returning from this call, the position of this buffer will be set to the limit

Exceptions
IOException:
thrown if an error occurred while writing
writeLazyback to summary
public abstract void writeLazy(byte[] value, int offset, int length) throws IOException

Writes a sequence of bytes. The ByteOutput is free to retain a reference to the value beyond the scope of this method call (e.g. write later) since it is considered immutable and is guaranteed not to change by the caller.

Note

This method MUST NOT modify the value. Doing so is a programming error and will lead to data corruption which will be difficult to debug.

Parameters
value:byte[]

the bytes to be written

offset:int

the offset of the start of the writable range

length:int

the number of bytes to write starting from offset

Exceptions
IOException:
thrown if an error occurred while writing
writeLazyback to summary
public abstract void writeLazy(ByteBuffer value) throws IOException

Writes a sequence of bytes. The ByteOutput is free to retain a reference to the value beyond the scope of this method call (e.g. write later) since it is considered immutable and is guaranteed not to change by the caller.

Note

This method MUST NOT modify the value. Doing so is a programming error and will lead to data corruption which will be difficult to debug.

Parameters
value:ByteBuffer

the bytes to be written. Upon returning from this call, the position of this buffer will be set to the limit

Exceptions
IOException:
thrown if an error occurred while writing