274 *
275 * @return This key's ready-operation set
276 *
277 * @throws CancelledKeyException
278 * If this key has been cancelled
279 */
280 public abstract int readyOps();
281
282
283 // -- Operation bits and bit-testing convenience methods --
284
285 /**
286 * Operation-set bit for read operations.
287 *
288 * <p> Suppose that a selection key's interest set contains
289 * {@code OP_READ} at the start of a <a
290 * href="Selector.html#selop">selection operation</a>. If the selector
291 * detects that the corresponding channel is ready for reading, has reached
292 * end-of-stream, has been remotely shut down for further reading, or has
293 * an error pending, then it will add {@code OP_READ} to the key's
294 * ready-operation set and add the key to its selected-key set. </p>
295 */
296 public static final int OP_READ = 1 << 0;
297
298 /**
299 * Operation-set bit for write operations.
300 *
301 * <p> Suppose that a selection key's interest set contains
302 * {@code OP_WRITE} at the start of a <a
303 * href="Selector.html#selop">selection operation</a>. If the selector
304 * detects that the corresponding channel is ready for writing, has been
305 * remotely shut down for further writing, or has an error pending, then it
306 * will add {@code OP_WRITE} to the key's ready set and add the key to its
307 * selected-key set. </p>
308 */
309 public static final int OP_WRITE = 1 << 2;
310
311 /**
312 * Operation-set bit for socket-connect operations.
313 *
314 * <p> Suppose that a selection key's interest set contains
315 * {@code OP_CONNECT} at the start of a <a
316 * href="Selector.html#selop">selection operation</a>. If the selector
317 * detects that the corresponding socket channel is ready to complete its
318 * connection sequence, or has an error pending, then it will add
319 * {@code OP_CONNECT} to the key's ready set and add the key to its
320 * selected-key set. </p>
321 */
322 public static final int OP_CONNECT = 1 << 3;
323
324 /**
325 * Operation-set bit for socket-accept operations.
326 *
327 * <p> Suppose that a selection key's interest set contains
328 * {@code OP_ACCEPT} at the start of a <a
329 * href="Selector.html#selop">selection operation</a>. If the selector
330 * detects that the corresponding server-socket channel is ready to accept
331 * another connection, or has an error pending, then it will add
332 * {@code OP_ACCEPT} to the key's ready set and add the key to its
333 * selected-key set. </p>
334 */
335 public static final int OP_ACCEPT = 1 << 4;
336
337 /**
338 * Tests whether this key's channel is ready for reading.
339 *
340 * <p> An invocation of this method of the form {@code k.isReadable()}
341 * behaves in exactly the same way as the expression
342 *
343 * <blockquote><pre>{@code
344 * k.readyOps() & OP_READ != 0
345 * }</pre></blockquote>
346 *
347 * <p> If this key's channel does not support read operations then this
348 * method always returns {@code false}. </p>
349 *
350 * @return {@code true} if, and only if,
351 {@code readyOps() & OP_READ} is nonzero
352 *
353 * @throws CancelledKeyException
|
274 *
275 * @return This key's ready-operation set
276 *
277 * @throws CancelledKeyException
278 * If this key has been cancelled
279 */
280 public abstract int readyOps();
281
282
283 // -- Operation bits and bit-testing convenience methods --
284
285 /**
286 * Operation-set bit for read operations.
287 *
288 * <p> Suppose that a selection key's interest set contains
289 * {@code OP_READ} at the start of a <a
290 * href="Selector.html#selop">selection operation</a>. If the selector
291 * detects that the corresponding channel is ready for reading, has reached
292 * end-of-stream, has been remotely shut down for further reading, or has
293 * an error pending, then it will add {@code OP_READ} to the key's
294 * ready-operation set. </p>
295 */
296 public static final int OP_READ = 1 << 0;
297
298 /**
299 * Operation-set bit for write operations.
300 *
301 * <p> Suppose that a selection key's interest set contains
302 * {@code OP_WRITE} at the start of a <a
303 * href="Selector.html#selop">selection operation</a>. If the selector
304 * detects that the corresponding channel is ready for writing, has been
305 * remotely shut down for further writing, or has an error pending, then it
306 * will add {@code OP_WRITE} to the key's ready set. </p>
307 */
308 public static final int OP_WRITE = 1 << 2;
309
310 /**
311 * Operation-set bit for socket-connect operations.
312 *
313 * <p> Suppose that a selection key's interest set contains
314 * {@code OP_CONNECT} at the start of a <a
315 * href="Selector.html#selop">selection operation</a>. If the selector
316 * detects that the corresponding socket channel is ready to complete its
317 * connection sequence, or has an error pending, then it will add
318 * {@code OP_CONNECT} to the key's ready set. </p>
319 */
320 public static final int OP_CONNECT = 1 << 3;
321
322 /**
323 * Operation-set bit for socket-accept operations.
324 *
325 * <p> Suppose that a selection key's interest set contains
326 * {@code OP_ACCEPT} at the start of a <a
327 * href="Selector.html#selop">selection operation</a>. If the selector
328 * detects that the corresponding server-socket channel is ready to accept
329 * another connection, or has an error pending, then it will add
330 * {@code OP_ACCEPT} to the key's ready set. </p>
331 */
332 public static final int OP_ACCEPT = 1 << 4;
333
334 /**
335 * Tests whether this key's channel is ready for reading.
336 *
337 * <p> An invocation of this method of the form {@code k.isReadable()}
338 * behaves in exactly the same way as the expression
339 *
340 * <blockquote><pre>{@code
341 * k.readyOps() & OP_READ != 0
342 * }</pre></blockquote>
343 *
344 * <p> If this key's channel does not support read operations then this
345 * method always returns {@code false}. </p>
346 *
347 * @return {@code true} if, and only if,
348 {@code readyOps() & OP_READ} is nonzero
349 *
350 * @throws CancelledKeyException
|