Source Code Cross Referenced for SelectionKey.java in  » Apache-Harmony-Java-SE » java-package » java » nio » channels » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » java package » java.nio.channels 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Licensed to the Apache Software Foundation (ASF) under one or more
002:         * contributor license agreements.  See the NOTICE file distributed with
003:         * this work for additional information regarding copyright ownership.
004:         * The ASF licenses this file to You under the Apache License, Version 2.0
005:         * (the "License"); you may not use this file except in compliance with
006:         * the License.  You may obtain a copy of the License at
007:         * 
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package java.nio.channels;
018:
019:        import java.nio.channels.Selector;
020:
021:        /**
022:         * A key that representing the relationship of a channel and the selector.
023:         * 
024:         */
025:        public abstract class SelectionKey {
026:
027:            /**
028:             * Interesting operation mask bit for socket-accept operations.
029:             */
030:            public static final int OP_ACCEPT = 16;
031:
032:            /**
033:             * Interesting operation mask bit for socket-connect operations.
034:             */
035:            public static final int OP_CONNECT = 8;
036:
037:            /**
038:             * Interesting operation mask bit for read operations.
039:             */
040:            public static final int OP_READ = 1;
041:
042:            /**
043:             * Interesting operation mask bit for write operations.
044:             */
045:            public static final int OP_WRITE = 4;
046:
047:            private volatile Object attachment = null;
048:
049:            /**
050:             * The constructor.
051:             * 
052:             */
053:            protected SelectionKey() {
054:                super ();
055:            }
056:
057:            /**
058:             * Attaches an object to the key.
059:             * 
060:             * @param anObject
061:             *            the object to attach
062:             * @return the last attached object
063:             */
064:            public final Object attach(Object anObject) {
065:                Object oldAttachment = attachment;
066:                attachment = anObject;
067:                return oldAttachment;
068:            }
069:
070:            /**
071:             * Gets the attached object.
072:             * 
073:             * @return the attached object or null if no object has been attached
074:             */
075:            public final Object attachment() {
076:                return attachment;
077:            }
078:
079:            /**
080:             * Cancels this key.
081:             * 
082:             */
083:            public abstract void cancel();
084:
085:            /**
086:             * Gets the channel of this key.
087:             * 
088:             * @return the channel of this key
089:             */
090:            public abstract SelectableChannel channel();
091:
092:            /**
093:             * Gets the interesting operation of this key.
094:             * 
095:             * @return the interesting operation of this key
096:             * @throws CancelledKeyException
097:             *             If the key has been cancelled already
098:             */
099:            public abstract int interestOps();
100:
101:            /**
102:             * Sets the interesting operation for this key.
103:             * 
104:             * @param operations
105:             *            the interesting operation to set
106:             * @return this key
107:             * @throws IllegalArgumentException
108:             *             if the given operation is not in the key's interesting
109:             *             operation set
110:             * @throws CancelledKeyException
111:             *             If the key has been cancelled already
112:             */
113:            public abstract SelectionKey interestOps(int operations);
114:
115:            /**
116:             * Tells whether the channel of this key is interested in accept operation
117:             * and ready for acceptation.
118:             * 
119:             * @return true if the channel is interested in accept operation and ready
120:             *         for acceptation
121:             * @throws CancelledKeyException
122:             *             If the key has been cancelled already
123:             */
124:            public final boolean isAcceptable() {
125:                return (readyOps() & OP_ACCEPT) == OP_ACCEPT;
126:            }
127:
128:            /**
129:             * Tells whether the channel of this key is interested in connect operation
130:             * and ready for connection.
131:             * 
132:             * @return true if the channel is interested in connect operation and ready
133:             *         for connection
134:             * @throws CancelledKeyException
135:             *             If the key has been cancelled already
136:             */
137:            public final boolean isConnectable() {
138:                return (readyOps() & OP_CONNECT) == OP_CONNECT;
139:            }
140:
141:            /**
142:             * Tells whether the channel of this key is interested in read operation and
143:             * ready for reading.
144:             * 
145:             * @return true if the channel is interested in read operation and ready for
146:             *         reading
147:             * @throws CancelledKeyException
148:             *             If the key has been cancelled already
149:             */
150:            public final boolean isReadable() {
151:                return (readyOps() & OP_READ) == OP_READ;
152:            }
153:
154:            /**
155:             * Tells whether the key is valid.
156:             * 
157:             * @return true if the key has not been cancelled
158:             */
159:            public abstract boolean isValid();
160:
161:            /**
162:             * Tells whether the channel of this key is interested in write operation
163:             * and ready for writing.
164:             * 
165:             * @return true if the channel is interested in write operation and ready
166:             *         for writing
167:             * @throws CancelledKeyException
168:             *             If the key has been cancelled already
169:             */
170:            public final boolean isWritable() {
171:                return (readyOps() & OP_WRITE) == OP_WRITE;
172:            }
173:
174:            /**
175:             * Gets the ready operation.
176:             * 
177:             * @return the ready operation
178:             * @throws CancelledKeyException
179:             *             If the key has been cancelled already
180:             */
181:            public abstract int readyOps();
182:
183:            /**
184:             * Gets the related selector.
185:             * 
186:             * @return the related selector
187:             */
188:            public abstract Selector selector();
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.