1 25 package org.ofbiz.entity.condition; 26 27 import java.util.Iterator ; 28 import java.util.List ; 29 import java.util.Map ; 30 31 import org.ofbiz.base.util.Debug; 32 import org.ofbiz.entity.EntityCryptoException; 33 import org.ofbiz.entity.GenericDelegator; 34 import org.ofbiz.entity.GenericModelException; 35 import org.ofbiz.entity.model.ModelEntity; 36 import org.ofbiz.entity.model.ModelField; 37 38 45 public abstract class EntityConditionListBase extends EntityCondition { 46 public static final String module = EntityConditionListBase.class.getName(); 47 48 protected List conditionList; 49 protected EntityJoinOperator operator; 50 51 protected EntityConditionListBase() {} 52 53 public EntityConditionListBase(List conditionList, EntityJoinOperator operator) { 54 this.conditionList = conditionList; 55 this.operator = operator; 56 } 57 58 public EntityOperator getOperator() { 59 return this.operator; 60 } 61 62 public EntityCondition getCondition(int index) { 63 return (EntityCondition) this.conditionList.get(index); 64 } 65 66 protected int getConditionListSize() { 67 return this.conditionList.size(); 68 } 69 70 protected Iterator getConditionIterator() { 71 return this.conditionList.iterator(); 72 } 73 74 public void visit(EntityConditionVisitor visitor) { 75 visitor.acceptEntityJoinOperator(operator, conditionList); 76 } 77 78 public String makeWhereString(ModelEntity modelEntity, List entityConditionParams) { 79 StringBuffer sql = new StringBuffer (); 81 operator.addSqlValue(sql, modelEntity, entityConditionParams, conditionList); 82 return sql.toString(); 83 } 84 85 public void checkCondition(ModelEntity modelEntity) throws GenericModelException { 86 operator.validateSql(modelEntity, conditionList); 88 } 89 90 public boolean mapMatches(GenericDelegator delegator, Map map) { 91 return operator.mapMatches(delegator, map, conditionList); 92 } 93 94 public EntityCondition freeze() { 95 return operator.freeze(conditionList); 96 } 97 98 public void encryptConditionFields(ModelEntity modelEntity, GenericDelegator delegator) { 99 Iterator conditionIter = this.conditionList.iterator(); 100 while (conditionIter.hasNext()) { 101 EntityCondition cond = (EntityCondition) conditionIter.next(); 102 cond.encryptConditionFields(modelEntity, delegator); 103 } 104 } 105 106 public boolean equals(Object obj) { 107 if (!(obj instanceof EntityConditionListBase)) return false; 108 EntityConditionListBase other = (EntityConditionListBase) obj; 109 110 boolean isEqual = conditionList.equals(other.conditionList) && operator.equals(other.operator); 111 return isEqual; 117 } 118 119 public int hashCode() { 120 return conditionList.hashCode() + operator.hashCode(); 121 } 122 } 123 | Popular Tags |