- java.lang.Object
-
- org.xnio.channels.AssembledChannel
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.Channel,java.nio.channels.InterruptibleChannel,CloseableChannel,Configurable
- Direct Known Subclasses:
AssembledConnectedChannel
public class AssembledChannel extends java.lang.Object implements CloseableChannel
A closeable view over a read and write side of a suspendable channel.- Author:
- David M. Lloyd
-
-
Field Summary
-
Fields inherited from interface org.xnio.channels.Configurable
EMPTY
-
-
Constructor Summary
Constructors Constructor Description AssembledChannel(SuspendableReadChannel readChannel, SuspendableWriteChannel writeChannel)Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close this channel.ChannelListener.Setter<? extends CloseableChannel>getCloseSetter()Get the setter which can be used to change the close listener for this channel.XnioIoThreadgetIoThread()Get the I/O thread associated with this channel.<T> TgetOption(Option<T> option)Get the value of a channel option.XnioWorkergetWorker()Get the worker for this channel.booleanisOpen()<T> TsetOption(Option<T> option, T value)Set an option for this channel.booleansupportsOption(Option<?> option)Determine whether an option is supported on this channel.
-
-
-
Constructor Detail
-
AssembledChannel
public AssembledChannel(SuspendableReadChannel readChannel, SuspendableWriteChannel writeChannel)
Construct a new instance.- Parameters:
readChannel- the read sidewriteChannel- the write side
-
-
Method Detail
-
getCloseSetter
public ChannelListener.Setter<? extends CloseableChannel> getCloseSetter()
Description copied from interface:CloseableChannelGet the setter which can be used to change the close listener for this channel. If the channel is already closed, then the listener will not be called.- Specified by:
getCloseSetterin interfaceCloseableChannel- Returns:
- the setter
-
getWorker
public XnioWorker getWorker()
Description copied from interface:CloseableChannelGet the worker for this channel.- Specified by:
getWorkerin interfaceCloseableChannel- Returns:
- the worker
-
getIoThread
public XnioIoThread getIoThread()
Description copied from interface:CloseableChannelGet the I/O thread associated with this channel.- Specified by:
getIoThreadin interfaceCloseableChannel- Returns:
- the I/O thread associated with this channel
-
close
public void close() throws java.io.IOExceptionDescription copied from interface:CloseableChannelClose this channel. When a channel is closed, its close listener is invoked. Invoking this method more than once has no additional effect.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.nio.channels.Channel- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceCloseableChannel- Specified by:
closein interfacejava.nio.channels.InterruptibleChannel- Throws:
java.io.IOException- if the close failed
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin interfacejava.nio.channels.Channel
-
supportsOption
public boolean supportsOption(Option<?> option)
Description copied from interface:ConfigurableDetermine whether an option is supported on this channel.- Specified by:
supportsOptionin interfaceConfigurable- Parameters:
option- the option- Returns:
trueif it is supported
-
getOption
public <T> T getOption(Option<T> option) throws java.io.IOException
Description copied from interface:ConfigurableGet the value of a channel option.- Specified by:
getOptionin interfaceConfigurable- Type Parameters:
T- the type of the option value- Parameters:
option- the option to get- Returns:
- the value of the option, or
nullif it is not set - Throws:
java.io.IOException- if an I/O error occurred when reading the option
-
setOption
public <T> T setOption(Option<T> option, T value) throws java.lang.IllegalArgumentException, java.io.IOException
Description copied from interface:ConfigurableSet an option for this channel. Unsupported options are ignored.- Specified by:
setOptionin interfaceConfigurable- Type Parameters:
T- the type of the option value- Parameters:
option- the option to setvalue- the value of the option to set- Returns:
- the previous option value, if any
- Throws:
java.lang.IllegalArgumentException- if the value is not acceptable for this optionjava.io.IOException- if an I/O error occurred when modifying the option
-
-