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


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