Top Description Inners Constructors Methods
java.nio.channels

public abstract Class Pipe

extends Object
Class Inheritance
Known Direct Subclasses
sun.nio.ch.PipeImpl
Imports
java.io.IOException, java.nio.channels.spi.*

A pair of channels that implements a unidirectional pipe.

A pipe consists of a pair of channels: A writable sink channel and a readable source channel. Once some bytes are written to the sink channel they can be read from the source channel in exactly the order in which they were written.

Whether or not a thread writing bytes to a pipe will block until another thread reads those bytes, or some previously-written bytes, from the pipe is system-dependent and therefore unspecified. Many pipe implementations will buffer up to a certain number of bytes between the sink and source channels, but such buffering should not be assumed.

Authors
Mark Reinhold, JSR-51 Expert Group
Since
1.4

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
Pipe.SinkChannel

A channel representing the writable end of a Pipe.

public abstract static class
Pipe.SourceChannel

A channel representing the readable end of a Pipe.

Constructor Summary

AccessConstructor and Description
protected
Pipe()

Initializes a new instance of this class.

Method Summary

Modifier and TypeMethod and Description
public static Pipe

Returns:

A new pipe
open
()

Opens a pipe.

public abstract Pipe.SinkChannel

Returns:

This pipe's sink channel
sink
()

Returns this pipe's sink channel.

public abstract Pipe.SourceChannel

Returns:

This pipe's source channel
source
()

Returns this pipe's source channel.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Pipeback to summary
protected Pipe()

Initializes a new instance of this class.

Method Detail

openback to summary
public static Pipe open() throws IOException

Opens a pipe.

The new pipe is created by invoking the openPipe method of the system-wide default java.nio.channels.spi.SelectorProvider object.

Returns:Pipe

A new pipe

Exceptions
IOException:
If an I/O error occurs
sinkback to summary
public abstract Pipe.SinkChannel sink()

Returns this pipe's sink channel.

Returns:Pipe.SinkChannel

This pipe's sink channel

sourceback to summary
public abstract Pipe.SourceChannel source()

Returns this pipe's source channel.

Returns:Pipe.SourceChannel

This pipe's source channel

java.nio.channels back to summary

public abstract Class Pipe.SinkChannel

extends AbstractSelectableChannel
implements WritableByteChannel, GatheringByteChannel
Class Inheritance
All Implemented Interfaces
java.nio.channels.GatheringByteChannel, java.nio.channels.WritableByteChannel, java.nio.channels.Channel, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
sun.nio.ch.SinkChannelImpl

A channel representing the writable end of a Pipe.
Since
1.4

Constructor Summary

AccessConstructor and Description
protected
SinkChannel(SelectorProvider
The selector provider
provider
)

Initializes a new instance of this class.

Method Summary

Modifier and TypeMethod and Description
public final int

Returns:

The valid-operation set
validOps
()

Implements abstract java.nio.channels.SelectableChannel.validOps.

Returns an operation set identifying this channel's supported operations.

Inherited from java.nio.channels.spi.AbstractSelectableChannel:
blockingLockconfigureBlockingimplCloseChannelimplCloseSelectableChannelimplConfigureBlockingisBlockingisRegisteredkeyForproviderregister

Constructor Detail

SinkChannelback to summary
protected SinkChannel(SelectorProvider provider)

Initializes a new instance of this class.

Parameters
provider:SelectorProvider

The selector provider

Method Detail

validOpsback to summary
public final int validOps()

Implements abstract java.nio.channels.SelectableChannel.validOps.

Returns an operation set identifying this channel's supported operations.

Pipe-sink channels only support writing, so this method returns SelectionKey#OP_WRITE.

Returns:int

The valid-operation set

java.nio.channels back to summary

public abstract Class Pipe.SourceChannel

extends AbstractSelectableChannel
implements ReadableByteChannel, ScatteringByteChannel
Class Inheritance
All Implemented Interfaces
java.nio.channels.ScatteringByteChannel, java.nio.channels.ReadableByteChannel, java.nio.channels.Channel, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
sun.nio.ch.SourceChannelImpl

A channel representing the readable end of a Pipe.
Since
1.4

Constructor Summary

AccessConstructor and Description
protected
SourceChannel(SelectorProvider
The selector provider
provider
)

Constructs a new instance of this class.

Method Summary

Modifier and TypeMethod and Description
public final int

Returns:

The valid-operation set
validOps
()

Implements abstract java.nio.channels.SelectableChannel.validOps.

Returns an operation set identifying this channel's supported operations.

Inherited from java.nio.channels.spi.AbstractSelectableChannel:
blockingLockconfigureBlockingimplCloseChannelimplCloseSelectableChannelimplConfigureBlockingisBlockingisRegisteredkeyForproviderregister

Constructor Detail

SourceChannelback to summary
protected SourceChannel(SelectorProvider provider)

Constructs a new instance of this class.

Parameters
provider:SelectorProvider

The selector provider

Method Detail

validOpsback to summary
public final int validOps()

Implements abstract java.nio.channels.SelectableChannel.validOps.

Returns an operation set identifying this channel's supported operations.

Pipe-source channels only support reading, so this method returns SelectionKey#OP_READ.

Returns:int

The valid-operation set