View Javadoc

1   /**********************************************************************
2    * IncompleteIOException.java
3    * created on 07.03.2005 by netseeker
4    * $Source: /cvsroot/ejoe/EJOE/src/de/netseeker/ejoe/io/IncompleteIOException.java,v $
5    * $Date: 2006/02/04 14:15:52 $
6    * $Revision: 1.6 $
7    *********************************************************************/
8   package de.netseeker.ejoe.io;
9   
10  import java.io.IOException;
11  import java.nio.ByteBuffer;
12  
13  /***
14   * A special exception type which will be thrown when a incomplete non-blocking
15   * IO read or write operation occurs.
16   *
17   * @author netseeker
18   */
19  public class IncompleteIOException extends IOException
20  {
21  	private static final long		serialVersionUID	= 3761973765386679092L;
22  
23  	private transient ByteBuffer	_buf;
24  
25  	private int						_selectionInterest;
26  
27  	/***
28  	 * Creates a new IncompleteIOException and stores the given ByteBuffer for
29  	 * possible reuse
30  	 *
31  	 * @param buf
32  	 *            the ByteBuffer containing the partial read/not yet written
33  	 *            data
34  	 */
35  	public IncompleteIOException(ByteBuffer buf)
36  	{
37  		this._buf = buf;
38  	}
39  
40  	/***
41  	 * Creates a new IncompleteIOException and stores the given ByteBuffer for
42  	 * possible reuse. Additionally it stores the type of the operation which
43  	 * has thrown this Exception.
44  	 *
45  	 * @param buf
46  	 *            the ByteBuffer containing the partial read/not yet written
47  	 *            data
48  	 * @param selectionInterest
49  	 *            type of the io operation which has caused the exception, can
50  	 *            be either SelectionKey.OP_READ or SelectionKey.OP_WRITE
51  	 * @see java.nio.channels.SelectionKey
52  	 */
53  	public IncompleteIOException(ByteBuffer buf, int selectionInterest)
54  	{
55  		this._buf = buf;
56  		this._selectionInterest = selectionInterest;
57  	}
58  
59  	/***
60  	 * Returns the contained ByteBuffer.
61  	 *
62  	 * @return
63  	 */
64  	public ByteBuffer getIOBuffer()
65  	{
66  		return this._buf;
67  	}
68  
69  	/***
70  	 * @param buf
71  	 *            The ByteBuffer to set.
72  	 */
73  	public void setIOBuffer(ByteBuffer buf)
74  	{
75  		this._buf = buf;
76  	}
77  
78  	public int getSelectionInterest()
79  	{
80  		return this._selectionInterest;
81  	}
82  
83  	public void setSelectionInterest(int interest)
84  	{
85  		this._selectionInterest = interest;
86  	}
87  }