Source Code Cross Referenced for EntityConditionList.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: EntityConditionList.java,v 1.3 2003/11/07 00:33:56 jonesde Exp $
003:         *
004:         * Copyright (c) 2001, 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.Iterator;
028:        import java.util.List;
029:
030:        import org.ofbiz.entity.GenericEntity;
031:        import org.ofbiz.entity.GenericModelException;
032:        import org.ofbiz.entity.model.ModelEntity;
033:
034:        /**
035:         * Encapsulates a list of EntityConditions to be used as a single EntityCondition combined as specified
036:         *
037:         * @author     <a href="mailto:jonesde@ofbiz.org">David E. Jones</a>
038:         * @version    $Revision: 1.3 $
039:         * @since      2.0
040:         */
041:        public class EntityConditionList extends EntityCondition {
042:
043:            protected List conditionList;
044:            protected EntityJoinOperator operator;
045:
046:            protected EntityConditionList() {
047:            }
048:
049:            public EntityConditionList(List conditionList,
050:                    EntityJoinOperator operator) {
051:                this .conditionList = conditionList;
052:                this .operator = operator;
053:            }
054:
055:            public EntityOperator getOperator() {
056:                return this .operator;
057:            }
058:
059:            public EntityCondition getCondition(int index) {
060:                return (EntityCondition) this .conditionList.get(index);
061:            }
062:
063:            public int getConditionListSize() {
064:                return this .conditionList.size();
065:            }
066:
067:            public Iterator getConditionIterator() {
068:                return this .conditionList.iterator();
069:            }
070:
071:            public String makeWhereString(ModelEntity modelEntity,
072:                    List entityConditionParams) {
073:                // if (Debug.verboseOn()) Debug.logVerbose("makeWhereString for entity " + modelEntity.getEntityName(), module);
074:                StringBuffer whereStringBuffer = new StringBuffer();
075:
076:                if (conditionList != null && conditionList.size() > 0) {
077:                    for (int i = 0; i < conditionList.size(); i++) {
078:                        EntityCondition condition = (EntityCondition) conditionList
079:                                .get(i);
080:
081:                        whereStringBuffer.append('(');
082:                        whereStringBuffer.append(condition.makeWhereString(
083:                                modelEntity, entityConditionParams));
084:                        whereStringBuffer.append(')');
085:                        if (i < conditionList.size() - 1) {
086:                            whereStringBuffer.append(' ');
087:                            whereStringBuffer.append(operator.getCode());
088:                            whereStringBuffer.append(' ');
089:                        }
090:                    }
091:                }
092:                return whereStringBuffer.toString();
093:            }
094:
095:            public void checkCondition(ModelEntity modelEntity)
096:                    throws GenericModelException {
097:                // if (Debug.verboseOn()) Debug.logVerbose("checkCondition for entity " + modelEntity.getEntityName(), module);
098:                if (conditionList == null || conditionList.size() == 0)
099:                    return;
100:
101:                Iterator exprIter = conditionList.iterator();
102:                while (exprIter.hasNext()) {
103:                    EntityCondition entityCondition = (EntityCondition) exprIter
104:                            .next();
105:                    entityCondition.checkCondition(modelEntity);
106:                }
107:            }
108:
109:            public boolean entityMatches(GenericEntity entity) {
110:                if (conditionList != null && conditionList.size() > 0) {
111:                    boolean matches = true;
112:                    EntityCondition condition = (EntityCondition) conditionList
113:                            .get(0);
114:                    EntityOperator.MatchResult result = operator.join(
115:                            condition, entity);
116:                    for (int i = 1; !result.shortCircuit
117:                            && i < conditionList.size(); i++) {
118:                        condition = (EntityCondition) conditionList.get(i);
119:                        result = operator.join(condition, entity);
120:                    }
121:                    return result.matches;
122:                }
123:                return false;
124:            }
125:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.