Source Code Cross Referenced for MatchNSNotQuery.java in  » Search-Engine » Jofti » com » jofti » query » namespace » 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 » Search Engine » Jofti » com.jofti.query.namespace 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.jofti.query.namespace;
002:
003:        import com.jofti.api.IndexQuery;
004:        import com.jofti.cache.adapter.NameSpaceWrapper;
005:        import com.jofti.core.INameSpace;
006:        import com.jofti.core.INameSpaceAware;
007:        import com.jofti.core.QueryId;
008:        import com.jofti.core.QueryType;
009:        import com.jofti.util.ReflectionUtil;
010:
011:        /**
012:         * 
013:         *
014:         * A utility class to enable simple queries to be done easily. The Query matches everything does not match 
015:         * the value for particular field. This is equivalent to !=.
016:         * <p>
017:         * All nameSpace queries must provide a correct namespace type for the implementation. Some nameSPaces 
018:         * are hierachical and so the search will use the nameSpace as starting point. Others are flat and so there is no 
019:         * traversal step.
020:         * <p>
021:         * This query cannot be combined with any other. iF you want to construct more complex queries use the @link com.jofti.query.Query class.
022:         *@author steve Woodcock
023:         */
024:        public class MatchNSNotQuery implements  IndexQuery, INameSpaceAware,
025:                QueryId {
026:
027:            Class className;
028:            Object nameSpace;
029:            String propertyName;
030:            Comparable value;
031:            public final Object alias;
032:            static final QueryType QUERY_ID = QueryType.NOT_NS_QUERY;
033:
034:            /**
035:             * Construct a query supplying the classname of the object type to be returned, the namespace 
036:             * under which to start the search. The field to be queried and the value to be used. 
037:             * <p>
038:             * The field type in the object and the value must be of the same type.
039:             * <p>
040:             * 
041:             * An example usage (for JBossCache) would be:
042:             * <p>
043:             * new MatchNSNotQuery("org.package.Myclass", "/test", "myProperty" ,"some value");
044:             * <p>
045:             * @param className - the class of object to be returned.
046:             * @param nameSpace - the name space to be searched.
047:             * @param propertyName - the field name to use
048:             * @param value - the value that is used as the search value.
049:             */
050:
051:            public MatchNSNotQuery(Class className, Object nameSpace,
052:                    String propertyName, Comparable value) {
053:                this (className, nameSpace, propertyName, value, null);
054:            }
055:
056:            public MatchNSNotQuery(Class className, Object nameSpace,
057:                    String propertyName, Comparable value, Object alias) {
058:                this .className = className;
059:                this .propertyName = propertyName;
060:                this .value = value;
061:                this .nameSpace = nameSpace;
062:                this .alias = alias;
063:            }
064:
065:            public MatchNSNotQuery(String className, Object nameSpace,
066:                    String propertyName, Comparable value) {
067:                this (className, nameSpace, propertyName, value, null);
068:            }
069:
070:            public MatchNSNotQuery(String className, Object nameSpace,
071:                    String propertyName, Comparable value, Object alias) {
072:                Class clazz = null;
073:                try {
074:                    clazz = ReflectionUtil.classForName(className);
075:                } catch (Exception e) {
076:                    throw new RuntimeException(e);
077:                }
078:                this .className = clazz;
079:                this .propertyName = propertyName;
080:                this .value = value;
081:                this .nameSpace = nameSpace;
082:                this .alias = alias;
083:            }
084:
085:            /**
086:             * Construct a query supplying the value to be searched against and the namespace 
087:             * under which to start the search. This is a convenience method for classes (such as String,Integer etc)
088:             * that have no property value as such. Instead the value is the class type.
089:             * <p>
090:             * 
091:             * An example usage (for JBossCache) would be:
092:             * <p>
093:             * new MatchNSNotQuery("/test","some value");
094:             * <p>
095:             * This is so you do not have to use the methods above in the manner of
096:             * <p>
097:             * new MatchNSNotQuery("java.lang.String", "/test", null ,"some value"); 
098:             * <p>
099:
100:             * @param nameSpace - the name space to be searched.
101:             * @param value - the value that is used as the search value.
102:             */
103:            public MatchNSNotQuery(Object nameSpace, Comparable value) {
104:                this (nameSpace, value, null);
105:            }
106:
107:            public MatchNSNotQuery(Object nameSpace, Comparable value,
108:                    Object alias) {
109:                this .value = value;
110:                this .nameSpace = nameSpace;
111:                this .alias = alias;
112:
113:            }
114:
115:            /**
116:             * @return Returns the className.
117:             */
118:            public Class getClassName() {
119:                return className;
120:            }
121:
122:            /**
123:             * @return Returns the propertyName.
124:             */
125:            public String getPropertyName() {
126:                return propertyName;
127:            }
128:
129:            /**
130:             * @return Returns the value.
131:             */
132:            public Comparable getValue() {
133:                return value;
134:            }
135:
136:            /**
137:             * @return Returns the wrapper.
138:             */
139:            public synchronized INameSpace getNameSpaceWrapper() {
140:
141:                if (nameSpace instanceof  INameSpace) {
142:                    return (INameSpace) nameSpace;
143:                } else {
144:                    return new NameSpaceWrapper(nameSpace);
145:                }
146:            }
147:
148:            /**
149:             * @return Returns the nameSpace.
150:             */
151:            public synchronized Object getNameSpace() {
152:                return nameSpace;
153:            }
154:
155:            /**
156:             * @param nameSpace The nameSpace to set.
157:             */
158:            public synchronized void setNameSpace(Object nameSpace) {
159:                this .nameSpace = nameSpace;
160:            }
161:
162:            public boolean equals(Object o) {
163:                if (o instanceof  MatchNSNotQuery) {
164:                    MatchNSNotQuery temp = (MatchNSNotQuery) o;
165:                    boolean result = nameSpace.equals(temp.nameSpace);
166:                    if (!result) {
167:                        return result;
168:                    }
169:                    if (className != null && temp.className != null) {
170:                        result = className.equals(temp.className);
171:                        if (!result) {
172:                            return result;
173:                        }
174:                    } else {
175:                        result = className == null & temp.className == null;
176:                        if (!result) {
177:                            return result;
178:                        }
179:                    }
180:
181:                    if (propertyName != null && temp.propertyName != null) {
182:                        result = propertyName.equals(temp.propertyName);
183:                        if (!result) {
184:                            return result;
185:                        }
186:                    } else {
187:                        result = propertyName == null
188:                                & temp.propertyName == null;
189:                        if (!result) {
190:                            return result;
191:                        }
192:                    }
193:                    if (value != null && temp.value != null) {
194:                        result = value.equals(temp.value);
195:                        if (!result) {
196:                            return result;
197:                        }
198:                    } else {
199:                        result = value == null & temp.value == null;
200:                        if (!result) {
201:                            return result;
202:                        }
203:                    }
204:                    return result;
205:                }
206:                return false;
207:            }
208:
209:            public int hashCode() {
210:                int temp = nameSpace.hashCode();
211:                if (className != null) {
212:                    temp += className.hashCode();
213:                }
214:                if (propertyName != null) {
215:                    temp += propertyName.hashCode();
216:                }
217:                if (value != null) {
218:                    temp += value.hashCode();
219:                }
220:                return temp;
221:
222:            }
223:
224:            public Object getAlias() {
225:                return alias;
226:            }
227:
228:            /* (non-Javadoc)
229:             * @see com.jofti.core.QueryId#getQueryType()
230:             */
231:            public QueryType getQueryType() {
232:
233:                return QUERY_ID;
234:            }
235:
236:            public IndexQuery setParameter(String name, Object value) {
237:                throw new UnsupportedOperationException(
238:                        "Parameters are not supported for convenience classes");
239:            }
240:
241:            /* (non-Javadoc)
242:             * @see com.jofti.api.IndexQuery#setParameter(int, java.lang.Object)
243:             */
244:            public IndexQuery setParameter(int position, Object value) {
245:                throw new UnsupportedOperationException(
246:                        "Parameters are not supported for convenience classes");
247:
248:            }
249:
250:            public IndexQuery setFirstResult(int firstResult) {
251:                throw new UnsupportedOperationException(
252:                        "Result limitation is not supported for convenience classes");
253:            }
254:
255:            public IndexQuery setMaxResults(int maxResults) {
256:                throw new UnsupportedOperationException(
257:                        "Result limitation is not supported for convenience classes");
258:            }
259:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.