Top Description Methods
org.xnio.conduits

public Interface StreamSinkConduit

extends SinkConduit
Known Direct Implementers
org.xnio.conduits.SynchronizedStreamSinkConduit, org.xnio.ssl.JsseStreamConduit, org.xnio.conduits.AbstractStreamSinkConduit, org.xnio.conduits.DeflatingStreamSinkConduit, org.xnio.conduits.FixedLengthStreamSinkConduit, org.xnio.conduits.MessageStreamSinkConduit, org.xnio.conduits.NullStreamSinkConduit, org.xnio.conduits.StreamSinkChannelWrappingConduit
Imports
java.io.IOException, java.nio.ByteBuffer, java.nio.channels.ClosedChannelException, .FileChannel, org.xnio.channels.StreamSourceChannel

A sink (writable) conduit for byte streams.
Author
David M. Lloyd

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

the number of bytes (possibly 0) that were actually transferred
transferFrom
(FileChannel
the file to read from
src
,
long
the position within the file from which the transfer is to begin
position
,
long
the number of bytes to be transferred
count
)

Transfer bytes into this conduit from the given file.

public long

Returns:

the number of bytes (possibly 0) that were actually transferred, or -1 if the end of input was reached
transferFrom
(StreamSourceChannel
the source to read from
source
,
long
the number of bytes to be transferred
count
,
ByteBuffer
the buffer to copy through.
throughBuffer
)

Transfers bytes from the given channel source.

public int

Returns:

the number of bytes written, possibly 0
write
(ByteBuffer
the buffer containing data to write
src
)

Writes a sequence of bytes to this conduit from the given buffer.

public long

Returns:

the number of bytes written, possibly 0
write
(ByteBuffer[]
the buffers containing data to write
srcs
,
int
the offset into the buffer array
offs
,
int
the number of buffers to write
len
)

Writes a sequence of bytes to this conduit from the given buffers.

public int

Returns:

The amount of data that was actually written.
writeFinal
(ByteBuffer
The data to write
src
)

Writes some data to the conduit, with the same semantics as write(java.nio.ByteBuffer).

public long

Returns:

The amount of data that was actually written
writeFinal
(ByteBuffer[]
The buffers from which bytes are to be retrieved
srcs
,
int
The offset within the buffer array of the first buffer from which bytes are to be retrieved; must be non-negative and no larger than srcs.length
offset
,
int
The maximum number of buffers to be accessed; must be non-negative and no larger than srcs.length - offset
length
)

Writes some data to the conduit, with the same semantics as write(java.nio.ByteBuffer[], int, int).

Inherited from org.xnio.conduits.SinkConduit:
awaitWritableawaitWritableflushgetWriteThreadisWriteResumedisWriteShutdownresumeWritessetWriteReadyHandlersuspendWritesterminateWritestruncateWriteswakeupWrites

Method Detail

transferFromback to summary
public long transferFrom(FileChannel src, long position, long count) throws IOException

Transfer bytes into this conduit from the given file.

Parameters
src:FileChannel

the file to read from

position:long

the position within the file from which the transfer is to begin

count:long

the number of bytes to be transferred

Returns:long

the number of bytes (possibly 0) that were actually transferred

Exceptions
IOException:
if an I/O error occurs
transferFromback to summary
public long transferFrom(StreamSourceChannel source, long count, ByteBuffer throughBuffer) throws IOException

Transfers bytes from the given channel source. On entry, throughBuffer will be cleared. On exit, the buffer will be flipped for emptying, and may be empty or may contain data. If this method returns a value less than count, then the remaining data in throughBuffer may contain data read from source which must be written to this channel to complete the operation.

Parameters
source:StreamSourceChannel

the source to read from

count:long

the number of bytes to be transferred

throughBuffer:ByteBuffer

the buffer to copy through.

Returns:long

the number of bytes (possibly 0) that were actually transferred, or -1 if the end of input was reached

Exceptions
IOException:
if an I/O error occurs
writeback to summary
public int write(ByteBuffer src) throws IOException

Writes a sequence of bytes to this conduit from the given buffer.

Parameters
src:ByteBuffer

the buffer containing data to write

Returns:int

the number of bytes written, possibly 0

Exceptions
IOException:
if an error occurs
ClosedChannelException:
if this conduit's terminateWrites() method was previously called
writeback to summary
public long write(ByteBuffer[] srcs, int offs, int len) throws IOException

Writes a sequence of bytes to this conduit from the given buffers.

Parameters
srcs:ByteBuffer[]

the buffers containing data to write

offs:int

the offset into the buffer array

len:int

the number of buffers to write

Returns:long

the number of bytes written, possibly 0

Exceptions
IOException:
if an error occurs
ClosedChannelException:
if this conduit's terminateWrites() method was previously called
writeFinalback to summary
public int writeFinal(ByteBuffer src) throws IOException

Writes some data to the conduit, with the same semantics as write(java.nio.ByteBuffer). If all the data is written out then the conduit will have its writes terminated. Semantically this method is equivalent to: int rem = src.remaining(); int written = conduit.write(src); if(written == rem) { conduit.terminateWrites() }

Parameters
src:ByteBuffer

The data to write

Returns:int

The amount of data that was actually written.

writeFinalback to summary
public long writeFinal(ByteBuffer[] srcs, int offset, int length) throws IOException

Writes some data to the conduit, with the same semantics as write(java.nio.ByteBuffer[], int, int). If all the data is written out then the conduit will have its writes terminated.

Parameters
srcs:ByteBuffer[]

The buffers from which bytes are to be retrieved

offset:int

The offset within the buffer array of the first buffer from which bytes are to be retrieved; must be non-negative and no larger than srcs.length

length:int

The maximum number of buffers to be accessed; must be non-negative and no larger than srcs.length - offset

Returns:long

The amount of data that was actually written