KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > entity > condition > EntityConditionValue


1 /*
2  * $Id: EntityConditionValue.java 5831 2005-09-26 06:52:24Z jonesde $
3  *
4  * Copyright (c) 2002-2005 The Open For Business Project - www.ofbiz.org
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */

24 package org.ofbiz.entity.condition;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.List JavaDoc;
28 import java.util.Map JavaDoc;
29
30 import org.ofbiz.entity.GenericDelegator;
31 import org.ofbiz.entity.GenericEntity;
32 import org.ofbiz.entity.GenericModelException;
33 import org.ofbiz.entity.config.DatasourceInfo;
34 import org.ofbiz.entity.model.ModelEntity;
35 import org.ofbiz.entity.model.ModelField;
36
37 /**
38  * Encapsulates operations between entities and entity fields. This is a immutable class.
39  *
40  *@author <a HREF='mailto:chris_maurer@altavista.com'>Chris Maurer</a>
41  *@author <a HREF="mailto:jonesde@ofbiz.org">David E. Jones</a>
42  *@author <a HREF="mailto:jaz@ofbiz.org">Andy Zeneski</a>
43  *@since 1.0
44  *@version $Rev: 5831 $
45  */

46 public abstract class EntityConditionValue extends EntityConditionBase {
47
48     public abstract ModelField getModelField(ModelEntity modelEntity);
49
50     public void addSqlValue(StringBuffer JavaDoc sql, ModelEntity modelEntity, List JavaDoc entityConditionParams, boolean includeTableNamePrefix,
51             DatasourceInfo datasourceinfo) {
52         addSqlValue(sql, emptyMap, modelEntity, entityConditionParams, includeTableNamePrefix, datasourceinfo);
53     }
54
55     public abstract void addSqlValue(StringBuffer JavaDoc sql, Map JavaDoc tableAliases, ModelEntity modelEntity, List JavaDoc entityConditionParams,
56             boolean includeTableNamePrefix, DatasourceInfo datasourceinfo);
57
58     public abstract void validateSql(ModelEntity modelEntity) throws GenericModelException;
59
60     public Object JavaDoc getValue(GenericEntity entity) {
61         if (entity == null) {
62             return null;
63         }
64         return getValue(entity.getDelegator(), entity);
65     }
66
67     public abstract Object JavaDoc getValue(GenericDelegator delegator, Map JavaDoc map);
68
69     public abstract EntityConditionValue freeze();
70
71     public abstract void visit(EntityConditionVisitor visitor);
72
73     public void accept(EntityConditionVisitor visitor) {
74         throw new IllegalArgumentException JavaDoc("accept not implemented");
75     }
76
77     public void toString(StringBuffer JavaDoc sb) {
78         addSqlValue(sb, null, new ArrayList JavaDoc(), false, null);
79     }
80     
81     public String JavaDoc toString() {
82         StringBuffer JavaDoc sql = new StringBuffer JavaDoc();
83         toString(sql);
84         return sql.toString();
85     }
86 }
87
Popular Tags