Source Code Cross Referenced for DefaultMOQuery.java in  » Net » snmp4j » org » snmp4j » agent » 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 » Net » snmp4j » org.snmp4j.agent 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*_############################################################################
002:          _## 
003:          _##  SNMP4J-Agent - DefaultMOQuery.java  
004:          _## 
005:          _##  Copyright (C) 2005-2007  Frank Fock (SNMP4J.org)
006:          _##  
007:          _##  Licensed under the Apache License, Version 2.0 (the "License");
008:          _##  you may not use this file except in compliance with the License.
009:          _##  You may obtain a copy of the License at
010:          _##  
011:          _##      http://www.apache.org/licenses/LICENSE-2.0
012:          _##  
013:          _##  Unless required by applicable law or agreed to in writing, software
014:          _##  distributed under the License is distributed on an "AS IS" BASIS,
015:          _##  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016:          _##  See the License for the specific language governing permissions and
017:          _##  limitations under the License.
018:          _##  
019:          _##########################################################################*/
020:
021:        package org.snmp4j.agent;
022:
023:        // For JavaDoc
024:        import org.snmp4j.agent.request.Request;
025:
026:        /**
027:         * The <code>DefaultMOQuery</code> class is the default implementation of a
028:         * managed object query. It is used to lookup managed objects, for example in
029:         * a {@link MOServer} repository.
030:         *
031:         * @author Frank Fock
032:         * @version 1.1
033:         */
034:        public class DefaultMOQuery implements  MOQuery {
035:
036:            private MOContextScope scope;
037:            private boolean writeAccessQuery;
038:            private Object source;
039:
040:            /**
041:             * Creates a context aware query from a context aware OID scope.
042:             * @param scope
043:             *    a scope that defines the possible result set of OIDs from a specific
044:             *    context for this query.
045:             */
046:            public DefaultMOQuery(MOContextScope scope) {
047:                this .scope = scope;
048:            }
049:
050:            /**
051:             * Creates a context aware query from a context aware OID scope.
052:             * @param scope
053:             *    a scope that defines the possible result set of OIDs from a specific
054:             *    context for this query.
055:             * @param isWriteAccessIntended
056:             *    indicates whether this query serves a write access on
057:             *    {@link ManagedObject}s or not.
058:             * @since 1.1
059:             */
060:            public DefaultMOQuery(MOContextScope scope,
061:                    boolean isWriteAccessIntended) {
062:                this (scope);
063:                this .writeAccessQuery = isWriteAccessIntended;
064:            }
065:
066:            /**
067:             * Creates a context aware query from a context aware OID scope.
068:             * @param scope
069:             *    a scope that defines the possible result set of OIDs from a specific
070:             *    context for this query.
071:             * @param isWriteAccessIntended
072:             *    indicates whether this query serves a write access on
073:             *    {@link ManagedObject}s or not.
074:             * @since 1.1
075:             */
076:            public DefaultMOQuery(MOContextScope scope,
077:                    boolean isWriteAccessIntended, Object source) {
078:                this (scope, isWriteAccessIntended);
079:                this .source = source;
080:            }
081:
082:            /**
083:             * Gets the search range of this query.
084:             *
085:             * @return a <code>MORange</code> instance denoting upper and lower bound of
086:             *   this queries scope.
087:             */
088:            public MOContextScope getScope() {
089:                return scope;
090:            }
091:
092:            /**
093:             * Checks whether a managed object matches the internal query criteria
094:             * defined by this query.
095:             *
096:             * @param managedObject the <code>ManagedObject</code> instance to check.
097:             * @return <code>true</code> if the <code>managedObject</code> matches the
098:             *   query.
099:             */
100:            public boolean matchesQuery(ManagedObject managedObject) {
101:                return true;
102:            }
103:
104:            public void substractScope(MOScope scope) {
105:                if (this .scope instanceof  MutableMOScope) {
106:                    ((MutableMOScope) this .scope).substractScope(scope);
107:                } else {
108:                    throw new UnsupportedOperationException();
109:                }
110:            }
111:
112:            public String toString() {
113:                return getClass().getName() + "[" + getScope().getContext()
114:                        + "]=" + getScope().getLowerBound() + "<"
115:                        + (getScope().isLowerIncluded() ? "=" : "") + " x <"
116:                        + (getScope().isUpperIncluded() ? "=" : "")
117:                        + getScope().getUpperBound();
118:            }
119:
120:            public boolean isWriteAccessQuery() {
121:                return writeAccessQuery;
122:            }
123:
124:            /**
125:             * Gets the source ({@link Request}) object on whose behalf this query is
126:             * executed. This object reference can be used to determine whether a query
127:             * needs to update {@link ManagedObject} content or not. When the reference
128:             * is the same as those from the last query then an update is not necessary.
129:             *
130:             * @return
131:             *    an Object on whose behalf this query is executed which will be in most
132:             *    cases a {@link Request} instance, but code should not rely on that. If
133:             *    <code>null</code> is returned, the query source cannot be determined.
134:             * @since 1.1
135:             */
136:            public Object getSource() {
137:                return source;
138:            }
139:
140:            /**
141:             * This method checks whether the supplied query and the given source
142:             * reference refer to the same source (request).
143:             *
144:             * @param query
145:             *    a <code>MOQuery</code> instance.
146:             * @param source
147:             *    any source object reference.
148:             * @return
149:             *    <code>true</code> only if <code>query</code> is a
150:             *    <code>DefaultMOQuery</code> instance and
151:             *    <code>{@link DefaultMOQuery#getSource()} == source</code> and source
152:             *    is not <code>null</code>.
153:             * @since 1.1
154:             */
155:            public static boolean isSameSource(MOQuery query, Object source) {
156:                if (query instanceof  DefaultMOQuery) {
157:                    return ((source != null) && (((DefaultMOQuery) query)
158:                            .getSource() == source));
159:                }
160:                return false;
161:            }
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.