You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2013/02/18 01:01:52 UTC
svn commit: r1447107 -
/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaSetField.java
Author: adrianc
Date: Mon Feb 18 00:01:52 2013
New Revision: 1447107
URL: http://svn.apache.org/r1447107
Log:
EntityEcaSetField.java bug fixes: test for null on field that was never null, not thread-safe.
Modified:
ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaSetField.java
Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaSetField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaSetField.java?rev=1447107&r1=1447106&r2=1447107&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaSetField.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaSetField.java Mon Feb 18 00:01:52 2013
@@ -30,14 +30,14 @@ import java.util.Map;
/**
* ServiceEcaSetField
*/
-public class EntityEcaSetField {
+public final class EntityEcaSetField {
public static final String module = EntityEcaSetField.class.getName();
- protected String fieldName = null;
- protected String envName = null;
- protected String value = null;
- protected String format = null;
+ private final String fieldName;
+ private final String envName;
+ private final String value;
+ private final String format;
public EntityEcaSetField(Element set) {
this.fieldName = set.getAttribute("field-name");
@@ -47,29 +47,17 @@ public class EntityEcaSetField {
}
public void eval(Map<String, Object> context) {
- if (fieldName != null) {
- // try to expand the envName
- if (UtilValidate.isEmpty(value)) {
- if (UtilValidate.isNotEmpty(envName) && envName.startsWith("${")) {
- FlexibleStringExpander exp = FlexibleStringExpander.getInstance(envName);
- String s = exp.expandString(context);
- if (UtilValidate.isNotEmpty(s)) {
- value = s;
- }
- Debug.logInfo("Expanded String: " + s, module);
- }
- }
-
- // process the context changes
- if (UtilValidate.isNotEmpty(value)) {
- context.put(fieldName, this.format(value, context));
- } else if (UtilValidate.isNotEmpty(envName) && context.get(envName) != null) {
+ if (!fieldName.isEmpty()) {
+ String valueExpanded = FlexibleStringExpander.expandString(value, context);
+ if (!valueExpanded.isEmpty()) {
+ context.put(fieldName, this.format(valueExpanded, context));
+ } else if (!envName.isEmpty() && context.get(envName) != null) {
context.put(fieldName, this.format((String) context.get(envName), context));
}
}
}
- protected Object format(String s, Map<String, ? extends Object> c) {
+ private Object format(String s, Map<String, ? extends Object> c) {
if (UtilValidate.isEmpty(s) || UtilValidate.isEmpty(format)) {
return s;
}