40 |
import java.nio.channels.spi.AbstractSelectableChannel; |
import java.nio.channels.spi.AbstractSelectableChannel; |
41 |
import java.nio.channels.spi.SelectorProvider; |
import java.nio.channels.spi.SelectorProvider; |
42 |
|
|
43 |
|
/** |
44 |
|
* @author Michael Koch |
45 |
|
* @since 1.4 |
46 |
|
*/ |
47 |
public abstract class Pipe |
public abstract class Pipe |
48 |
{ |
{ |
49 |
public abstract static class SinkChannel |
public abstract static class SinkChannel |
50 |
extends AbstractSelectableChannel |
extends AbstractSelectableChannel |
51 |
implements WritableByteChannel, GatheringByteChannel |
implements WritableByteChannel, GatheringByteChannel |
52 |
{ |
{ |
53 |
protected SinkChannel(SelectorProvider provider) |
/** |
54 |
|
* Initializes the channel. |
55 |
|
*/ |
56 |
|
protected SinkChannel (SelectorProvider provider) |
57 |
{ |
{ |
58 |
super (provider); |
super (provider); |
59 |
} |
} |
60 |
|
|
61 |
|
/** |
62 |
|
* Returns an operation set that is valid on this channel. |
63 |
|
* |
64 |
|
* The only valid operation on this channel is @see SelectionKey.OP_WRITE. |
65 |
|
*/ |
66 |
|
public final int validOps () |
67 |
|
{ |
68 |
|
return SelectionKey.OP_WRITE; |
69 |
|
} |
70 |
} |
} |
71 |
|
|
72 |
public abstract static class SourceChannel |
public abstract static class SourceChannel |
73 |
extends AbstractSelectableChannel |
extends AbstractSelectableChannel |
74 |
implements ReadableByteChannel, ScatteringByteChannel |
implements ReadableByteChannel, ScatteringByteChannel |
75 |
{ |
{ |
76 |
protected SourceChannel(SelectorProvider provider) |
/** |
77 |
|
* Initializes the channel. |
78 |
|
*/ |
79 |
|
protected SourceChannel (SelectorProvider provider) |
80 |
{ |
{ |
81 |
super (provider); |
super (provider); |
82 |
} |
} |
83 |
|
|
84 |
|
/** |
85 |
|
* Returns an operation set that is valid on this channel. |
86 |
|
* |
87 |
|
* The only valid operation on this channel is @see SelectionKey.OP_READ. |
88 |
|
*/ |
89 |
|
public final int validOps () |
90 |
|
{ |
91 |
|
return SelectionKey.OP_READ; |
92 |
|
} |
93 |
} |
} |
94 |
|
|
95 |
|
/** |
96 |
|
* Initializes the pipe. |
97 |
|
*/ |
98 |
protected Pipe() |
protected Pipe() |
99 |
{ |
{ |
100 |
} |
} |
101 |
|
|
102 |
|
/** |
103 |
|
* Opens a pipe. |
104 |
|
* |
105 |
|
* @exception IOException If an error occurs |
106 |
|
*/ |
107 |
public static Pipe open() |
public static Pipe open() |
108 |
{ |
{ |
109 |
return null; |
return SelectorProvider.provider ().openPipe(); |
110 |
} |
} |
111 |
|
|
112 |
|
/** |
113 |
|
* Returns a pipe's sink channel. |
114 |
|
*/ |
115 |
public abstract Pipe.SinkChannel sink(); |
public abstract Pipe.SinkChannel sink(); |
116 |
|
|
117 |
|
/** |
118 |
|
* Returns a pipe's source channel |
119 |
|
*/ |
120 |
public abstract Pipe.SourceChannel source(); |
public abstract Pipe.SourceChannel source(); |
121 |
} |
} |