Class ByteOutput
- Direct Known Subclasses:
BinaryWriter,CodedOutputStream
Traditional write operations: (as defined by 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidwrite(byte value) Writes a single byte.abstract voidwrite(byte[] value, int offset, int length) Writes a sequence of bytes.abstract voidwrite(ByteBuffer value) Writes a sequence of bytes.abstract voidwriteLazy(byte[] value, int offset, int length) Writes a sequence of bytes.abstract voidwriteLazy(ByteBuffer value) Writes a sequence of bytes.
-
Constructor Details
-
ByteOutput
public ByteOutput()
-
-
Method Details
-
write
Writes a single byte.- Parameters:
value- the byte to be written- Throws:
IOException- thrown if an error occurred while writing
-
write
Writes a sequence of bytes. TheByteOutputmust copyvalueif it will not be processed prior to the return of this method call, sincevaluemay 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- the bytes to be writtenoffset- the offset of the start of the writable rangelength- the number of bytes to write starting fromoffset- Throws:
IOException- thrown if an error occurred while writing
-
writeLazy
Writes a sequence of bytes. TheByteOutputis 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- the bytes to be writtenoffset- the offset of the start of the writable rangelength- the number of bytes to write starting fromoffset- Throws:
IOException- thrown if an error occurred while writing
-
write
Writes a sequence of bytes. TheByteOutputmust copyvalueif it will not be processed prior to the return of this method call, sincevaluemay 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- the bytes to be written. Upon returning from this call, thepositionof this buffer will be set to thelimit- Throws:
IOException- thrown if an error occurred while writing
-
writeLazy
Writes a sequence of bytes. TheByteOutputis 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- the bytes to be written. Upon returning from this call, thepositionof this buffer will be set to thelimit- Throws:
IOException- thrown if an error occurred while writing
-