Source Code Cross Referenced for NotifierArgs.java in  » 6.0-JDK-Modules-com.sun » jndi » com » sun » jndi » ldap » 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 » 6.0 JDK Modules com.sun » jndi » com.sun.jndi.ldap 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1999 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:
026:        package com.sun.jndi.ldap;
027:
028:        import javax.naming.directory.SearchControls;
029:        import javax.naming.event.*;
030:
031:        /**
032:         * This class holds the information in an event registration/deregistration
033:         * request. This includes the name, filter, search controls and 
034:         * the different interfaces that the listener implements. This last piece
035:         * of information determines which event(s) the listener is interested in.
036:         *<p>
037:         * It overrides equals() and hashCode() to use all these pieces of
038:         * information so that it can be used correctly in a hashtable.
039:         *
040:         * @author Rosanna Lee
041:         */
042:        final class NotifierArgs {
043:            static final int ADDED_MASK = 0x1;
044:            static final int REMOVED_MASK = 0x2;
045:            static final int CHANGED_MASK = 0x4;
046:            static final int RENAMED_MASK = 0x8;
047:
048:            // these fields are package private; used by NamingEventNotifier
049:            String name;
050:            String filter;
051:            SearchControls controls;
052:            int mask;
053:
054:            // package private
055:            NotifierArgs(String name, int scope, NamingListener l) {
056:                this (name, "(objectclass=*)", null, l);
057:
058:                // if scope is not default, create search ctl and set it
059:                if (scope != EventContext.ONELEVEL_SCOPE) {
060:                    controls = new SearchControls();
061:                    controls.setSearchScope(scope);
062:                }
063:            }
064:
065:            // package private
066:            NotifierArgs(String name, String filter, SearchControls ctls,
067:                    NamingListener l) {
068:                this .name = name;
069:                this .filter = filter;
070:                this .controls = ctls;
071:
072:                if (l instanceof  NamespaceChangeListener) {
073:                    mask |= ADDED_MASK | REMOVED_MASK | RENAMED_MASK;
074:                }
075:                if (l instanceof  ObjectChangeListener) {
076:                    mask |= CHANGED_MASK;
077:                }
078:            }
079:
080:            // checks name, filter, controls
081:            public boolean equals(Object obj) {
082:                if (obj instanceof  NotifierArgs) {
083:                    NotifierArgs target = (NotifierArgs) obj;
084:                    return mask == target.mask && name.equals(target.name)
085:                            && filter.equals(target.filter)
086:                            && checkControls(target.controls);
087:                }
088:                return false;
089:            }
090:
091:            private boolean checkControls(SearchControls ctls) {
092:                if ((controls == null || ctls == null)) {
093:                    return ctls == controls;
094:                }
095:                // ctls are nonempty
096:
097:                return (controls.getSearchScope() == ctls.getSearchScope())
098:                        && (controls.getTimeLimit() == ctls.getTimeLimit())
099:                        && (controls.getDerefLinkFlag() == ctls
100:                                .getDerefLinkFlag())
101:                        && (controls.getReturningObjFlag() == ctls
102:                                .getReturningObjFlag())
103:                        && (controls.getCountLimit() == ctls.getCountLimit())
104:                        && checkStringArrays(controls.getReturningAttributes(),
105:                                ctls.getReturningAttributes());
106:            }
107:
108:            private static boolean checkStringArrays(String[] s1, String[] s2) {
109:                if ((s1 == null) || (s2 == null)) {
110:                    return s1 == s2;
111:                }
112:
113:                // both are nonnull
114:                if (s1.length != s2.length) {
115:                    return false;
116:                }
117:
118:                for (int i = 0; i < s1.length; i++) {
119:                    if (!s1[i].equals(s2[i])) {
120:                        return false;
121:                    }
122:                }
123:                return true;
124:            }
125:
126:            // save from having to recalculate each time
127:            private int sum = -1;
128:
129:            public int hashCode() {
130:                if (sum == -1)
131:                    sum = mask + name.hashCode() + filter.hashCode()
132:                            + controlsCode();
133:                return sum;
134:            }
135:
136:            // used in calculating hash code
137:            private int controlsCode() {
138:                if (controls == null)
139:                    return 0;
140:
141:                int total = (int) controls.getTimeLimit()
142:                        + (int) controls.getCountLimit()
143:                        + (controls.getDerefLinkFlag() ? 1 : 0)
144:                        + (controls.getReturningObjFlag() ? 1 : 0);
145:
146:                String[] attrs = controls.getReturningAttributes();
147:                if (attrs != null) {
148:                    for (int i = 0; i < attrs.length; i++) {
149:                        total += attrs[i].hashCode();
150:                    }
151:                }
152:
153:                return total;
154:            }
155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.