Source Code Cross Referenced for EntityOperator.java in  » ERP-CRM-Financial » SourceTap-CRM » org » ofbiz » entity » condition » 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 » ERP CRM Financial » SourceTap CRM » org.ofbiz.entity.condition 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: EntityOperator.java,v 1.3 2004/01/14 00:08:11 ajzeneski Exp $
003:         *
004:         *  Copyright (c) 2002 The Open For Business Project - www.ofbiz.org
005:         *
006:         *  Permission is hereby granted, free of charge, to any person obtaining a
007:         *  copy of this software and associated documentation files (the "Software"),
008:         *  to deal in the Software without restriction, including without limitation
009:         *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
010:         *  and/or sell copies of the Software, and to permit persons to whom the
011:         *  Software is furnished to do so, subject to the following conditions:
012:         *
013:         *  The above copyright notice and this permission notice shall be included
014:         *  in all copies or substantial portions of the Software.
015:         *
016:         *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
017:         *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
018:         *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
019:         *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
020:         *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
021:         *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
022:         *  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
023:         */
024:
025:        package org.ofbiz.entity.condition;
026:
027:        import java.util.HashMap;
028:
029:        /**
030:         * Encapsulates operations between entities and entity fields. This is a immutable class.
031:         *
032:         *@author     <a href='mailto:chris_maurer@altavista.com'>Chris Maurer</a>
033:         *@author     <a href="mailto:jonesde@ofbiz.org">David E. Jones</a>
034:         *@author     <a href="mailto:jaz@ofbiz.org">Andy Zeneski</a>
035:         *@version    $Revision: 1.3 $
036:         *@since      2.0
037:         */
038:        public class EntityOperator implements  java.io.Serializable {
039:
040:            public static final int ID_EQUALS = 1;
041:            public static final int ID_NOT_EQUAL = 2;
042:            public static final int ID_LESS_THAN = 3;
043:            public static final int ID_GREATER_THAN = 4;
044:            public static final int ID_LESS_THAN_EQUAL_TO = 5;
045:            public static final int ID_GREATER_THAN_EQUAL_TO = 6;
046:            public static final int ID_IN = 7;
047:            public static final int ID_BETWEEN = 8;
048:            public static final int ID_NOT = 9;
049:            public static final int ID_AND = 10;
050:            public static final int ID_OR = 11;
051:            public static final int ID_LIKE = 12;
052:            public static final int ID_NOT_IN = 13;
053:
054:            private static HashMap registry = new HashMap();
055:
056:            private static void register(String name, EntityOperator operator) {
057:                registry.put(name, operator);
058:            }
059:
060:            public static EntityOperator lookup(String name) {
061:                return (EntityOperator) registry.get(name);
062:            }
063:
064:            public static EntityComparisonOperator lookupComparison(String name) {
065:                EntityOperator operator = lookup(name);
066:                if (!(operator instanceof  EntityComparisonOperator))
067:                    throw new IllegalArgumentException(name
068:                            + " is not a comparison operator");
069:                return (EntityComparisonOperator) operator;
070:            }
071:
072:            public static EntityJoinOperator lookupJoin(String name) {
073:                EntityOperator operator = lookup(name);
074:                if (!(operator instanceof  EntityJoinOperator))
075:                    throw new IllegalArgumentException(name
076:                            + " is not a join operator");
077:                return (EntityJoinOperator) operator;
078:            }
079:
080:            public static final EntityComparisonOperator EQUALS = new EntityComparisonOperator(
081:                    ID_EQUALS, "=") {
082:                public boolean compare(Object lhs, Object rhs) {
083:                    return EntityComparisonOperator.compareEqual(lhs, rhs);
084:                }
085:            };
086:            static {
087:                register("equals", EQUALS);
088:            }
089:            public static final EntityComparisonOperator NOT_EQUAL = new EntityComparisonOperator(
090:                    ID_NOT_EQUAL, "<>") {
091:                public boolean compare(Object lhs, Object rhs) {
092:                    return EntityComparisonOperator.compareNotEqual(lhs, rhs);
093:                }
094:            };
095:            static {
096:                register("notEqual", NOT_EQUAL);
097:            }
098:            public static final EntityComparisonOperator LESS_THAN = new EntityComparisonOperator(
099:                    ID_LESS_THAN, "<") {
100:                public boolean compare(Object lhs, Object rhs) {
101:                    return EntityComparisonOperator.compareLessThan(lhs, rhs);
102:                }
103:            };
104:            static {
105:                register("lessThan", LESS_THAN);
106:            }
107:            public static final EntityComparisonOperator GREATER_THAN = new EntityComparisonOperator(
108:                    ID_GREATER_THAN, ">") {
109:                public boolean compare(Object lhs, Object rhs) {
110:                    return EntityComparisonOperator
111:                            .compareGreaterThan(lhs, rhs);
112:                }
113:            };
114:            static {
115:                register("greaterThan", GREATER_THAN);
116:            }
117:            public static final EntityComparisonOperator LESS_THAN_EQUAL_TO = new EntityComparisonOperator(
118:                    ID_LESS_THAN_EQUAL_TO, "<=") {
119:                public boolean compare(Object lhs, Object rhs) {
120:                    return EntityComparisonOperator.compareLessThanEqualTo(lhs,
121:                            rhs);
122:                }
123:            };
124:            static {
125:                register("lessThanEqualTo", LESS_THAN_EQUAL_TO);
126:            }
127:            public static final EntityComparisonOperator GREATER_THAN_EQUAL_TO = new EntityComparisonOperator(
128:                    ID_GREATER_THAN_EQUAL_TO, ">=") {
129:                public boolean compare(Object lhs, Object rhs) {
130:                    return EntityComparisonOperator.compareGreaterThanEqualTo(
131:                            lhs, rhs);
132:                }
133:            };
134:            static {
135:                register("greaterThanEqualTo", GREATER_THAN_EQUAL_TO);
136:            }
137:            public static final EntityComparisonOperator IN = new EntityComparisonOperator(
138:                    ID_IN, "IN") {
139:                public boolean compare(Object lhs, Object rhs) {
140:                    return EntityComparisonOperator.compareIn(lhs, rhs);
141:                }
142:            };
143:            static {
144:                register("in", IN);
145:            }
146:            public static final EntityComparisonOperator BETWEEN = new EntityComparisonOperator(
147:                    ID_BETWEEN, "BETWEEN");
148:            static {
149:                register("between", BETWEEN);
150:            }
151:            public static final EntityComparisonOperator NOT = new EntityComparisonOperator(
152:                    ID_NOT, "NOT");
153:            static {
154:                register("not", NOT);
155:            }
156:            public static final EntityJoinOperator AND = new EntityJoinOperator(
157:                    ID_AND, "AND", false);
158:            static {
159:                register("and", AND);
160:            }
161:            public static final EntityJoinOperator OR = new EntityJoinOperator(
162:                    ID_OR, "OR", true);
163:            static {
164:                register("or", OR);
165:            }
166:            public static final EntityComparisonOperator LIKE = new EntityComparisonOperator(
167:                    ID_LIKE, "LIKE") {
168:                public boolean compare(Object lhs, Object rhs) {
169:                    return EntityComparisonOperator.compareLike(lhs, rhs);
170:                }
171:            };
172:            static {
173:                register("like", LIKE);
174:            }
175:            public static final EntityComparisonOperator NOT_IN = new EntityComparisonOperator(
176:                    ID_NOT_IN, "NOT IN");
177:            static {
178:                register("not-in", NOT_IN);
179:            }
180:
181:            protected int idInt;
182:            protected String codeString;
183:
184:            public EntityOperator(int id, String code) {
185:                idInt = id;
186:                codeString = code;
187:            }
188:
189:            public String getCode() {
190:                if (codeString == null)
191:                    return "null";
192:                else
193:                    return codeString;
194:            }
195:
196:            public int getId() {
197:                return idInt;
198:            }
199:
200:            public String toString() {
201:                return codeString;
202:            }
203:
204:            public int hashCode() {
205:                return this .codeString.hashCode();
206:            }
207:
208:            public boolean equals(Object obj) {
209:                EntityOperator otherOper = (EntityOperator) obj;
210:                return this .idInt == otherOper.idInt;
211:            }
212:
213:            public class MatchResult {
214:                public boolean shortCircuit = false;
215:                public boolean matches = false;
216:            }
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.