Author: mbrohl
Date: Sat Oct 28 14:10:07 2017 New Revision: 1813633 URL: http://svn.apache.org/viewvc?rev=1813633&view=rev Log: Improved: Fixing defects reported by FindBugs, package org.apache.ofbiz.entity.condition. (OFBIZ-9713) Thanks Dennis Balkir for reporting and providing the patch. Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBuilder.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionFunction.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityDateFilterCondition.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldMap.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldValue.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFunction.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityJoinOperator.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityOperator.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityWhereString.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java?rev=1813633&r1=1813632&r2=1813633&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityClause.java Sat Oct 28 14:10:07 2017 @@ -139,9 +139,9 @@ public class EntityClause { outputBuffer.append("[secondField,").append(secondField == null ? "null" : secondField).append("]"); outputBuffer.append("[firstModelEntity,").append(firstModelEntity == null ? "null" : (firstModelEntity.getEntityName() == null ? "null" : firstModelEntity.getEntityName())).append("]"); outputBuffer.append("[secondModelEntity,").append(secondModelEntity == null ? "null" : (secondModelEntity.getEntityName() == null ? "null" : secondModelEntity.getEntityName())).append("]"); - outputBuffer.append("[interFieldOperation,").append(interFieldOperation == null ? "null" : (interFieldOperation.getCode() == null ? "null" : interFieldOperation.getCode())).append("]"); + outputBuffer.append("[interFieldOperation,").append(interFieldOperation == null ? "null" : (interFieldOperation.getCode())).append("]"); outputBuffer.append("[intraFieldOperation,").append(intraFieldOperation == null ? "null" : (intraFieldOperation.getCode() == null ? "null" : intraFieldOperation.getCode())).append("]"); - outputBuffer.append("[value,").append(getValue().toString() == null ? "null" : getValue().toString()).append("]"); + outputBuffer.append("[value,").append(getValue().toString()).append("]"); return outputBuffer.toString(); } Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBuilder.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBuilder.java?rev=1813633&r1=1813632&r2=1813633&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBuilder.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionBuilder.java Sat Oct 28 14:10:07 2017 @@ -22,6 +22,7 @@ package org.apache.ofbiz.entity.conditio import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.Map; import org.apache.ofbiz.base.util.Debug; @@ -87,9 +88,9 @@ public class EntityConditionBuilder exte @Override protected Object createNode(Object methodName) { - String operatorName = ((String)methodName).toLowerCase(); + String operatorName = ((String)methodName).toLowerCase(Locale.getDefault()); EntityJoinOperator operator = EntityOperator.lookupJoin(operatorName); - List<EntityCondition> condList = new LinkedList<EntityCondition>(); + List<EntityCondition> condList = new LinkedList<>(); return new ConditionHolder(EntityCondition.makeCondition(condList, operator)); } @@ -103,17 +104,16 @@ public class EntityConditionBuilder exte @Override protected Object createNode(Object methodName, Map mapArg) { Map<String, Object> fieldValueMap = UtilGenerics.checkMap(mapArg); - String operatorName = ((String)methodName).toLowerCase(); + String operatorName = ((String)methodName).toLowerCase(Locale.getDefault()); EntityComparisonOperator<String, Object> operator = EntityOperator.lookupComparison(operatorName); - List<EntityCondition> conditionList = new LinkedList<EntityCondition>(); + List<EntityCondition> conditionList = new LinkedList<>(); for (Map.Entry<String, Object> entry : fieldValueMap.entrySet()) { conditionList.add(EntityCondition.makeCondition(entry.getKey(), operator, entry.getValue())); } if (conditionList.size() == 1) { return new ConditionHolder(conditionList.get(0)); - } else { - return new ConditionHolder(EntityCondition.makeCondition(conditionList)); } + return new ConditionHolder(EntityCondition.makeCondition(conditionList)); } @Override @@ -126,7 +126,7 @@ public class EntityConditionBuilder exte ConditionHolder holder = (ConditionHolder) parent; EntityConditionList<EntityCondition> parentConList = UtilGenerics.cast(holder.condition); Iterator<EntityCondition> iterator = parentConList.getConditionIterator(); - List<EntityCondition> tempList = new LinkedList<EntityCondition>(); + List<EntityCondition> tempList = new LinkedList<>(); while (iterator.hasNext()) { tempList.add(iterator.next()); } Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionFunction.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionFunction.java?rev=1813633&r1=1813632&r2=1813633&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionFunction.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityConditionFunction.java Sat Oct 28 14:10:07 2017 @@ -71,8 +71,7 @@ public abstract class EntityConditionFun public String getCode() { if (codeString == null) return "null"; - else - return codeString; + return codeString; } public int getId() { @@ -88,7 +87,7 @@ public abstract class EntityConditionFun public boolean equals(Object obj) { if (!(obj instanceof EntityConditionFunction)) return false; EntityConditionFunction otherFunc = (EntityConditionFunction) obj; - return this.idInt == otherFunc.idInt && (this.condition != null ? condition.equals(otherFunc.condition) : otherFunc.condition != null); + return this.idInt.equals(otherFunc.idInt) && (this.condition != null ? condition.equals(otherFunc.condition) : otherFunc.condition != null); } @Override Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityDateFilterCondition.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityDateFilterCondition.java?rev=1813633&r1=1813632&r2=1813633&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityDateFilterCondition.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityDateFilterCondition.java Sat Oct 28 14:10:07 2017 @@ -36,8 +36,8 @@ import org.apache.ofbiz.entity.model.Mod @SuppressWarnings("serial") public final class EntityDateFilterCondition extends EntityCondition { - protected final String fromDateName; - protected final String thruDateName; + private final String fromDateName; + private final String thruDateName; public EntityDateFilterCondition(String fromDateName, String thruDateName) { this.fromDateName = fromDateName; @@ -131,7 +131,7 @@ public final class EntityDateFilterCondi * @return EntityCondition representing the date range filter */ public static EntityCondition makeRangeCondition(Timestamp rangeStart, Timestamp rangeEnd, String fromDateName, String thruDateName) { - List<EntityCondition> criteria = new LinkedList<EntityCondition>(); + List<EntityCondition> criteria = new LinkedList<>(); // fromDate is equal to or after rangeStart but before rangeEnd criteria.add( EntityCondition.makeCondition( Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java?rev=1813633&r1=1813632&r2=1813633&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityExpr.java Sat Oct 28 14:10:07 2017 @@ -20,6 +20,7 @@ package org.apache.ofbiz.entity.conditio import java.util.Collection; import java.util.List; +import java.util.Locale; import java.util.Map; import org.apache.ofbiz.base.util.Debug; @@ -140,7 +141,7 @@ public final class EntityExpr extends En protected void addValue(StringBuilder buffer, ModelField field, Object value, List<EntityConditionParam> params) { if (rhs instanceof EntityFunction.UPPER) { if (value instanceof String) { - value = ((String) value).toUpperCase(); + value = ((String) value).toUpperCase(Locale.getDefault()); } } super.addValue(buffer, field, value, params); @@ -215,6 +216,9 @@ public final class EntityExpr extends En } catch (GenericEntityException e) { Debug.logWarning(e, module); } + if (valueType == null) { + throw new IllegalArgumentException("Type " + curField.getType() + " not found for entity [" + modelEntity.getEntityName() + "]; probably because there is no datasource (helper) setup for the entity group that this entity is in: [" + delegator.getEntityGroupName(modelEntity.getEntityName()) + "]"); + } // make sure the type of keyFieldName of EntityConditionSubSelect matches the field Java type try { if (!ObjectType.instanceOf(ObjectType.loadClass(valueType.getJavaType()), type.getJavaType())) { Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldMap.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldMap.java?rev=1813633&r1=1813632&r2=1813633&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldMap.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldMap.java Sat Oct 28 14:10:07 2017 @@ -34,13 +34,13 @@ import org.apache.ofbiz.entity.util.Enti @SuppressWarnings("serial") public final class EntityFieldMap extends EntityConditionListBase<EntityExpr> { - protected final Map<String, ? extends Object> fieldMap; + private final Map<String, ? extends Object> fieldMap; public static <V> List<EntityExpr> makeConditionList(Map<String, V> fieldMap, EntityComparisonOperator<?,V> op) { if (fieldMap == null) { return Collections.emptyList(); } - List<EntityExpr> list = new ArrayList<EntityExpr>(fieldMap.size()); + List<EntityExpr> list = new ArrayList<>(fieldMap.size()); for (Map.Entry<String, ? extends Object> entry: fieldMap.entrySet()) { list.add(EntityCondition.makeCondition(entry.getKey(), op, entry.getValue())); } Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldValue.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldValue.java?rev=1813633&r1=1813632&r2=1813633&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldValue.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFieldValue.java Sat Oct 28 14:10:07 2017 @@ -64,7 +64,7 @@ public class EntityFieldValue extends En this.fieldName = fieldName; this.entityAlias = entityAlias; if (UtilValidate.isNotEmpty(entityAliasStack)) { - this.entityAliasStack = new LinkedList<String>(); + this.entityAliasStack = new LinkedList<>(); this.entityAliasStack.addAll(entityAliasStack); } this.modelViewEntity = modelViewEntity; @@ -115,9 +115,8 @@ public class EntityFieldValue extends En if (this.entityAlias != null) { ModelEntity memberModelEntity = modelViewEntity.getMemberModelEntity(entityAlias); return getField(memberModelEntity, fieldName); - } else { - return getField(modelViewEntity, fieldName); } + return getField(modelViewEntity, fieldName); } return getField(modelEntity, fieldName); } @@ -181,9 +180,8 @@ public class EntityFieldValue extends En } if (map instanceof GenericEntity.NULL) { return null; - } else { - return map.get(fieldName); } + return map.get(fieldName); } @Override Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFunction.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFunction.java?rev=1813633&r1=1813632&r2=1813633&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFunction.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityFunction.java Sat Oct 28 14:10:07 2017 @@ -20,6 +20,7 @@ package org.apache.ofbiz.entity.condition; import java.util.List; +import java.util.Locale; import java.util.Map; import org.apache.ofbiz.base.util.UtilGenerics; @@ -64,7 +65,7 @@ public abstract class EntityFunction<T e * */ public static class LENGTH extends EntityFunctionSingle<Integer> { - public static Fetcher<Integer> FETCHER = new Fetcher<Integer>() { + public static final Fetcher<Integer> FETCHER = new Fetcher<Integer>() { public Integer getValue(Object value) { return value.toString().length(); } }; @@ -78,7 +79,7 @@ public abstract class EntityFunction<T e * */ public static class TRIM extends EntityFunctionSingle<String> { - public static Fetcher<String> FETCHER = new Fetcher<String>() { + public static final Fetcher<String> FETCHER = new Fetcher<String>() { public String getValue(Object value) { return value.toString().trim(); } }; @@ -92,8 +93,8 @@ public abstract class EntityFunction<T e * */ public static class UPPER extends EntityFunctionSingle<String> { - public static Fetcher<String> FETCHER = new Fetcher<String>() { - public String getValue(Object value) { return value.toString().toUpperCase(); } + public static final Fetcher<String> FETCHER = new Fetcher<String>() { + public String getValue(Object value) { return value.toString().toUpperCase(Locale.getDefault()); } }; private UPPER(Object value) { @@ -106,8 +107,8 @@ public abstract class EntityFunction<T e * */ public static class LOWER extends EntityFunctionSingle<String> { - public static Fetcher<String> FETCHER = new Fetcher<String>() { - public String getValue(Object value) { return value.toString().toLowerCase(); } + public static final Fetcher<String> FETCHER = new Fetcher<String>() { + public String getValue(Object value) { return value.toString().toLowerCase(Locale.getDefault()); } }; private LOWER(Object value) { @@ -156,9 +157,8 @@ public abstract class EntityFunction<T e public EntityConditionValue freeze() { if (nested != null) { return new EntityFunctionNested<T>(fetcher, function, nested.freeze()) {}; - } else { - return new EntityFunctionSingle<T>(fetcher, function, value) {}; } + return new EntityFunctionSingle<T>(fetcher, function, value) {}; } public String getCode() { Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityJoinOperator.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityJoinOperator.java?rev=1813633&r1=1813632&r2=1813633&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityJoinOperator.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityJoinOperator.java Sat Oct 28 14:10:07 2017 @@ -48,7 +48,7 @@ public class EntityJoinOperator extends @Override public void addSqlValue(StringBuilder sql, ModelEntity modelEntity, List<EntityConditionParam> entityConditionParams, boolean compat, EntityCondition lhs, EntityCondition rhs, Datasource datasourceInfo) { - List<EntityCondition> conditions = new LinkedList<EntityCondition>(); + List<EntityCondition> conditions = new LinkedList<>(); conditions.add(lhs); conditions.add(rhs); addSqlValue(sql, modelEntity, entityConditionParams, conditions, datasourceInfo); @@ -89,7 +89,7 @@ public class EntityJoinOperator extends } public EntityCondition freeze(List<? extends EntityCondition> conditionList) { - List<EntityCondition> newList = new ArrayList<EntityCondition>(conditionList.size()); + List<EntityCondition> newList = new ArrayList<>(conditionList.size()); for (EntityCondition condition: conditionList) { newList.add(condition.freeze()); } Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityOperator.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityOperator.java?rev=1813633&r1=1813632&r2=1813633&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityOperator.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityOperator.java Sat Oct 28 14:10:07 2017 @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; @@ -60,8 +61,8 @@ public abstract class EntityOperator<L, private static HashMap<String, EntityOperator<?,?,?>> registry = new HashMap<String, EntityOperator<?,?,?>>(); private static <L,R,T> void registerCase(String name, EntityOperator<L,R,T> operator) { - registry.put(name.toLowerCase(), operator); - registry.put(name.toUpperCase(), operator); + registry.put(name.toLowerCase(Locale.getDefault()), operator); + registry.put(name.toUpperCase(Locale.getDefault()), operator); } public static <L,R,T> void register(String name, EntityOperator<L,R,T> operator) { @@ -209,9 +210,8 @@ public abstract class EntityOperator<L, public String getCode() { if (codeString == null) { return "null"; - } else { - return codeString; } + return codeString; } public int getId() { Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityWhereString.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityWhereString.java?rev=1813633&r1=1813632&r2=1813633&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityWhereString.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/EntityWhereString.java Sat Oct 28 14:10:07 2017 @@ -42,7 +42,7 @@ import org.apache.ofbiz.entity.model.Mod @SuppressWarnings("serial") public final class EntityWhereString extends EntityCondition { - protected final String sqlString; + private final String sqlString; public EntityWhereString(String sqlString) { this.sqlString = sqlString; Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java?rev=1813633&r1=1813632&r2=1813633&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java Sat Oct 28 14:10:07 2017 @@ -20,6 +20,7 @@ package org.apache.ofbiz.entity.condition; import java.util.Comparator; +import java.util.Locale; import org.apache.ofbiz.base.util.UtilGenerics; import org.apache.ofbiz.entity.GenericEntity; @@ -34,6 +35,7 @@ public class OrderByItem implements Comp public static final String NULLS_FIRST = "NULLS FIRST"; public static final String NULLS_LAST = "NULLS LAST"; + public static final String module = OrderByItem.class.getName(); protected boolean descending; protected Boolean nullsFirst; @@ -78,12 +80,12 @@ public class OrderByItem implements Comp // handle nulls first/last Boolean nullsFirst = null; - if (text.toUpperCase().endsWith(NULLS_FIRST)) { + if (text.toUpperCase(Locale.getDefault()).endsWith(NULLS_FIRST)) { nullsFirst = true; text = text.substring(0, text.length() - NULLS_FIRST.length()).trim(); } - if (text.toUpperCase().endsWith(NULLS_LAST)) { + if (text.toUpperCase(Locale.getDefault()).endsWith(NULLS_LAST)) { nullsFirst = false; text = text.substring(0, text.length() - NULLS_LAST.length()).trim(); } @@ -114,7 +116,7 @@ public class OrderByItem implements Comp } if (text.endsWith(")")) { - String upperText = text.toUpperCase(); + String upperText = text.toUpperCase(Locale.getDefault()); endIndex--; if (upperText.startsWith("UPPER(")) { caseSensitivity = UPPER; @@ -132,7 +134,6 @@ public class OrderByItem implements Comp if (startIndex != 0 || endIndex != text.length()) { text = text.substring(startIndex, endIndex); startIndex = 0; - endIndex = text.length(); } EntityConditionValue value = EntityFieldValue.makeFieldValue(text); switch (caseSensitivity) { @@ -142,6 +143,8 @@ public class OrderByItem implements Comp case LOWER: value = EntityFunction.LOWER(value); break; + default: + break; } return new OrderByItem(value, descending, nullsFirst); } @@ -192,6 +195,16 @@ public class OrderByItem implements Comp } @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (descending ? 1231 : 1237); + result = prime * result + ((nullsFirst == null) ? 0 : nullsFirst.hashCode()); + result = prime * result + ((value == null) ? 0 : value.hashCode()); + return result; + } + + @Override public boolean equals(java.lang.Object obj) { if (!(obj instanceof OrderByItem)) return false; OrderByItem that = (OrderByItem) obj; Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java?rev=1813633&r1=1813632&r2=1813633&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByList.java Sat Oct 28 14:10:07 2017 @@ -30,7 +30,7 @@ import org.apache.ofbiz.entity.config.mo import org.apache.ofbiz.entity.model.ModelEntity; public class OrderByList implements Comparator<GenericEntity> { - protected List<OrderByItem> orderByList = new ArrayList<OrderByItem>(); + protected List<OrderByItem> orderByList = new ArrayList<>(); public OrderByList() { } @@ -103,6 +103,14 @@ public class OrderByList implements Comp return result; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((orderByList == null) ? 0 : orderByList.hashCode()); + return result; + } + @Override public boolean equals(java.lang.Object obj) { if (!(obj instanceof OrderByList)) return false; |
Free forum by Nabble | Edit this page |