API Overview API Index Package Overview Direct link to this page
JDK 1.6
  java.nio.channels. Pipe View Javadoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136

/*
 * @(#)Pipe.java	1.21 05/11/17
 *
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

package java.nio.channels;

import java.io.IOException;
import java.nio.channels.spi.*;


/**
 * A pair of channels that implements a unidirectional pipe.
 *
 * <p> A pipe consists of a pair of channels: A writable {@link
 * Pipe.SinkChannel </code>sink<code>} channel and a readable {@link
 * Pipe.SourceChannel </code>source<code>} channel.  Once some bytes are
 * written to the sink channel they can be read from source channel in exactly
 * the order in which they were written.
 *
 * <p> 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.  </p>
 *
 *
 * @author Mark Reinhold
 * @author JSR-51 Expert Group
 * @version 1.21, 05/11/17
 * @since 1.4
 */

public abstract class Pipe {

    /**
     * A channel representing the readable end of a {@link Pipe}.  </p>
     *
     * @since 1.4
     */
    public static abstract class SourceChannel
	extends AbstractSelectableChannel
	implements ReadableByteChannel, ScatteringByteChannel
    {
	/**
	 * Constructs a new instance of this class.
	 */
	protected SourceChannel(SelectorProvider provider) {
	    super(provider);
	}

	/**
	 * Returns an operation set identifying this channel's supported
	 * operations.
	 *
	 * <p> Pipe-source channels only support reading, so this method
	 * returns {@link SelectionKey#OP_READ}.  </p>
	 *
	 * @return  The valid-operation set
	 */
	public final int validOps() {
	    return SelectionKey.OP_READ;
	}

    }

    /**
     * A channel representing the writable end of a {@link Pipe}.  </p>
     *
     * @since 1.4
     */
    public static abstract class SinkChannel
	extends AbstractSelectableChannel
	implements WritableByteChannel, GatheringByteChannel
    {
	/**
	 * Initializes a new instance of this class.
	 */
	protected SinkChannel(SelectorProvider provider) {
	    super(provider);
	}

	/**
	 * Returns an operation set identifying this channel's supported
	 * operations.
	 *
	 * <p> Pipe-sink channels only support writing, so this method returns
	 * {@link SelectionKey#OP_WRITE}.  </p>
	 *
	 * @return  The valid-operation set
	 */
	public final int validOps() {
	    return SelectionKey.OP_WRITE;
	}

    }

    /**
     * Initializes a new instance of this class.
     */
    protected Pipe() { }

    /**
     * Returns this pipe's source channel.  </p>
     *
     * @return  This pipe's source channel
     */
    public abstract SourceChannel source();

    /**
     * Returns this pipe's sink channel.  </p>
     *
     * @return  This pipe's sink channel
     */
    public abstract SinkChannel sink();

    /**
     * Opens a pipe.
     *
     * <p> The new pipe is created by invoking the {@link
     * java.nio.channels.spi.SelectorProvider#openPipe openPipe} method of the
     * system-wide default {@link java.nio.channels.spi.SelectorProvider}
     * object.  </p>
     *
     * @return  A new pipe
     *
     * @throws  IOException
     *          If an I/O error occurs
     */
    public static Pipe open() throws IOException {
	return SelectorProvider.provider().openPipe();
    }

}

Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar