Source Code Cross Referenced for WhereCondition.java in  » Content-Management-System » harmonise » org » openharmonise » commons » dsi » dml » 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 » Content Management System » harmonise » org.openharmonise.commons.dsi.dml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the 
003:         * Mozilla Public License Version 1.1 (the "License"); 
004:         * you may not use this file except in compliance with the License. 
005:         * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
009:         * See the License for the specific language governing rights and 
010:         * limitations under the License.
011:         *
012:         * The Initial Developer of the Original Code is Simulacra Media Ltd.
013:         * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014:         *
015:         * All Rights Reserved.
016:         *
017:         * Contributor(s):
018:         */
019:        package org.openharmonise.commons.dsi.dml;
020:
021:        import java.util.*;
022:
023:        import org.openharmonise.commons.dsi.*;
024:
025:        /**
026:         * This class represents a where condition which can be included in a DML statement.
027:         * 
028:         * Note: the default operator is the '=' operator.
029:         * 
030:         * @author Michael Bell
031:         * @version $Revision: 1.1 $
032:         *
033:         */
034:        public class WhereCondition extends Object {
035:
036:            /**
037:             * An array of valid operators
038:             */
039:            static private final String[] saValidOperators = { "<>", ">", "<",
040:                    "=", ">=", "<=", "!=", "IN", "CONTAINS", "BETWEEN", "LIKE",
041:                    "STARTS_WITH", "NOT IN", "NULL", "is", "is not" }; //TODO this list should be data store dependant...
042:
043:            /**
044:             * The column reference.
045:             */
046:            private ColumnRef m_colref = null;
047:
048:            /**
049:             * The comparison operator.
050:             */
051:            private String m_sOp = null;
052:
053:            /**
054:             * The list of values to be compared.
055:             */
056:            private List m_value = null;
057:
058:            /**
059:             * The collection of join conditions to be associaged with this where condition.
060:             */
061:            private JoinConditions m_associated_joins = null;
062:
063:            /**.
064:             * Constructs a where condition from the given parameters
065:             * 
066:             * @param colref the condition column reference
067:             * @param val the condition value
068:             * @throws DataStoreException if the data for the condition is somehow invalid
069:             */
070:            public WhereCondition(ColumnRef colref, int val)
071:                    throws DataStoreException {
072:                Vector vec = new Vector();
073:                vec.add(new Integer(val));
074:                addColumnRef(colref);
075:                addOperator("=");
076:                addValue(vec);
077:            }
078:
079:            /**
080:             * Constructs a where condition from the given parameters.
081:             * 
082:             * @param colref the condition column reference
083:             * @param sOp the comparison operator
084:             * @param val the condition value
085:             * @throws DataStoreException if the data for the condition is somehow invalid
086:             */
087:            public WhereCondition(ColumnRef colref, String sOp, int val)
088:                    throws DataStoreException {
089:                Vector vec = new Vector();
090:                vec.add(new Integer(val));
091:                addColumnRef(colref);
092:                addOperator(sOp);
093:                addValue(vec);
094:            }
095:
096:            /**
097:             * Constructs a where condition from the given parameters.
098:             * 
099:             * @param colref the condition column reference
100:             * @param val the condition value
101:             * @throws DataStoreException if the data for the condition is somehow invalid
102:             */
103:            public WhereCondition(ColumnRef colref, Object val)
104:                    throws DataStoreException {
105:
106:                Vector vec = new Vector();
107:                vec.add(val);
108:                addColumnRef(colref);
109:                addOperator("=");
110:                addValue(vec);
111:            }
112:
113:            /**
114:             * Constructs a where condition from the given parameters.
115:             * 
116:             * @param colref the condition column reference
117:             * @param sOp the comparison operator
118:             * @param val the condition value
119:             * @throws DataStoreException if the data for the condition is somehow invalid
120:             */
121:            public WhereCondition(ColumnRef colref, String sOp, Object val)
122:                    throws DataStoreException {
123:
124:                Vector vec = new Vector();
125:                vec.add(val);
126:                addColumnRef(colref);
127:                addOperator(sOp);
128:                addValue(vec);
129:            }
130:
131:            /**
132:             * Constructs a where condition from the given parameters.
133:             * 
134:             * @param colref the condition column reference
135:             * @param val the condition value
136:             * @throws DataStoreException if the data for the condition is somehow invalid
137:             */
138:            public WhereCondition(ColumnRef colref, Vector val)
139:                    throws DataStoreException {
140:                addColumnRef(colref);
141:                addOperator("=");
142:                addValue(val);
143:            }
144:
145:            /**
146:             * Constructs a where condition from the given parameters.
147:             * 
148:             * @param colref the condition column reference
149:             * @param sOp the comparison operator
150:             * @param val the list of condition values
151:             * @throws DataStoreException
152:             */
153:            public WhereCondition(ColumnRef colref, String sOp, List val)
154:                    throws DataStoreException {
155:                boolean bfound = false;
156:
157:                //check for valid operator
158:                int i = 0;
159:
160:                while ((i < saValidOperators.length) && !bfound) {
161:                    if (sOp.equalsIgnoreCase(saValidOperators[i])) {
162:                        bfound = true;
163:                    }
164:
165:                    i++;
166:                }
167:
168:                if (!bfound) {
169:                    throw new DataStoreException("Invalid Search Operator=" + i
170:                            + sOp + ":");
171:                }
172:
173:                m_colref = colref;
174:                m_sOp = sOp;
175:                m_value = val;
176:            }
177:
178:            /**
179:             * Adds the column reference for this condition.
180:             * 
181:             * @param colref the column reference
182:             */
183:            private void addColumnRef(ColumnRef colref) {
184:                m_colref = colref;
185:            }
186:
187:            /**
188:             * Adds the comparison operator for this condition.
189:             * 
190:             * @param sOp the comparison operator
191:             * 
192:             * @throws DataStoreException if the operator is invalid
193:             */
194:            private void addOperator(String sOp) throws DataStoreException {
195:                boolean bfound = false;
196:
197:                //check for valid operator
198:                int i = 0;
199:
200:                while ((i < saValidOperators.length) && !bfound) {
201:                    if (sOp.equalsIgnoreCase(saValidOperators[i])) {
202:                        bfound = true;
203:                    }
204:
205:                    i++;
206:                }
207:
208:                if (!bfound) {
209:                    throw new DataStoreException("Invalid Search Operator=" + i
210:                            + " - " + sOp);
211:                }
212:
213:                m_sOp = sOp;
214:            }
215:
216:            /**
217:             * Adds the conditional value to this condition.
218:             * 
219:             * @param val the conditional value
220:             */
221:            private void addValue(List val) {
222:                if (val == null) {
223:                    m_value = new Vector();
224:                    m_value.add(null);
225:                } else {
226:                    m_value = val;
227:                }
228:            }
229:
230:            /**
231:             * Returns the column reference for this condition.
232:             * 
233:             * @return the condition column reference
234:             */
235:            public ColumnRef getColumnRef() {
236:                return m_colref;
237:            }
238:
239:            /**
240:             * Returns the comparison operator for this condition.
241:             * 
242:             * @return the comparison operator
243:             */
244:            public String getOperator() {
245:                return m_sOp;
246:            }
247:
248:            /**
249:             * Returns the list of conditional values for this condition.
250:             * 
251:             * @return the list of conditional values
252:             */
253:            public List getValues() {
254:                return m_value;
255:            }
256:
257:            /**
258:             * Returns the column name for this condition.
259:             * 
260:             * @return the column name 
261:             */
262:            public String getColumnName() {
263:                return (m_colref.getColumn());
264:            }
265:
266:            /**
267:             * Returns the table name for this condition.
268:             * 
269:             * @return the table name
270:             */
271:            public String getTableName() {
272:                String sTable = m_colref.getTable();
273:
274:                if (m_colref.hasTableAlias() == true) {
275:                    sTable = m_colref.getTableAlias();
276:                }
277:
278:                return sTable;
279:            }
280:
281:            /**
282:             * Returns the full string representation for the column reference for condition.
283:             * 
284:             * @return the full string representation for the column reference
285:             */
286:            public String getFullColumnRef() {
287:                return (m_colref.getFullRef());
288:            }
289:
290:            /**
291:             * Adds join conditions which are associated with this condition.
292:             * 
293:             * @param joins the join conditions 
294:             */
295:            public void addAssociatedJoinConditions(JoinConditions joins) {
296:                m_associated_joins = joins;
297:            }
298:
299:            /**
300:             * Returns the join conditions that are associated with this condition.
301:             * 
302:             * @return the join conditions
303:             */
304:            public JoinConditions getAssociatedJoinConditions() {
305:                return m_associated_joins;
306:            }
307:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.