Source Code Cross Referenced for SelectItem.java in  » Web-Server » Rimfaxe-Web-Server » seda » nbio » 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 » Web Server » Rimfaxe Web Server » seda.nbio 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * Copyright (c) 2000 by Matt Welsh and The Regents of the University of 
003:         * California. All rights reserved.
004:         *
005:         * Permission to use, copy, modify, and distribute this software and its
006:         * documentation for any purpose, without fee, and without written agreement is
007:         * hereby granted, provided that the above copyright notice and the following
008:         * two paragraphs appear in all copies of this software.
009:         * 
010:         * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
011:         * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
012:         * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
013:         * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
014:         * 
015:         * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
016:         * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
017:         * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
018:         * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
019:         * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
020:         *
021:         * Author: Matt Welsh <mdw@cs.berkeley.edu>
022:         * 
023:         */
024:
025:        package seda.nbio;
026:
027:        /**
028:         * A SelectItem represents a single socket/file descriptor/etc. which
029:         * can be handled by a SelectSet. Each SelectItem has an associated
030:         * Selectable as well as two event masks: 'events' and 'revents'.
031:         * Setting 'events' allows you to specify which events you are
032:         * interested in receiving notification on for this Selectable.
033:         * After calling SelectSet.select(), 'revents' will be set to the
034:         * set of events that occurred. 
035:         */
036:        public class SelectItem {
037:            private Selectable sel; // Do not let user change this without updating fd
038:
039:            /**
040:             * The set of events that you are interested in receiving notification on.
041:             * The event types are specified by the constants in Selectable.
042:             *
043:             * <p><b>Important:</b> If you change the events field of a SelectItem
044:             * after registering it with a SelectSet (using SelectSet.add()), 
045:             * you must invoke SelectSet.update() to push the new event mask to the
046:             * SelectSet.
047:             *
048:             * @see Selectable
049:             * @see SelectSet
050:             */
051:            public short events;
052:
053:            /**
054:             * The set of events that occurred.
055:             * The event types are specified by the constants in Selectable.
056:             * @see Selectable
057:             */
058:            public short revents;
059:
060:            /** 
061:             * A state object associated with this SelectItem. You can use this
062:             * for any purpose you like.
063:             */
064:            public Object obj;
065:
066:            private NBIOFileDescriptor fd;
067:
068:            private void updatefd() {
069:                // We want to keep a clone of the fd here, since if the socket 
070:                // closes, we want to remember the fd for deregistering with SelectSet.
071:                if (sel instanceof  NonblockingSocket) {
072:                    fd = ((NonblockingSocket) sel).impl.getFileDescriptor()
073:                            .getClone();
074:                } else if (sel instanceof  NonblockingServerSocket) {
075:                    fd = ((NonblockingServerSocket) sel).impl
076:                            .getFileDescriptor().getClone();
077:                } else if (sel instanceof  NonblockingDatagramSocket) {
078:                    fd = ((NonblockingDatagramSocket) sel).impl
079:                            .getFileDescriptor().getClone();
080:                } else {
081:                    throw new IllegalArgumentException(
082:                            "Selectable must support internal NBIOFileDescriptor");
083:                }
084:            }
085:
086:            // So SelectSet can get fd
087:            NBIOFileDescriptor getFD() {
088:                return fd;
089:            }
090:
091:            /**
092:             * Create a SelectItem with the given Selectable, given state pointer,
093:             * and the given event mask.
094:             */
095:            public SelectItem(Selectable sel, Object obj, short events) {
096:                this .sel = sel;
097:                this .obj = obj;
098:                this .events = events;
099:                this .revents = (short) 0;
100:                updatefd();
101:            }
102:
103:            /**
104:             * Create a SelectItem with the given Selectable and the given event
105:             * mask.
106:             */
107:            public SelectItem(Selectable sel, short events) {
108:                this (sel, null, events);
109:            }
110:
111:            /**
112:             * Return the Selectable associated with this SelectItem.
113:             */
114:            public Selectable getSelectable() {
115:                return sel;
116:            }
117:
118:            /**
119:             * Return the state pointer associated with this SelectItem.
120:             */
121:            public Object getObj() {
122:                return obj;
123:            }
124:
125:            /**
126:             * Return the requested events mask.
127:             */
128:            public short getEvents() {
129:                return events;
130:            }
131:
132:            /**
133:             * Return the returned events mask.
134:             */
135:            public short returnedEvents() {
136:                return revents;
137:            }
138:
139:            public String toString() {
140:                return "SelectItem [sel=" + sel + "] events=0x"
141:                        + Integer.toHexString(events) + " revents=0x"
142:                        + Integer.toHexString(revents);
143:            }
144:
145:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.