Class BaseWriteChannel<ServiceOptionsT,EntityT> (2.8.27)

public abstract class BaseWriteChannel<ServiceOptionsT,EntityT> implements WriteChannel

Base implementation for a WriteChannel.

Inheritance

java.lang.Object > BaseWriteChannel<ServiceOptionsT,EntityT>

Implements

WriteChannel

Type Parameters

NameDescription
ServiceOptionsT
EntityT

Constructors

BaseWriteChannel(ServiceOptionsT options, EntityT entity, String uploadId)

protected BaseWriteChannel(ServiceOptionsT options, EntityT entity, String uploadId)
Parameters
NameDescription
optionsServiceOptionsT
entityEntityT
uploadIdString

Methods

capture()

public RestorableState<WriteChannel> capture()

Captures the write channel state so that it can be saved and restored afterwards. The original WriteChannel and the restored one should not both be used. Closing one channel causes the other channel to close; subsequent writes will fail.

Returns
TypeDescription
RestorableState<WriteChannel>

close()

public final void close()
Exceptions
TypeDescription
IOException

flushBuffer(int length, boolean last)

protected abstract void flushBuffer(int length, boolean last)

Writes length bytes of #getBuffer() to the #getUploadId() URL.

Parameters
NameDescription
lengthint

the number of bytes to write from #getBuffer()

lastboolean

if true the resumable session is closed

getBuffer()

protected byte[] getBuffer()
Returns
TypeDescription
byte[]

getChunkSize()

protected int getChunkSize()
Returns
TypeDescription
int

getDefaultChunkSize()

protected int getDefaultChunkSize()
Returns
TypeDescription
int

getEntity()

protected EntityT getEntity()
Returns
TypeDescription
EntityT

getLimit()

protected int getLimit()
Returns
TypeDescription
int

getMinChunkSize()

protected int getMinChunkSize()
Returns
TypeDescription
int

getOptions()

protected ServiceOptionsT getOptions()
Returns
TypeDescription
ServiceOptionsT

getPosition()

protected long getPosition()
Returns
TypeDescription
long

getUploadId()

protected String getUploadId()
Returns
TypeDescription
String

isOpen()

public boolean isOpen()
Returns
TypeDescription
boolean

restore(BaseWriteChannel.BaseState state)

protected void restore(BaseWriteChannel.BaseState state)

Restores the state of the current write channel given a BaseState object.

Parameter
NameDescription
stateBaseState

setChunkSize(int chunkSize)

public final void setChunkSize(int chunkSize)

Sets the minimum size that will be written by a single RPC. Written data will be buffered and only flushed upon reaching this size or closing the channel.

Parameter
NameDescription
chunkSizeint

stateBuilder()

protected abstract BaseWriteChannel.BaseState.Builder<ServiceOptionsT,EntityT> stateBuilder()

Creates a BaseState.Builder for the current write channel.

Returns
TypeDescription
Builder<ServiceOptionsT,EntityT>

write(ByteBuffer byteBuffer)

public final int write(ByteBuffer byteBuffer)
Parameter
NameDescription
byteBufferByteBuffer
Returns
TypeDescription
int
Exceptions
TypeDescription
IOException