Source Code Cross Referenced for SearchCriteriaHolder.java in  » Database-ORM » ProjectJulp » org » julp » misc » search » 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 » Database ORM » ProjectJulp » org.julp.misc.search 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.julp.misc.search;
002:
003:        import java.util.*;
004:
005:        public class SearchCriteriaHolder implements  java.io.Serializable,
006:                Cloneable {
007:
008:            public SearchCriteriaHolder() {
009:            }
010:
011:            protected String fieldLabel = null;
012:            protected String fieldName = null;
013:            protected String operator = "=";
014:            protected String functions = null;
015:            protected Object searchValue = null;
016:            protected String booleanCondition = AND;
017:
018:            public static final String LESS = "<";
019:            public static final String LESS_OR_EQUALS = "<=";
020:            public static final String EQUALS = "=";
021:            public static final String LIKE = "LIKE";
022:            public static final String NOT_LIKE = "NOT LIKE";
023:            public static final String IN = "IN";
024:            public static final String NOT_IN = "NOT IN";
025:            public static final String NOT_EQUALS = "<>";
026:            public static final String NOT_EXISTS = "NOT EXISTS";
027:            public static final String EXISTS = "EXISTS";
028:            public static final String BETWEEN = "BETWEEN";
029:            public static final String NOT_BETWEEN = "NOT BETWEEN";
030:            public static final String IS = "IS";
031:            public static final String IS_NOT = "IS NOT";
032:            public static final String GREATER_OR_EQUALS = ">=";
033:            public static final String GREATER = ">";
034:
035:            public static final String AND = "AND";
036:            public static final String OR = "OR";
037:            public static final String AND_NESTED_LOGIC_START = "AND (";
038:            public static final String OR_NESTED_LOGIC_START = "OR (";
039:            public static final String AND_NESTED_LOGIC_END = ") AND";
040:            public static final String OR_NESTED_LOGIC_END = ") OR";
041:            public static final String AND_NESTED_LOGIC = ") AND (";
042:            public static final String OR_NESTED_LOGIC = ") OR (";
043:            public static final String NESTED_LOGIC_END = ")";
044:
045:            // hints for search using LIKE operator
046:            public static final int STARTS_WITH = 0;
047:            public static final int CONTAINS = 1;
048:            public static final int ENDS_WITH = 2;
049:            // default hint
050:            protected int likeHint = STARTS_WITH;
051:
052:            protected String operators = "<=NOT LIKE!=NOT IN<>NOT EXISTSNOT BETWEEN IS NOT >=";
053:            protected Map searchValuesMap = null;
054:            protected List searchValuesList = null;
055:
056:            /** Getter for property fieldName.
057:             * @return Value of property fieldName.
058:             *
059:             */
060:            public java.lang.String getFieldName() {
061:                return fieldName;
062:            }
063:
064:            /** Setter for property fieldName.
065:             * @param fieldName New value of property fieldName.
066:             *
067:             */
068:            public void setFieldName(java.lang.String fieldName) {
069:                this .fieldName = fieldName;
070:            }
071:
072:            /** Getter for property operator.
073:             * @return Value of property operator.
074:             *
075:             */
076:            public java.lang.String getOperator() {
077:                return operator;
078:            }
079:
080:            /** Setter for property operator.
081:             * @param operator New value of property operator.
082:             *
083:             */
084:            public void setOperator(java.lang.String operator) {
085:                if (operators.indexOf(operator.toUpperCase()) == -1) {
086:                    throw new IllegalArgumentException("Invalid Operator: "
087:                            + operator);
088:                }
089:                this .operator = operator;
090:            }
091:
092:            /** Getter for property searchValue.
093:             * @return Value of property searchValue.
094:             *
095:             */
096:            public java.lang.Object getSearchValue() {
097:                return searchValue;
098:            }
099:
100:            /** Setter for property searchValue.
101:             * @param searchValue New value of property searchValue.
102:             *
103:             */
104:            public void setSearchValue(java.lang.Object searchValue) {
105:                this .searchValue = searchValue;
106:            }
107:
108:            /** Getter for property booleanCondition.
109:             * @return Value of property booleanCondition.
110:             *
111:             */
112:            public java.lang.String getBooleanCondition() {
113:                return booleanCondition;
114:            }
115:
116:            /** Setter for property booleanCondition.
117:             * @param booleanCondition New value of property booleanCondition.
118:             *
119:             */
120:            public void setBooleanCondition(java.lang.String booleanCondition) {
121:                if (booleanCondition == null) {
122:                    throw new IllegalArgumentException(
123:                            "Missing Boolean Condition. (AND/OR)");
124:                }
125:                String tmp = booleanCondition.toUpperCase();
126:                if (booleanCondition.equalsIgnoreCase(AND) || tmp.equals(OR)
127:                        || tmp.equals(AND_NESTED_LOGIC_START)
128:                        || tmp.equals(AND_NESTED_LOGIC_END)
129:                        || tmp.equals(OR_NESTED_LOGIC_START)
130:                        || tmp.equals(NESTED_LOGIC_END)
131:                        || tmp.equals(OR_NESTED_LOGIC_END)
132:                        || tmp.equals(OR_NESTED_LOGIC)
133:                        || tmp.equals(AND_NESTED_LOGIC)) {
134:                } else {
135:                    throw new IllegalArgumentException(
136:                            "Invalid Boolean Condition: \n\n"
137:                                    + booleanCondition
138:                                    + " \n\nOnly AND/OR must be used");
139:                }
140:                this .booleanCondition = booleanCondition;
141:            }
142:
143:            public String toString() {
144:                StringBuffer sb = new StringBuffer();
145:                String space = " ";
146:                if (functions != null) {
147:                    sb.append(functions.replaceFirst("${}", fieldName));
148:                } else {
149:                    sb.append(fieldName);
150:                }
151:                sb.append(space).append(operator).append(space);
152:                sb.append(searchValue);
153:                sb.append(space).append(booleanCondition).append(space);
154:
155:                return sb.toString();
156:            }
157:
158:            /** Getter for property searchValuesMap.
159:             * @return Value of property searchValuesMap.
160:             *
161:             */
162:            public java.util.Map getSearchValuesMap() {
163:                return searchValuesMap;
164:            }
165:
166:            /** Setter for property searchValuesMap.
167:             * @param searchValuesMap New value of property searchValuesMap.
168:             *
169:             */
170:            public void setSearchValuesMap(java.util.Map searchValuesMap) {
171:                this .searchValuesMap = searchValuesMap;
172:            }
173:
174:            /** Getter for property fieldLabel.
175:             * @return Value of property fieldLabel.
176:             *
177:             */
178:            public java.lang.String getFieldLabel() {
179:                return fieldLabel;
180:            }
181:
182:            /** Setter for property fieldLabel.
183:             * @param fieldLabel New value of property fieldLabel.
184:             *
185:             */
186:            public void setFieldLabel(java.lang.String fieldLabel) {
187:                this .fieldLabel = fieldLabel;
188:            }
189:
190:            /**
191:             * Getter for property searchValuesList.
192:             * @return Value of property searchValuesList.
193:             */
194:            public java.util.List getSearchValuesList() {
195:                return searchValuesList;
196:            }
197:
198:            /**
199:             * Setter for property searchValuesList.
200:             * @param searchValuesList New value of property searchValuesList.
201:             */
202:            public void setSearchValuesList(java.util.List searchValuesList) {
203:                this .searchValuesList = searchValuesList;
204:            }
205:
206:            /**
207:             * Getter for property likeHint.
208:             * @return Value of property likeHint.
209:             */
210:            public int getLikeHint() {
211:                return likeHint;
212:            }
213:
214:            /**
215:             * Setter for property likeHint.
216:             * @param likeHint New value of property likeHint.     
217:             */
218:            public void setLikeHint(int likeHint) {
219:                this .likeHint = likeHint;
220:            }
221:
222:            /**
223:             * Getter for property functions.
224:             * @return Value of property functions.      
225:             */
226:            public java.lang.String getFunctions() {
227:                return this .functions;
228:            }
229:
230:            /**
231:             * Setter for property functions.
232:             * @param functions New value of property functions.
233:             * Example:
234:             * Assume the value of the field is 'This is a test'
235:             *
236:             * SearchCriteriaHolder holder = new SearchCriteriaHolder();
237:             * ...
238:             * holder.setFunctions("CONCAT(UPPER(SUBSTR(${}, 10)), 'XYZ')" );
239:             * ...
240:             * result would be: TESTXYZ
241:             */
242:            public void setFunctions(java.lang.String functions) {
243:                this.functions = functions;
244:            }
245:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.