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


001:        /*******************************************************************************
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements.  See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership.  The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License.  You may obtain a copy of the License at
009:         * 
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied.  See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         *******************************************************************************/package org.ofbiz.entity.condition;
019:
020:        import java.io.Serializable;
021:        import java.util.Collections;
022:        import java.util.List;
023:        import java.util.Map;
024:
025:        import javolution.util.FastList;
026:        import javolution.util.FastMap;
027:
028:        import org.ofbiz.entity.config.DatasourceInfo;
029:        import org.ofbiz.entity.jdbc.SqlJdbcUtil;
030:        import org.ofbiz.entity.model.ModelEntity;
031:        import org.ofbiz.entity.model.ModelField;
032:        import org.ofbiz.entity.model.ModelViewEntity;
033:        import org.ofbiz.entity.model.ModelViewEntity.ModelAlias;
034:
035:        /**
036:         * Represents the conditions to be used to constrain a query
037:         * <br/>An EntityCondition can represent various type of constraints, including:
038:         * <ul>
039:         *  <li>EntityConditionList: a list of EntityConditions, combined with the operator specified
040:         *  <li>EntityExpr: for simple expressions or expressions that combine EntityConditions
041:         *  <li>EntityFieldMap: a map of fields where the field (key) equals the value, combined with the operator specified
042:         * </ul>
043:         * These can be used in various combinations using the EntityConditionList and EntityExpr objects.
044:         *
045:         */
046:        public abstract class EntityConditionBase implements  Serializable {
047:
048:            public static final List emptyList = Collections
049:                    .unmodifiableList(FastList.newInstance());
050:            public static final Map emptyMap = Collections
051:                    .unmodifiableMap(FastMap.newInstance());
052:
053:            protected ModelField getField(ModelEntity modelEntity,
054:                    String fieldName) {
055:                ModelField modelField = null;
056:                if (modelEntity != null) {
057:                    modelField = modelEntity.getField(fieldName);
058:                }
059:                return modelField;
060:            }
061:
062:            protected String getColName(Map tableAliases,
063:                    ModelEntity modelEntity, String fieldName,
064:                    boolean includeTableNamePrefix,
065:                    DatasourceInfo datasourceInfo) {
066:                if (modelEntity == null)
067:                    return fieldName;
068:                return getColName(tableAliases, modelEntity, getField(
069:                        modelEntity, fieldName), fieldName,
070:                        includeTableNamePrefix, datasourceInfo);
071:            }
072:
073:            protected String getColName(ModelField modelField, String fieldName) {
074:                String colName = null;
075:                if (modelField != null) {
076:                    colName = modelField.getColName();
077:                } else {
078:                    colName = fieldName;
079:                }
080:                return colName;
081:            }
082:
083:            protected String getColName(Map tableAliases,
084:                    ModelEntity modelEntity, ModelField modelField,
085:                    String fieldName, boolean includeTableNamePrefix,
086:                    DatasourceInfo datasourceInfo) {
087:                if (modelEntity == null || modelField == null)
088:                    return fieldName;
089:
090:                // if this is a view entity and we are configured to alias the views, use the alias here instead of the composite (ie table.column) field name 
091:                if (datasourceInfo != null && datasourceInfo.aliasViews
092:                        && modelEntity instanceof  ModelViewEntity) {
093:                    ModelViewEntity modelViewEntity = (ModelViewEntity) modelEntity;
094:                    ModelAlias modelAlias = modelViewEntity.getAlias(fieldName);
095:                    if (modelAlias != null) {
096:                        return modelAlias.getColAlias();
097:                    }
098:                }
099:
100:                String colName = getColName(modelField, fieldName);
101:                if (includeTableNamePrefix && datasourceInfo != null) {
102:                    String tableName = modelEntity.getTableName(datasourceInfo);
103:                    if (tableAliases.containsKey(tableName)) {
104:                        tableName = (String) tableAliases.get(tableName);
105:                    }
106:                    colName = tableName + "." + colName;
107:                }
108:                return colName;
109:            }
110:
111:            protected void addValue(StringBuffer buffer, ModelField field,
112:                    Object value, List params) {
113:                SqlJdbcUtil.addValue(buffer, params == null ? null : field,
114:                        value, params);
115:            }
116:
117:            public boolean equals(Object obj) {
118:                throw new UnsupportedOperationException("equals:"
119:                        + getClass().getName());
120:            }
121:
122:            public int hashCode() {
123:                throw new UnsupportedOperationException("hashCode: "
124:                        + getClass().getName());
125:            }
126:
127:            protected static boolean equals(Object o1, Object o2) {
128:                return o1 == null ? o2 == null : o1.equals(o2);
129:            }
130:
131:            protected static int hashCode(Object o) {
132:                return o != null ? o.hashCode() : 0;
133:            }
134:
135:            public static Boolean castBoolean(boolean result) {
136:                return result ? Boolean.TRUE : Boolean.FALSE;
137:            }
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.