svn commit: r687422 [1/2] - in /ofbiz/trunk: applications/accounting/src/org/ofbiz/accounting/finaccount/ applications/content/src/org/ofbiz/content/content/ framework/base/src/org/ofbiz/base/util/string/ framework/entity/src/org/ofbiz/entity/finder/ f...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r687422 [1/2] - in /ofbiz/trunk: applications/accounting/src/org/ofbiz/accounting/finaccount/ applications/content/src/org/ofbiz/content/content/ framework/base/src/org/ofbiz/base/util/string/ framework/entity/src/org/ofbiz/entity/finder/ f...

adrianc
Author: adrianc
Date: Wed Aug 20 11:50:04 2008
New Revision: 687422

URL: http://svn.apache.org/viewvc?rev=687422&view=rev
Log:
FlexibleStringExpander refactor.

1. Improved parsing logic - the entire expression is pre-parsed now.
2. Factory method stores parsed expressions in the cache.
3. Single null/empty expression instance - saves on memory.
4. Class names and variable names shortened to reduce object size.
5. Small performance improvements.

The expression cache is set up with no limit. We'll have to see if that needs to be changed. Larger installations might need to limit the expression cache size.

Modified:
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountProductServices.java
    ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/Finder.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/PrimaryKeyFinder.java
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaSetField.java
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java
    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/Assert.java
    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/RegexpCondition.java
    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java
    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java
    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java
    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java
    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfHasPermission.java
    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfRegexp.java
    ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountProductServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountProductServices.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountProductServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/finaccount/FinAccountProductServices.java Wed Aug 20 11:50:04 2008
@@ -172,7 +172,7 @@
         expContext.put("partyGroup", partyGroup);
 
         // expand the name field to dynamicly add information
-        FlexibleStringExpander exp = new FlexibleStringExpander(finAccountName);
+        FlexibleStringExpander exp = FlexibleStringExpander.getInstance(finAccountName);
         finAccountName = exp.expandString(expContext);
 
         // price/amount/quantity to create initial deposit amount

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java Wed Aug 20 11:50:04 2008
@@ -665,7 +665,7 @@
   
         boolean isWhen = true; //opposite default from checkReturnWhen
         if (whenStr != null && whenStr.length() > 0) {
-            FlexibleStringExpander fse = new FlexibleStringExpander(whenStr);
+            FlexibleStringExpander fse = FlexibleStringExpander.getInstance(whenStr);
             String newWhen = fse.expandString(context);
             //if (Debug.infoOn()) Debug.logInfo("newWhen:" + newWhen,null);
             //if (Debug.infoOn()) Debug.logInfo("context:" + context,null);
@@ -685,7 +685,7 @@
     public static boolean checkReturnWhen(Map context, String whenStr) {
         boolean isWhen = false; //opposite default from checkWhen
         if (whenStr != null && whenStr.length() > 0) {
-            FlexibleStringExpander fse = new FlexibleStringExpander(whenStr);
+            FlexibleStringExpander fse = FlexibleStringExpander.getInstance(whenStr);
             String newWhen = fse.expandString(context);
             try {
                 Boolean isWhenObj = (Boolean) BshUtil.eval(newWhen, context);

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/FlexibleStringExpander.java Wed Aug 20 11:50:04 2008
@@ -28,50 +28,53 @@
 import org.ofbiz.base.util.BshUtil;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.ObjectType;
-import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.cache.UtilCache;
 import org.ofbiz.base.util.collections.FlexibleMapAccessor;
+import org.ofbiz.base.util.UtilDateTime;
 import org.ofbiz.base.util.UtilFormatOut;
 import org.ofbiz.base.util.UtilMisc;
 
 import bsh.EvalError;
 
-/**
- * Expands string values with in a Map context supporting the ${} syntax for
+/** Expands string values within a Map context supporting the ${} syntax for
  * variable placeholders and the "." (dot) and "[]" (square-brace) syntax
  * elements for accessing Map entries and List elements in the context.
  * It Also supports the execution of bsh files by using the 'bsh:' prefix.
  * Further it is possible to control the output by specifying the suffix
  * '?currency(XXX)' to format the output according the current locale
  * and specified (XXX) currency
- *
  */
 @SuppressWarnings("serial")
 public class FlexibleStringExpander implements Serializable {
     
     public static final String module = FlexibleStringExpander.class.getName();
-    
-    protected String original;
-    protected List<StringElement> stringElements = new LinkedList<StringElement>();
-    protected static boolean localizeCurrency = false;
-    protected static String currencyCode = null;
-    
+    protected static UtilCache<String, FlexibleStringExpander> exprCache = new UtilCache<String, FlexibleStringExpander>("flexibleStringExpander.ExpressionCache");
+    protected static FlexibleStringExpander nullExpr = new FlexibleStringExpander(null);
+    protected String orig;
+    protected List<StrElem> strElems = null;
+    protected int hint = 20;
+
+    /**
+     * @deprecated Use getInstance(String original) instead.
+     * @param original
+     */
     public FlexibleStringExpander(String original) {
-        this.original = original;
-        
-        ParseElementHandler handler = new PreParseHandler(stringElements);
-        parseString(original, handler);
+        // TODO: Change this to protected, remove @deprecated javadoc comment
+        this.orig = original;
+        if (original != null && original.contains("${")) {
+            this.strElems = getStrElems(original);
+            if (original.length() > this.hint) {
+                this.hint = original.length();
+            }
+        }
     }
     
     public boolean isEmpty() {
-        if (this.original == null || this.original.length() == 0) {
-            return true;
-        } else {
-            return false;
-        }
+        return this.orig == null || this.orig.length() == 0;
     }
     
     public String getOriginal() {
-        return this.original;
+        return this.orig;
     }
 
     /**
@@ -84,7 +87,7 @@
      * @return The original String expanded by replacing varaible place holders.
      */    
     public String expandString(Map<String, ? extends Object> context) {
-        return this.expandString(context, context != null ? (Locale) context.get("locale") : null);
+        return this.expandString(context, null, null);
     }
     
     /**
@@ -98,14 +101,75 @@
      * @return The original String expanded by replacing varaible place holders.
      */    
     public String expandString(Map<String, ? extends Object> context, Locale locale) {
-        StringBuilder expanded = new StringBuilder();
-        
-        for (StringElement element: stringElements) {
-            element.appendElement(expanded, context, locale);
+        return this.expandString(context, null, locale);
+    }
+    
+    /**
+     * This expands the pre-parsed String given the context passed in. Note that
+     * pre-parsing can only parse the top-level place-holders and if there are
+     * nested expansions they will be done on the fly instead of pre-parsed because
+     * they are dependent on the context which isn't known until expansion time.
+     *
+     * @param context A context Map containing the variable values
+     * @param timeZone the current set time zone
+     * @param locale the current set locale
+     * @return The original String expanded by replacing varaible place holders.
+     */    
+    public String expandString(Map<String, ? extends Object> context, TimeZone timeZone, Locale locale) {
+        if (this.strElems == null) {
+            return this.orig == null ? "" : this.orig;
         }
-        
-        //call back into this method with new String to take care of any/all nested expands
-        return expandString(expanded.toString(), context, locale);
+        if (locale == null) {
+            locale = (Locale) context.get("locale");
+            if (locale == null && context.containsKey("autoUserLogin")) {
+                locale = UtilMisc.ensureLocale(((Map) context.get("autoUserLogin")).get("lastLocale"));
+            }
+            if (locale == null) {
+                locale = Locale.getDefault();
+            }
+        }
+        if (timeZone == null) {
+            timeZone = (TimeZone) context.get("timeZone");
+            if (timeZone == null && context.containsKey("autoUserLogin")) {
+                timeZone = UtilDateTime.toTimeZone((String)((Map) context.get("autoUserLogin")).get("lastTimeZone"));
+            }
+            if (timeZone == null) {
+                timeZone = TimeZone.getDefault();
+            }
+        }
+        StringBuilder buffer = new StringBuilder(this.hint);
+        for (StrElem elem : this.strElems) {
+            elem.append(buffer, context, timeZone, locale);
+        }
+        if (buffer.length() > this.hint) {
+            this.hint = buffer.length();
+        }
+        return buffer.toString();
+    }
+    
+    /** Returns a FlexibleStringExpander instance.
+     * @param original The original String expression
+     * @return A FlexibleStringExpander instance
+     */
+    public static FlexibleStringExpander getInstance(String original) {
+        if (original == null || original.length() == 0) {
+            return nullExpr;
+        }
+        // Remove the next three lines to cache all expressions
+        if (!original.contains("${")) {
+            return new FlexibleStringExpander(original);
+        }
+        FlexibleStringExpander fse = exprCache.get(original);
+        if (fse == null) {
+            synchronized (exprCache) {
+                fse = exprCache.get(original);
+                if (fse == null) {
+                    fse = new FlexibleStringExpander(original);
+                    exprCache.put(original, fse);
+                }
+            }
+        }
+        return fse;
     }
     
     /**
@@ -165,57 +229,27 @@
         if (context == null) {
             return original;
         }
-        
-        // if null or less than 3 return original; 3 chars because that is the minimum necessary for a ${}
-        if (original == null || original.length() < 3) {
-            return original;
-        }
-        
-        // start by checking to see if expansion is necessary for better performance
-        // this is also necessary for the nested stuff since this will be the stopping point for nested expansions
-        int start = original.indexOf("${");
-        if (start == -1) {
+        if (original == null || !original.contains("${")) {
             return original;
-        } else {
-            if (original.indexOf("}", start) == -1) {
-                //no ending for the start, so we also have a stop condition
-                Debug.logWarning("Found a \"${\" without a closing \"}\" (curly-brace) in the String: " + original, module);
-                return original;  
-            }
-        }
-        
-        if (locale == null && context.containsKey("locale")) {
-            locale = (Locale) context.get("locale");
-        }
-        if (locale == null && context.containsKey("autoUserLogin")) {
-            locale = UtilMisc.ensureLocale(((Map) context.get("autoUserLogin")).get("lastLocale"));
-        }
-        
-        if (timeZone == null) {
-            timeZone = (TimeZone) context.get("timeZone");
-            if (timeZone == null) {
-                timeZone = TimeZone.getDefault();
-            }
         }
-
-        StringBuilder expanded = new StringBuilder();
-        // TODO: for performance to save object build up and tear down times we should use Javolution to make OnTheFlyHandler reusable and use a factory methods instead of constructor
-        ParseElementHandler handler = new OnTheFlyHandler(expanded, context, timeZone, locale);
-        parseString(original, handler);
-        
-        //call back into this method with new String to take care of any/all nested expands
-        return expandString(expanded.toString(), context, timeZone, locale);
+        FlexibleStringExpander fse = FlexibleStringExpander.getInstance(original);
+        return fse.expandString(context, timeZone, locale);
     }
     
-    public static void parseString(String original, ParseElementHandler handler) {
-        if (original == null || original.length() == 0) {
-            return;
+    /** Protected helper method.
+     * @param original
+     * @return
+     */
+    protected static List<StrElem> getStrElems(String original) {
+        int origLen = original.length();
+        if (original == null || origLen == 0) {
+            return null;
         }
-        
+        List<StrElem> strElems = new LinkedList<StrElem>();
         int start = original.indexOf("${");
         if (start == -1) {
-            handler.handleConstant(original, 0);
-            return;
+            strElems.add(new ConstElem(original));
+            return strElems;
         }
         int currentInd = 0;
         int end = -1;
@@ -225,204 +259,152 @@
                 Debug.logWarning("Found a ${ without a closing } (curly-brace) in the String: " + original, module);
                 break;
             }
-            
-            // check to see if there is a nested ${}, ie something like ${foo.${bar}} or ${foo[$bar}]}
-            // since we are only handling one at a time, and then recusively looking for nested ones, just look backward from the } for another ${ and if found and is not the same start spot, update the start spot
-            int possibleNestedStart = original.lastIndexOf("${", end);
-            if (start != possibleNestedStart) {
-                // found a nested one, could print something here, but just do the simple thing...
-                start = possibleNestedStart;
-            }
-            
-            // append everything from the current index to the start of the var
-            handler.handleConstant(original, currentInd, start);
-            
+            if (start > currentInd) {
+                // append everything from the current index to the start of the var
+                strElems.add(new ConstElem(original.substring(currentInd, start)));
+            }
             // check to see if this starts with a "bsh:", if so treat the rest of the string as a bsh scriptlet
-            if (original.indexOf("bsh:", start+2) == start+2) {
-                // get the bsh scriptlet and append it
-                handler.handleBsh(original, start+6, end);
+            if (original.indexOf("bsh:", start + 2) == start + 2) {
+                strElems.add(new BshElem(original.substring(start + 6, end)));
             } else {
-                // get the environment value and append it
-                handler.handleVariable(original, start+2, end);
+                int ptr = original.indexOf("${", start + 2);
+                while (ptr != -1 && end != -1 && ptr < end) {
+                    end = original.indexOf("}", end + 1);
+                    ptr = original.indexOf("${", ptr + 2);
+                }
+                if (end == -1) {
+                    end = origLen;
+                }
+                String expression = original.substring(start + 2, end);
+                // Evaluation sequence is important - do not change it
+                if (expression.contains("?currency(")) {
+                    strElems.add(new CurrElem(expression));
+                } else if (expression.contains("${")){
+                    strElems.add(new NestedVarElem(expression));
+                } else {
+                    strElems.add(new VarElem(expression));
+                }
             }
-            
             // reset the current index to after the var, and the start to the beginning of the next var
             currentInd = end + 1;
+            if (currentInd > origLen) {
+                currentInd = origLen;
+            }
             start = original.indexOf("${", currentInd);
         }
-        
         // append the rest of the original string, ie after the last variable
-        if (currentInd < original.length()) {
-            handler.handleConstant(original, currentInd);
+        if (currentInd < origLen) {
+            strElems.add(new ConstElem(original.substring(currentInd)));
         }
+        return strElems;
     }
 
-    public static interface StringElement extends Serializable {
-        public void appendElement(StringBuilder buffer, Map<String, ? extends Object> context, Locale locale);
+    protected static interface StrElem extends Serializable {
+        public void append(StringBuilder buffer, Map<String, ? extends Object> context, TimeZone timeZone, Locale locale);
     }
     
-    public static class ConstantElement implements StringElement {
-        protected String value;
-        
-        public ConstantElement(String value) {
-            this.value = value;
+    protected static class ConstElem implements StrElem {
+        protected String str;
+        protected ConstElem(String value) {
+            this.str = value.intern();
         }
-        
-        public void appendElement(StringBuilder buffer, Map<String, ? extends Object> context, Locale locale) {
-            buffer.append(this.value);
+        public void append(StringBuilder buffer, Map<String, ? extends Object> context, TimeZone timeZone, Locale locale) {
+            buffer.append(this.str);
         }
     }
     
-    public static class BshElement implements StringElement {
-        String scriptlet;
-        
-        public BshElement(String scriptlet) {
-            this.scriptlet = scriptlet;
+    protected static class BshElem implements StrElem {
+        String str;
+        protected BshElem(String scriptlet) {
+            this.str = scriptlet;
         }
-        
-        public void appendElement(StringBuilder buffer, Map<String, ? extends Object> context, Locale locale) {
+        public void append(StringBuilder buffer, Map<String, ? extends Object> context, TimeZone timeZone, Locale locale) {
             try {
-                Object scriptResult = BshUtil.eval(scriptlet, UtilMisc.makeMapWritable(context));
-                if (scriptResult != null) {
+                Object obj = BshUtil.eval(this.str, UtilMisc.makeMapWritable(context));
+                if (obj != null) {
                     try {
-                        buffer.append(ObjectType.simpleTypeConvert(scriptResult, "String", null, (TimeZone) context.get("timeZone"), locale, true));
+                        buffer.append(ObjectType.simpleTypeConvert(obj, "String", null, timeZone, locale, true));
                     } catch (Exception e) {
-                        buffer.append(scriptResult);
+                        buffer.append(obj);
                     }
                 } else {
-                    Debug.logWarning("BSH scriptlet evaluated to null [" + scriptlet + "], got no return so inserting nothing.", module);
+                    if (Debug.verboseOn()) {
+                        Debug.logVerbose("BSH scriptlet evaluated to null [" + this.str + "], got no return so inserting nothing.", module);
+                    }
                 }
             } catch (EvalError e) {
-                Debug.logWarning(e, "Error evaluating BSH scriptlet [" + scriptlet + "], inserting nothing; error was: " + e.toString(), module);
-            }
-        }
-    }
-    public static class VariableElement implements StringElement {
-        protected FlexibleMapAccessor<Object> fma;
-        
-        public VariableElement(String valueName) {
-            this.fma = new FlexibleMapAccessor<Object>(valueName);
-        }
-        
-        public void appendElement(StringBuilder buffer, Map<String, ? extends Object> context, Locale locale) {
-            Object retVal = fma.get(context, locale);
-            if (retVal != null) {
-                try {
-                    buffer.append((String) ObjectType.simpleTypeConvert(retVal, "String", null, (TimeZone) context.get("timeZone"), locale, true));
-                } catch (Exception e) {
-                    buffer.append(retVal);
-                }
-            } else {
-                // otherwise do nothing
+                Debug.logWarning(e, "Error evaluating BSH scriptlet [" + this.str + "], inserting nothing; error was: " + e, module);
             }
         }
     }
 
-    public static interface ParseElementHandler extends Serializable {
-        public void handleConstant(String original, int start);
-        public void handleConstant(String original, int start, int end);
-        public void handleVariable(String original, int start, int end);
-        public void handleBsh(String original, int start, int end);
-    }
-    
-    public static class PreParseHandler implements ParseElementHandler {
-        protected List<StringElement> stringElements;
-        
-        public PreParseHandler(List<StringElement> stringElements) {
-            this.stringElements = stringElements;
-        }
-        
-        public void handleConstant(String original, int start) {
-            stringElements.add(new ConstantElement(original.substring(start)));
-        }
-        
-        public void handleConstant(String original, int start, int end) {
-            stringElements.add(new ConstantElement(original.substring(start, end)));
-        }
-        
-        public void handleVariable(String original, int start, int end) {
-            stringElements.add(new VariableElement(original.substring(start, end)));
-        }
-
-        public void handleBsh(String original, int start, int end) {
-            stringElements.add(new BshElement(original.substring(start, end)));
+    protected static class CurrElem implements StrElem {
+        String str;
+        protected FlexibleStringExpander codeExpr = null;
+        protected CurrElem(String original) {
+            int currencyPos = original.indexOf("?currency(");
+            int closeBracket = original.indexOf(")", currencyPos+10);
+            this.codeExpr = FlexibleStringExpander.getInstance(original.substring(currencyPos+10, closeBracket));
+            this.str = original.substring(0, currencyPos);
+        }
+        public void append(StringBuilder buffer, Map<String, ? extends Object> context, TimeZone timeZone, Locale locale) {
+            FlexibleMapAccessor<Object> fma = new FlexibleMapAccessor<Object>(this.str);
+            Object obj = fma.get(context, locale);
+            if (obj != null) {
+                String currencyCode = this.codeExpr.expandString(context, timeZone, locale);
+                buffer.append(UtilFormatOut.formatCurrency(Double.valueOf(obj.toString()), currencyCode, locale));
+            }
         }
     }
-    
-    public static class OnTheFlyHandler implements ParseElementHandler {
-        protected StringBuilder targetBuffer;
-        protected Map<String, ? extends Object> context;
-        protected Locale locale;
-        protected TimeZone timeZone;
-        
-        public OnTheFlyHandler(StringBuilder targetBuffer, Map<String, ? extends Object> context, TimeZone timeZone, Locale locale) {
-            this.targetBuffer = targetBuffer;
-            this.context = context;
-            this.timeZone = timeZone;
-            this.locale = locale;
-        }
-        
-        public void handleConstant(String original, int start) {
-            targetBuffer.append(original.substring(start));
-        }
         
-        public void handleConstant(String original, int start, int end) {
-            targetBuffer.append(original.substring(start, end));
+    protected static class NestedVarElem implements StrElem {
+        protected List<StrElem> strElems = null;
+        protected int hint = 20;
+        protected NestedVarElem(String original) {
+            this.strElems = getStrElems(original);
+            if (original.length() > this.hint) {
+                this.hint = original.length();
+            }
         }
-        
-        public void handleVariable(String original, int start, int end) {
-            //get the environment value and append it
-            String envName = original.substring(start, end);
-
-            // see if ?currency(xxx) formatting is required
-            localizeCurrency = false;
-            int currencyPos = envName.indexOf("?currency(");
-            if (currencyPos != -1) {
-                int closeBracket = envName.indexOf(")", currencyPos+10);
-                currencyCode = envName.substring(currencyPos+10, closeBracket);
-                localizeCurrency = true;
-                envName = envName.substring(0, currencyPos);
+        public void append(StringBuilder buffer, Map<String, ? extends Object> context, TimeZone timeZone, Locale locale) {
+            if (strElems == null) {
+                return;
             }
-
-            FlexibleMapAccessor<Object> fma = new FlexibleMapAccessor<Object>(envName);
-            Object envVal = fma.get(context, locale);
-            if (envVal != null) {
-                if (localizeCurrency) {
-                    targetBuffer.append(UtilFormatOut.formatCurrency(Double.valueOf(envVal.toString()), currencyCode, locale));
-                } else {
-                    try {
-                        targetBuffer.append(ObjectType.simpleTypeConvert(envVal, "String", null, timeZone, locale, true));
-                    } catch (Exception e) {
-                        targetBuffer.append(envVal);
-                    }
-                }
-            } else if (envName.equals("ofbiz.home")) { // This is only used in case of Geronimo or WASCE using OFBiz multi-instances. It allows to retrieve ofbiz.home value set in JVM env
-                String ofbizHome = System.getProperty("ofbiz.home");
-                if (UtilValidate.isNotEmpty(ofbizHome)) {
-                    targetBuffer.append(ofbizHome);
+            StringBuilder expr = new StringBuilder(this.hint);
+            for (StrElem elem : this.strElems) {
+                elem.append(expr, context, timeZone, locale);
+            }
+            if (expr.length() > this.hint) {
+                this.hint = expr.length();
+            }
+            FlexibleMapAccessor<Object> fma = new FlexibleMapAccessor<Object>(expr.toString());
+            Object obj = fma.get(context, locale);
+            if (obj != null) {
+                try {
+                    buffer.append((String) ObjectType.simpleTypeConvert(obj, "String", null, timeZone, locale, true));
+                } catch (Exception e) {
+                    buffer.append(obj);
                 }
-            } else {
-                Debug.logWarning("Could not find value in environment for the name [" + envName + "], inserting nothing.", module);
             }
         }
+    }
 
-        public void handleBsh(String original, int start, int end) {
-            //run the scriptlet and append the result
-            String scriptlet = original.substring(start, end);
-            try {
-                Object scriptResult = BshUtil.eval(scriptlet, UtilMisc.makeMapWritable(context));
-                if (scriptResult != null) {
-                    try {
-                        targetBuffer.append(ObjectType.simpleTypeConvert(scriptResult, "String", null, timeZone, locale, true));
-                    } catch (Exception e) {
-                        targetBuffer.append(scriptResult);
-                    }
-                } else {
-                    Debug.logWarning("BSH scriptlet evaluated to null [" + scriptlet + "], got no return so inserting nothing.", module);
+    protected static class VarElem implements StrElem {
+        protected String str;
+        protected VarElem(String original) {
+            this.str = original;
+        }
+        public void append(StringBuilder buffer, Map<String, ? extends Object> context, TimeZone timeZone, Locale locale) {
+            FlexibleMapAccessor<Object> fma = new FlexibleMapAccessor<Object>(str);
+            Object obj = fma.get(context, locale);
+            if (obj != null) {
+                try {
+                    buffer.append((String) ObjectType.simpleTypeConvert(obj, "String", null, timeZone, locale, true));
+                } catch (Exception e) {
+                    buffer.append(obj);
                 }
-            } catch (EvalError e) {
-                Debug.logWarning(e, "Error evaluating BSH scriptlet [" + scriptlet + "], inserting nothing; error was: " + e.toString(), module);
             }
         }
     }
+
 }

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java Wed Aug 20 11:50:04 2008
@@ -77,7 +77,7 @@
                     fieldMap.put(new FlexibleMapAccessor<Object>(envName), new FlexibleMapAccessor<Object>(envName));
                 } else {
                     if (UtilValidate.isNotEmpty(value)) {
-                        fieldMap.put(new FlexibleMapAccessor<Object>(fieldName), new FlexibleStringExpander(value));
+                        fieldMap.put(new FlexibleMapAccessor<Object>(fieldName), FlexibleStringExpander.getInstance(value));
                     } else {
                         // at this point we have a fieldName and no value, do we have a envName?
                         if (UtilValidate.isNotEmpty(envName)) {
@@ -118,7 +118,7 @@
         if (selectFieldElementList.size() > 0) {
             selectFieldExpanderList = new LinkedList<FlexibleStringExpander>();
             for (Element selectFieldElement: selectFieldElementList) {
-                selectFieldExpanderList.add(new FlexibleStringExpander(selectFieldElement.getAttribute("field-name")));
+                selectFieldExpanderList.add(FlexibleStringExpander.getInstance(selectFieldElement.getAttribute("field-name")));
             }
         }
         return selectFieldExpanderList;
@@ -159,15 +159,15 @@
         protected boolean ignoreCase;
         
         public ConditionExpr(Element conditionExprElement) {
-            this.fieldNameExdr = new FlexibleStringExpander(conditionExprElement.getAttribute("field-name"));
+            this.fieldNameExdr = FlexibleStringExpander.getInstance(conditionExprElement.getAttribute("field-name"));
             if (this.fieldNameExdr.isEmpty()) {
                 // no "field-name"? try "name"
-                this.fieldNameExdr = new FlexibleStringExpander(conditionExprElement.getAttribute("name"));
+                this.fieldNameExdr = FlexibleStringExpander.getInstance(conditionExprElement.getAttribute("name"));
             }
 
-            this.operatorExdr = new FlexibleStringExpander(UtilFormatOut.checkEmpty(conditionExprElement.getAttribute("operator"), "equals"));
+            this.operatorExdr = FlexibleStringExpander.getInstance(UtilFormatOut.checkEmpty(conditionExprElement.getAttribute("operator"), "equals"));
             this.envNameAcsr = new FlexibleMapAccessor<Object>(conditionExprElement.getAttribute("env-name"));
-            this.valueExdr = new FlexibleStringExpander(conditionExprElement.getAttribute("value"));
+            this.valueExdr = FlexibleStringExpander.getInstance(conditionExprElement.getAttribute("value"));
             this.ignoreIfNull = "true".equals(conditionExprElement.getAttribute("ignore-if-null"));
             this.ignoreIfEmpty = "true".equals(conditionExprElement.getAttribute("ignore-if-empty"));
             this.ignoreCase = "true".equals(conditionExprElement.getAttribute("ignore-case"));
@@ -255,7 +255,7 @@
         FlexibleStringExpander combineExdr;
         
         public ConditionList(Element conditionListElement) {
-            this.combineExdr = new FlexibleStringExpander(conditionListElement.getAttribute("combine"));
+            this.combineExdr = FlexibleStringExpander.getInstance(conditionListElement.getAttribute("combine"));
             
             List<? extends Element> subElements = UtilXml.childElementList(conditionListElement);
             for (Element subElement: subElements) {
@@ -323,8 +323,8 @@
         FlexibleStringExpander sizeExdr;
         
         public LimitRange(Element limitRangeElement) {
-            this.startExdr = new FlexibleStringExpander(limitRangeElement.getAttribute("start"));
-            this.sizeExdr = new FlexibleStringExpander(limitRangeElement.getAttribute("size"));
+            this.startExdr = FlexibleStringExpander.getInstance(limitRangeElement.getAttribute("start"));
+            this.sizeExdr = FlexibleStringExpander.getInstance(limitRangeElement.getAttribute("size"));
         }
         
         int getStart(Map<String, Object> context) {
@@ -377,8 +377,8 @@
         FlexibleStringExpander viewSizeExdr;
         
         public LimitView(Element limitViewElement) {
-            this.viewIndexExdr = new FlexibleStringExpander(limitViewElement.getAttribute("view-index"));
-            this.viewSizeExdr = new FlexibleStringExpander(limitViewElement.getAttribute("view-size"));
+            this.viewIndexExdr = FlexibleStringExpander.getInstance(limitViewElement.getAttribute("view-index"));
+            this.viewSizeExdr = FlexibleStringExpander.getInstance(limitViewElement.getAttribute("view-size"));
         }
         
         int getIndex(Map<String, Object> context) {

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/Finder.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/Finder.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/Finder.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/Finder.java Wed Aug 20 11:50:04 2008
@@ -31,8 +31,8 @@
     protected FlexibleStringExpander useCacheStrExdr;
 
     protected Finder(Element element) {
-        this.entityNameExdr = new FlexibleStringExpander(element.getAttribute("entity-name"));
-        this.useCacheStrExdr = new FlexibleStringExpander(element.getAttribute("use-cache"));
+        this.entityNameExdr = FlexibleStringExpander.getInstance(element.getAttribute("entity-name"));
+        this.useCacheStrExdr = FlexibleStringExpander.getInstance(element.getAttribute("use-cache"));
     }
     
     public String getEntityName() {

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java Wed Aug 20 11:50:04 2008
@@ -75,11 +75,11 @@
         super(element);
         this.label = label;
 
-        this.filterByDateStrExdr = new FlexibleStringExpander(element.getAttribute("filter-by-date"));
-        this.distinctStrExdr = new FlexibleStringExpander(element.getAttribute("distinct"));
-        this.delegatorNameExdr = new FlexibleStringExpander(element.getAttribute("delegator-name"));
+        this.filterByDateStrExdr = FlexibleStringExpander.getInstance(element.getAttribute("filter-by-date"));
+        this.distinctStrExdr = FlexibleStringExpander.getInstance(element.getAttribute("distinct"));
+        this.delegatorNameExdr = FlexibleStringExpander.getInstance(element.getAttribute("delegator-name"));
         this.listAcsr = new FlexibleMapAccessor<Object>(element.getAttribute("list-name"));
-        this.resultSetTypeExdr = new FlexibleStringExpander(element.getAttribute("result-set-type"));
+        this.resultSetTypeExdr = FlexibleStringExpander.getInstance(element.getAttribute("result-set-type"));
 
         // process select-field
         selectFieldExpanderList = EntityFinderUtil.makeSelectFieldExpanderList(element);
@@ -89,7 +89,7 @@
         if (orderByElementList.size() > 0) {
             orderByExpanderList = FastList.newInstance();
             for (Element orderByElement: orderByElementList) {
-                orderByExpanderList.add(new FlexibleStringExpander(orderByElement.getAttribute("field-name")));
+                orderByExpanderList.add(FlexibleStringExpander.getInstance(orderByElement.getAttribute("field-name")));
             }
         }
 

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/PrimaryKeyFinder.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/PrimaryKeyFinder.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/PrimaryKeyFinder.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/PrimaryKeyFinder.java Wed Aug 20 11:50:04 2008
@@ -53,7 +53,7 @@
         super(entityOneElement);
         if (UtilValidate.isNotEmpty(entityOneElement.getAttribute("value-name")))
             this.valueNameAcsr = new FlexibleMapAccessor<Object>(entityOneElement.getAttribute("value-name"));
-        this.autoFieldMapExdr = new FlexibleStringExpander(entityOneElement.getAttribute("auto-field-map"));
+        this.autoFieldMapExdr = FlexibleStringExpander.getInstance(entityOneElement.getAttribute("auto-field-map"));
 
         // process field-map
         this.fieldMap = EntityFinderUtil.makeFieldMap(entityOneElement);

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=687422&r1=687421&r2=687422&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 Wed Aug 20 11:50:04 2008
@@ -51,7 +51,7 @@
             // try to expand the envName
             if (UtilValidate.isEmpty(value)) {
                 if (UtilValidate.isNotEmpty(envName) && envName.startsWith("${")) {
-                    FlexibleStringExpander exp = new FlexibleStringExpander(envName);
+                    FlexibleStringExpander exp = FlexibleStringExpander.getInstance(envName);
                     String s = exp.expandString(context);
                     if (UtilValidate.isNotEmpty(s)) {
                         value = s;

Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java Wed Aug 20 11:50:04 2008
@@ -72,8 +72,8 @@
     protected AuxiliaryValueGetter auxiliaryValueGetter;
     
     public EntityPermissionChecker(Element element) {
-        this.entityNameExdr = new FlexibleStringExpander(element.getAttribute("entity-name"));
-        this.entityIdExdr = new FlexibleStringExpander(element.getAttribute("entity-id"));
+        this.entityNameExdr = FlexibleStringExpander.getInstance(element.getAttribute("entity-name"));
+        this.entityIdExdr = FlexibleStringExpander.getInstance(element.getAttribute("entity-id"));
         this.displayFailCond = "true".equals(element.getAttribute("display-fail-cond"));
         Element permissionConditionElement = UtilXml.firstChildElement(element, "permission-condition-getter");
         if (permissionConditionElement == null) {

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/Assert.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/Assert.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/Assert.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/Assert.java Wed Aug 20 11:50:04 2008
@@ -58,7 +58,7 @@
         super(element, simpleMethod);
 
         errorListAcsr = new ContextAccessor<List<Object>>(element.getAttribute("error-list-name"), "error_list");
-        titleExdr = new FlexibleStringExpander(element.getAttribute("title"));
+        titleExdr = FlexibleStringExpander.getInstance(element.getAttribute("title"));
         
         for (Element conditionalElement: UtilXml.childElementList(element)) {
             this.conditionalList.add(ConditionalFactory.makeConditional(conditionalElement, simpleMethod));

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/RegexpCondition.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/RegexpCondition.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/RegexpCondition.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/RegexpCondition.java Wed Aug 20 11:50:04 2008
@@ -75,7 +75,7 @@
         this.mapAcsr = new ContextAccessor<Map<String, ? extends Object>>(element.getAttribute("map-name"));
         this.fieldAcsr = new ContextAccessor<Object>(element.getAttribute("field-name"));
 
-        this.exprExdr = new FlexibleStringExpander(element.getAttribute("expr"));
+        this.exprExdr = FlexibleStringExpander.getInstance(element.getAttribute("expr"));
     }
 
     public boolean checkCondition(MethodContext methodContext) {

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java Wed Aug 20 11:50:04 2008
@@ -60,8 +60,8 @@
 
     public EntityCount(Element element, SimpleMethod simpleMethod) {
         super(element, simpleMethod);
-        this.entityNameExdr = new FlexibleStringExpander(element.getAttribute("entity-name"));
-        this.delegatorNameExdr = new FlexibleStringExpander(element.getAttribute("delegator-name"));
+        this.entityNameExdr = FlexibleStringExpander.getInstance(element.getAttribute("entity-name"));
+        this.delegatorNameExdr = FlexibleStringExpander.getInstance(element.getAttribute("delegator-name"));
         this.countAcsr = new FlexibleMapAccessor<Long>(element.getAttribute("count-name"));
         
         // process condition-expr | condition-list

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java Wed Aug 20 11:50:04 2008
@@ -62,9 +62,9 @@
 
     public EntityData(Element element, SimpleMethod simpleMethod) {
         super(element, simpleMethod);
-        locationExdr = new FlexibleStringExpander(element.getAttribute("location"));
-        delegatorNameExdr = new FlexibleStringExpander(element.getAttribute("delegator-name"));
-        timeoutExdr = new FlexibleStringExpander(element.getAttribute("timeout"));
+        locationExdr = FlexibleStringExpander.getInstance(element.getAttribute("location"));
+        delegatorNameExdr = FlexibleStringExpander.getInstance(element.getAttribute("delegator-name"));
+        timeoutExdr = FlexibleStringExpander.getInstance(element.getAttribute("timeout"));
         errorListAcsr = new ContextAccessor<List<Object>>(element.getAttribute("error-list-name"), "error_list");
         
         mode = element.getAttribute("mode");

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java Wed Aug 20 11:50:04 2008
@@ -70,19 +70,19 @@
         super(element, simpleMethod);
         this.field = new ContextAccessor<Timestamp>(element.getAttribute("field"));
         this.fromField = new ContextAccessor<Object>(element.getAttribute("from-field"));
-        this.valueExdr = new FlexibleStringExpander(element.getAttribute("value"));
-        this.defaultExdr = new FlexibleStringExpander(element.getAttribute("default-value"));
-        this.yearsExdr = new FlexibleStringExpander(element.getAttribute("years"));
-        this.monthsExdr = new FlexibleStringExpander(element.getAttribute("months"));
-        this.daysExdr = new FlexibleStringExpander(element.getAttribute("days"));
-        this.hoursExdr = new FlexibleStringExpander(element.getAttribute("hours"));
-        this.minutesExdr = new FlexibleStringExpander(element.getAttribute("minutes"));
-        this.secondsExdr = new FlexibleStringExpander(element.getAttribute("seconds"));
-        this.millisExdr = new FlexibleStringExpander(element.getAttribute("millis"));
-        this.periodAlignStart = new FlexibleStringExpander(element.getAttribute("period-align-start"));
-        this.periodAlignEnd = new FlexibleStringExpander(element.getAttribute("period-align-end"));
-        this.localeExdr = new FlexibleStringExpander(element.getAttribute("locale"));
-        this.timeZoneExdr = new FlexibleStringExpander(element.getAttribute("time-zone"));
+        this.valueExdr = FlexibleStringExpander.getInstance(element.getAttribute("value"));
+        this.defaultExdr = FlexibleStringExpander.getInstance(element.getAttribute("default-value"));
+        this.yearsExdr = FlexibleStringExpander.getInstance(element.getAttribute("years"));
+        this.monthsExdr = FlexibleStringExpander.getInstance(element.getAttribute("months"));
+        this.daysExdr = FlexibleStringExpander.getInstance(element.getAttribute("days"));
+        this.hoursExdr = FlexibleStringExpander.getInstance(element.getAttribute("hours"));
+        this.minutesExdr = FlexibleStringExpander.getInstance(element.getAttribute("minutes"));
+        this.secondsExdr = FlexibleStringExpander.getInstance(element.getAttribute("seconds"));
+        this.millisExdr = FlexibleStringExpander.getInstance(element.getAttribute("millis"));
+        this.periodAlignStart = FlexibleStringExpander.getInstance(element.getAttribute("period-align-start"));
+        this.periodAlignEnd = FlexibleStringExpander.getInstance(element.getAttribute("period-align-end"));
+        this.localeExdr = FlexibleStringExpander.getInstance(element.getAttribute("locale"));
+        this.timeZoneExdr = FlexibleStringExpander.getInstance(element.getAttribute("time-zone"));
         // default to false, anything but true is false
         this.setIfNull = "true".equals(element.getAttribute("set-if-null"));
         // default to true, anything but false is true

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java Wed Aug 20 11:50:04 2008
@@ -59,8 +59,8 @@
         super(element, simpleMethod);
         this.field = new ContextAccessor<Object>(element.getAttribute("field"));
         this.fromField = new ContextAccessor<Object>(element.getAttribute("from-field"));
-        this.valueExdr = new FlexibleStringExpander(element.getAttribute("value"));
-        this.defaultExdr = new FlexibleStringExpander(element.getAttribute("default-value"));
+        this.valueExdr = FlexibleStringExpander.getInstance(element.getAttribute("value"));
+        this.defaultExdr = FlexibleStringExpander.getInstance(element.getAttribute("default-value"));
         this.type = element.getAttribute("type");
         // default to false, anything but true is false
         this.setIfNull = "true".equals(element.getAttribute("set-if-null"));

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfHasPermission.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfHasPermission.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfHasPermission.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfHasPermission.java Wed Aug 20 11:50:04 2008
@@ -54,8 +54,8 @@
 
     public IfHasPermission(Element element, SimpleMethod simpleMethod) {
         super(element, simpleMethod);
-        this.permissionExdr = new FlexibleStringExpander(element.getAttribute("permission"));
-        this.actionExdr = new FlexibleStringExpander(element.getAttribute("action"));
+        this.permissionExdr = FlexibleStringExpander.getInstance(element.getAttribute("permission"));
+        this.actionExdr = FlexibleStringExpander.getInstance(element.getAttribute("action"));
 
         SimpleMethod.readOperations(element, subOps, simpleMethod);
 

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfRegexp.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfRegexp.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfRegexp.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfRegexp.java Wed Aug 20 11:50:04 2008
@@ -62,7 +62,7 @@
         this.mapAcsr = new ContextAccessor<Map<String, ? extends Object>>(element.getAttribute("map-name"));
         this.fieldAcsr = new ContextAccessor<Object>(element.getAttribute("field-name"));
 
-        this.exprExdr = new FlexibleStringExpander(element.getAttribute("expr"));
+        this.exprExdr = FlexibleStringExpander.getInstance(element.getAttribute("expr"));
 
         SimpleMethod.readOperations(element, subOps, simpleMethod);
 

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java Wed Aug 20 11:50:04 2008
@@ -51,7 +51,7 @@
             // try to expand the envName
             if (UtilValidate.isEmpty(value)) {
                 if (UtilValidate.isNotEmpty(envName) && envName.startsWith("${")) {
-                    FlexibleStringExpander exp = new FlexibleStringExpander(envName);
+                    FlexibleStringExpander exp = FlexibleStringExpander.getInstance(envName);
                     String s = exp.expandString(context);
                     if (UtilValidate.isNotEmpty(s)) {
                         value = s;

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Wed Aug 20 11:50:04 2008
@@ -404,19 +404,19 @@
             setPaginateSizeField(formElement.getAttribute("paginate-size-field"));
         }
         if (this.overrideListSize == null || formElement.hasAttribute("override-list-size")) {
-            this.overrideListSize = new FlexibleStringExpander(formElement.getAttribute("override-list-size"));
+            this.overrideListSize = FlexibleStringExpander.getInstance(formElement.getAttribute("override-list-size"));
         }
         if (this.paginateFirstLabel == null || formElement.hasAttribute("paginate-first-label")) {
-            this.paginateFirstLabel = new FlexibleStringExpander(formElement.getAttribute("paginate-first-label"));
+            this.paginateFirstLabel = FlexibleStringExpander.getInstance(formElement.getAttribute("paginate-first-label"));
         }
         if (this.paginatePreviousLabel == null || formElement.hasAttribute("paginate-previous-label")) {
-            this.paginatePreviousLabel = new FlexibleStringExpander(formElement.getAttribute("paginate-previous-label"));
+            this.paginatePreviousLabel = FlexibleStringExpander.getInstance(formElement.getAttribute("paginate-previous-label"));
         }
         if (this.paginateNextLabel == null || formElement.hasAttribute("paginate-next-label")) {
-            this.paginateNextLabel = new FlexibleStringExpander(formElement.getAttribute("paginate-next-label"));
+            this.paginateNextLabel = FlexibleStringExpander.getInstance(formElement.getAttribute("paginate-next-label"));
         }
         if (this.paginateLastLabel == null || formElement.hasAttribute("paginate-last-label")) {
-            this.paginateLastLabel = new FlexibleStringExpander(formElement.getAttribute("paginate-last-label"));
+            this.paginateLastLabel = FlexibleStringExpander.getInstance(formElement.getAttribute("paginate-last-label"));
         }
         if (this.paginateStyle == null || formElement.hasAttribute("paginate-style")) {
             setPaginateStyle(formElement.getAttribute("paginate-style"));
@@ -441,7 +441,7 @@
             setDefaultViewSize(formElement.getAttribute("view-size"));
         }
         if (this.rowCountExdr == null || formElement.hasAttribute("row-count")) {
-            this.rowCountExdr = new FlexibleStringExpander(formElement.getAttribute("row-count"));
+            this.rowCountExdr = FlexibleStringExpander.getInstance(formElement.getAttribute("row-count"));
         }
 
         // alt-target
@@ -2172,7 +2172,7 @@
      * @param string
      */
     public void setTarget(String string) {
-        this.target = new FlexibleStringExpander(string);
+        this.target = FlexibleStringExpander.getInstance(string);
     }
 
     /**
@@ -2364,7 +2364,7 @@
     }
             
     public void setTargetWindow( String val ) {
-        this.targetWindowExdr = new FlexibleStringExpander(val);
+        this.targetWindowExdr = FlexibleStringExpander.getInstance(val);
     }
 
     /**
@@ -2415,15 +2415,15 @@
     }
 
     public void setPaginateTarget(String string) {
-        this.paginateTarget = new FlexibleStringExpander(string);
+        this.paginateTarget = FlexibleStringExpander.getInstance(string);
     }
 
     public void setPaginateIndexField(String string) {
-        this.paginateIndexField = new FlexibleStringExpander(string);
+        this.paginateIndexField = FlexibleStringExpander.getInstance(string);
     }
 
     public void setPaginateSizeField(String string) {
-        this.paginateSizeField = new FlexibleStringExpander(string);
+        this.paginateSizeField = FlexibleStringExpander.getInstance(string);
     }
 
     public void setPaginateStyle(String string) {
@@ -2765,13 +2765,13 @@
         
         public Banner(Element sortOrderElement, ModelForm modelForm) {
             this.modelForm = modelForm;
-            this.style = new FlexibleStringExpander(sortOrderElement.getAttribute("style"));
-            this.text = new FlexibleStringExpander(sortOrderElement.getAttribute("text"));
-            this.textStyle = new FlexibleStringExpander(sortOrderElement.getAttribute("text-style"));
-            this.leftText = new FlexibleStringExpander(sortOrderElement.getAttribute("left-text"));
-            this.leftTextStyle = new FlexibleStringExpander(sortOrderElement.getAttribute("left-text-style"));
-            this.rightText = new FlexibleStringExpander(sortOrderElement.getAttribute("right-text"));
-            this.rightTextStyle = new FlexibleStringExpander(sortOrderElement.getAttribute("right-text-style"));
+            this.style = FlexibleStringExpander.getInstance(sortOrderElement.getAttribute("style"));
+            this.text = FlexibleStringExpander.getInstance(sortOrderElement.getAttribute("text"));
+            this.textStyle = FlexibleStringExpander.getInstance(sortOrderElement.getAttribute("text-style"));
+            this.leftText = FlexibleStringExpander.getInstance(sortOrderElement.getAttribute("left-text"));
+            this.leftTextStyle = FlexibleStringExpander.getInstance(sortOrderElement.getAttribute("left-text-style"));
+            this.rightText = FlexibleStringExpander.getInstance(sortOrderElement.getAttribute("right-text"));
+            this.rightTextStyle = FlexibleStringExpander.getInstance(sortOrderElement.getAttribute("right-text-style"));
         }
         
         public String getStyle(Map<String, Object> context) { return this.style.expandString(context); }

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java Wed Aug 20 11:50:04 2008
@@ -114,9 +114,9 @@
             super (modelForm, setElement);
             this.field = new FlexibleMapAccessor<Object>(setElement.getAttribute("field"));
             this.fromField = UtilValidate.isNotEmpty(setElement.getAttribute("from-field")) ? new FlexibleMapAccessor<String>(setElement.getAttribute("from-field")) : null;
-            this.valueExdr = UtilValidate.isNotEmpty(setElement.getAttribute("value")) ? new FlexibleStringExpander(setElement.getAttribute("value")) : null;
-            this.defaultExdr = new FlexibleStringExpander(setElement.getAttribute("default-value"));
-            this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global"));
+            this.valueExdr = UtilValidate.isNotEmpty(setElement.getAttribute("value")) ? FlexibleStringExpander.getInstance(setElement.getAttribute("value")) : null;
+            this.defaultExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("default-value"));
+            this.globalExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("global"));
             this.type = setElement.getAttribute("type");
             if (this.fromField != null && this.valueExdr != null) {
                 throw new IllegalArgumentException("Cannot specify a from-field [" + setElement.getAttribute("from-field") + "] and a value [" + setElement.getAttribute("value") + "] on the set action in a screen widget");
@@ -176,9 +176,9 @@
         
         public PropertyMap(ModelForm modelForm, Element setElement) {
             super (modelForm, setElement);
-            this.resourceExdr = new FlexibleStringExpander(setElement.getAttribute("resource"));
+            this.resourceExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("resource"));
             this.mapNameAcsr = new FlexibleMapAccessor<Map<String, Object>>(setElement.getAttribute("map-name"));
-            this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global"));
+            this.globalExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("global"));
         }
         
         public void runAction(Map<String, Object> context) {
@@ -212,13 +212,13 @@
 
         public PropertyToField(ModelForm modelForm, Element setElement) {
             super (modelForm, setElement);
-            this.resourceExdr = new FlexibleStringExpander(setElement.getAttribute("resource"));
-            this.propertyExdr = new FlexibleStringExpander(setElement.getAttribute("property"));
+            this.resourceExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("resource"));
+            this.propertyExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("property"));
             this.fieldAcsr = new FlexibleMapAccessor<String>(setElement.getAttribute("field"));
-            this.defaultExdr = new FlexibleStringExpander(setElement.getAttribute("default"));
+            this.defaultExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("default"));
             noLocale = "true".equals(setElement.getAttribute("no-locale"));
             this.argListAcsr = new FlexibleMapAccessor<List<Object>>(setElement.getAttribute("arg-list-name"));
-            this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global"));
+            this.globalExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("global"));
         }
         
         public void runAction(Map<String, Object> context) {
@@ -296,22 +296,22 @@
         
         public Service(ModelForm modelForm, Element serviceElement) {
             super (modelForm, serviceElement);
-            this.serviceNameExdr = new FlexibleStringExpander(serviceElement.getAttribute("service-name"));
+            this.serviceNameExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("service-name"));
             this.resultMapNameAcsr = UtilValidate.isNotEmpty(serviceElement.getAttribute("result-map-name")) ? new FlexibleMapAccessor<Map<String, Object>>(serviceElement.getAttribute("result-map-name")) : null;
-            this.autoFieldMapExdr = new FlexibleStringExpander(serviceElement.getAttribute("auto-field-map"));
+            this.autoFieldMapExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("auto-field-map"));
             if (UtilValidate.isEmpty(serviceElement.getAttribute("result-map-list-name"))) {
                 if (UtilValidate.isEmpty(serviceElement.getAttribute("result-map-list-iterator-name"))) {
                     String lstNm = modelForm.getListName();
                     if (UtilValidate.isEmpty(lstNm)) {
                         lstNm = ModelForm.DEFAULT_FORM_RESULT_LIST_NAME;
                     }
-                    this.resultMapListNameExdr = new FlexibleStringExpander(lstNm);
+                    this.resultMapListNameExdr = FlexibleStringExpander.getInstance(lstNm);
                 } else {
                     // this is deprecated, but support it for now anyway
-                    this.resultMapListNameExdr = new FlexibleStringExpander(serviceElement.getAttribute("result-map-list-iterator-name"));
+                    this.resultMapListNameExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("result-map-list-iterator-name"));
                 }
             } else {
-                this.resultMapListNameExdr = new FlexibleStringExpander(serviceElement.getAttribute("result-map-list-name"));
+                this.resultMapListNameExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("result-map-list-name"));
             }
             
             this.fieldMap = EntityFinderUtil.makeFieldMap(serviceElement);
@@ -478,3 +478,4 @@
 
 
 
+

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Wed Aug 20 11:50:04 2008
@@ -1275,7 +1275,7 @@
      * @param string
      */
     public void setAction(String string) {
-        this.action = new FlexibleStringExpander(string);
+        this.action = FlexibleStringExpander.getInstance(string);
     }
 
     /**
@@ -1289,7 +1289,7 @@
      * @param string
      */
     public void setTitle(String string) {
-        this.title = new FlexibleStringExpander(string);
+        this.title = FlexibleStringExpander.getInstance(string);
     }
 
     /**
@@ -1310,14 +1310,14 @@
      * @param string
      */
     public void setTooltip(String string) {
-        this.tooltip = new FlexibleStringExpander(string);
+        this.tooltip = FlexibleStringExpander.getInstance(string);
     }
 
     /**
      * @param string
      */
     public void setUseWhen(String string) {
-        this.useWhen = new FlexibleStringExpander(string);
+        this.useWhen = FlexibleStringExpander.getInstance(string);
     }
 
     /**
@@ -1510,7 +1510,7 @@
         public FieldInfoWithOptions(Element element, ModelFormField modelFormField) {
             super(element, modelFormField);
 
-            noCurrentSelectedKey = new FlexibleStringExpander(element.getAttribute("no-current-selected-key"));
+            noCurrentSelectedKey = FlexibleStringExpander.getInstance(element.getAttribute("no-current-selected-key"));
 
             // read all option and entity-options sub-elements, maintaining order
             List childElements = UtilXml.childElementList(element);
@@ -1571,7 +1571,7 @@
         }
 
         public void setNoCurrentSelectedKey(String string) {            
-            this.noCurrentSelectedKey = new FlexibleStringExpander(string);
+            this.noCurrentSelectedKey = FlexibleStringExpander.getInstance(string);
         }
 
         public void addOptionSource(OptionSource optionSource) {
@@ -1608,14 +1608,14 @@
         protected FlexibleStringExpander description;
 
         public SingleOption(String key, String description, FieldInfo fieldInfo) {
-            this.key = new FlexibleStringExpander(key);
-            this.description = new FlexibleStringExpander(UtilXml.checkEmpty(description, key));
+            this.key = FlexibleStringExpander.getInstance(key);
+            this.description = FlexibleStringExpander.getInstance(UtilXml.checkEmpty(description, key));
             this.fieldInfo = fieldInfo;
         }
 
         public SingleOption(Element optionElement, FieldInfo fieldInfo) {
-            this.key = new FlexibleStringExpander(optionElement.getAttribute("key"));
-            this.description = new FlexibleStringExpander(UtilXml.checkEmpty(optionElement.getAttribute("description"), optionElement.getAttribute("key")));
+            this.key = FlexibleStringExpander.getInstance(optionElement.getAttribute("key"));
+            this.description = FlexibleStringExpander.getInstance(UtilXml.checkEmpty(optionElement.getAttribute("description"), optionElement.getAttribute("key")));
             this.fieldInfo = fieldInfo;
         }
 
@@ -1634,7 +1634,7 @@
             this.listAcsr = new FlexibleMapAccessor<List<? extends Object>>(listName);
             this.listEntryName = listEntryName;
             this.keyAcsr = new FlexibleMapAccessor<String>(keyName);
-            this.description = new FlexibleStringExpander(description);
+            this.description = FlexibleStringExpander.getInstance(description);
             this.fieldInfo = fieldInfo;
         }
 
@@ -1643,7 +1643,7 @@
             this.keyAcsr = new FlexibleMapAccessor<String>(optionElement.getAttribute("key-name"));
             this.listAcsr = new FlexibleMapAccessor<List<? extends Object>>(optionElement.getAttribute("list-name"));
             this.listEntryName = optionElement.getAttribute("list-entry-name");
-            this.description = new FlexibleStringExpander(optionElement.getAttribute("description"));
+            this.description = FlexibleStringExpander.getInstance(optionElement.getAttribute("description"));
             this.fieldInfo = fieldInfo;
         }
 
@@ -1682,7 +1682,7 @@
         public EntityOptions(Element entityOptionsElement, FieldInfo fieldInfo) {
             this.entityName = entityOptionsElement.getAttribute("entity-name");
             this.keyFieldName = entityOptionsElement.getAttribute("key-field-name");
-            this.description = new FlexibleStringExpander(entityOptionsElement.getAttribute("description"));
+            this.description = FlexibleStringExpander.getInstance(entityOptionsElement.getAttribute("description"));
             this.cache = !"false".equals(entityOptionsElement.getAttribute("cache"));
             this.filterByDate = entityOptionsElement.getAttribute("filter-by-date");
 
@@ -1936,7 +1936,7 @@
         }
 
         public void setUrl(String url) {
-            this.url = new FlexibleStringExpander(url);
+            this.url = FlexibleStringExpander.getInstance(url);
         }
 
         public void setCancelControl(String string) {
@@ -2129,20 +2129,20 @@
          * @param Description
          */
         public void setDescription(String string) {
-            description = new FlexibleStringExpander(string);
+            description = FlexibleStringExpander.getInstance(string);
         }
         
         /**
          * @param string
          */
         public void setCurrency(String string) {
-            currency = new FlexibleStringExpander(string);
+            currency = FlexibleStringExpander.getInstance(string);
         }
         /**
          * @param date
          */
         public void setDate(String string) {
-            date = new FlexibleStringExpander(string);
+            date = FlexibleStringExpander.getInstance(string);
         }
         
         public void setInPlaceEditor(InPlaceEditor newInPlaceEditor) {
@@ -2264,7 +2264,7 @@
             this.setTarget(element.getAttribute("target"));
             this.alsoHidden = !"false".equals(element.getAttribute("also-hidden"));
             this.targetType = element.getAttribute("target-type");
-            this.targetWindowExdr = new FlexibleStringExpander(element.getAttribute("target-window"));
+            this.targetWindowExdr = FlexibleStringExpander.getInstance(element.getAttribute("target-window"));
         }
 
         public void renderFieldString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException {
@@ -2326,14 +2326,14 @@
          * @param string
          */
         public void setDescription(String string) {
-            this.description = new FlexibleStringExpander(string);
+            this.description = FlexibleStringExpander.getInstance(string);
         }
 
         /**
          * @param string
          */
         public void setTarget(String string) {
-            this.target = new FlexibleStringExpander(string);
+            this.target = FlexibleStringExpander.getInstance(string);
         }
     }
 
@@ -2351,7 +2351,7 @@
             this.setUseWhen(element.getAttribute("use-when"));
             this.linkStyle = element.getAttribute("link-style");
             this.targetType = element.getAttribute("target-type");
-            this.targetWindowExdr = new FlexibleStringExpander(element.getAttribute("target-window"));
+            this.targetWindowExdr = FlexibleStringExpander.getInstance(element.getAttribute("target-window"));
         }
 
         /**
@@ -2458,21 +2458,21 @@
          * @param string
          */
         public void setDescription(String string) {
-            this.description = new FlexibleStringExpander(string);
+            this.description = FlexibleStringExpander.getInstance(string);
         }
 
         /**
          * @param string
          */
         public void setTarget(String string) {
-            this.target = new FlexibleStringExpander(string);
+            this.target = FlexibleStringExpander.getInstance(string);
         }
 
         /**
          * @param string
          */
         public void setUseWhen(String string) {
-            this.useWhen = new FlexibleStringExpander(string);
+            this.useWhen = FlexibleStringExpander.getInstance(string);
         }
     }
     
@@ -2681,7 +2681,7 @@
          * @param str
          */
         public void setDefaultValue(String str) {
-            this.defaultValue = new FlexibleStringExpander(str);
+            this.defaultValue = FlexibleStringExpander.getInstance(str);
         }
 
         public SubHyperlink getSubHyperlink() {
@@ -2717,7 +2717,7 @@
             this.setDefaultValue(element.getAttribute("default-value"));
             
             visualEditorEnable = "true".equals(element.getAttribute("visual-editor-enable"));
-            visualEditorButtons = new FlexibleStringExpander(element.getAttribute("visual-editor-buttons"));
+            visualEditorButtons = FlexibleStringExpander.getInstance(element.getAttribute("visual-editor-buttons"));
             readOnly = "true".equals(element.getAttribute("read-only"));
 
             String colsStr = element.getAttribute("cols");
@@ -2814,7 +2814,7 @@
          * @param str
          */
         public void setDefaultValue(String str) {
-            this.defaultValue = new FlexibleStringExpander(str);
+            this.defaultValue = FlexibleStringExpander.getInstance(str);
         }
 
         /**
@@ -2828,7 +2828,7 @@
          * @param i
          */
         public void setVisualEditorButtons(String eb) {
-            this.visualEditorButtons = new FlexibleStringExpander(eb);
+            this.visualEditorButtons = FlexibleStringExpander.getInstance(eb);
         }
     }
 
@@ -2899,7 +2899,7 @@
          * @param str
          */
         public void setDefaultValue(String str) {
-            this.defaultValue = new FlexibleStringExpander(str);
+            this.defaultValue = FlexibleStringExpander.getInstance(str);
         }
 
         public void setInputMethod(String str) {
@@ -2960,7 +2960,7 @@
             this.size = element.getAttribute("size");
             this.allowEmpty = "true".equals(element.getAttribute("allow-empty"));
             this.allowMulti = "true".equals(element.getAttribute("allow-multiple"));
-            this.currentDescription = new FlexibleStringExpander(element.getAttribute("current-description"));
+            this.currentDescription = FlexibleStringExpander.getInstance(element.getAttribute("current-description"));
 
             // set the default size
             if (size == null) {
@@ -3023,7 +3023,7 @@
         }
 
         public void setCurrentDescription(String string) {
-            this.currentDescription = new FlexibleStringExpander(string);
+            this.currentDescription = FlexibleStringExpander.getInstance(string);
         }
 
         public SubHyperlink getSubHyperlink() {
@@ -3114,7 +3114,7 @@
 
         public CheckField(Element element, ModelFormField modelFormField) {
             super(element, modelFormField);
-            allChecked = new FlexibleStringExpander(element.getAttribute("all-checked"));
+            allChecked = FlexibleStringExpander.getInstance(element.getAttribute("all-checked"));
         }
 
         public void renderFieldString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException {
@@ -3152,7 +3152,7 @@
             super(element, modelFormField);
             this.buttonType = element.getAttribute("button-type");
             this.imageLocation = element.getAttribute("image-location");
-            this.backgroundSubmitRefreshTargetExdr = new FlexibleStringExpander(element.getAttribute("background-submit-refresh-target"));
+            this.backgroundSubmitRefreshTargetExdr = FlexibleStringExpander.getInstance(element.getAttribute("background-submit-refresh-target"));
         }
 
         public void renderFieldString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException {
@@ -3247,7 +3247,7 @@
         }
 
         public void setValue(String string) {
-            this.value = new FlexibleStringExpander(string);
+            this.value = FlexibleStringExpander.getInstance(string);
         }
     }
 
@@ -3375,7 +3375,7 @@
         
         public LookupField(Element element, ModelFormField modelFormField) {
             super(element, modelFormField);
-            this.formName = new FlexibleStringExpander(element.getAttribute("target-form-name"));
+            this.formName = FlexibleStringExpander.getInstance(element.getAttribute("target-form-name"));
             this.descriptionFieldName = element.getAttribute("description-field-name");
             this.targetParameter = element.getAttribute("target-parameter");
         }
@@ -3404,7 +3404,7 @@
         }
 
         public void setFormName(String str) {
-            this.formName = new FlexibleStringExpander(str);
+            this.formName = FlexibleStringExpander.getInstance(str);
         }
         
         public String getDescriptionFieldName() {
@@ -3518,7 +3518,7 @@
          * @param str
          */
         public void setDefaultValue(String str) {
-            this.defaultValue = new FlexibleStringExpander(str);
+            this.defaultValue = FlexibleStringExpander.getInstance(str);
         }
 
         public SubHyperlink getSubHyperlink() {
@@ -3567,7 +3567,7 @@
         }
 
         public void setValue(String string) {
-            this.value = new FlexibleStringExpander(string);
+            this.value = FlexibleStringExpander.getInstance(string);
         }
 
     }

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Wed Aug 20 11:50:04 2008
@@ -2670,7 +2670,7 @@
     public void renderHyperlinkTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText) throws IOException {
         if (UtilValidate.isNotEmpty(modelFormField.getHeaderLink())) {
             StringBuffer targetBuffer = new StringBuffer();
-            FlexibleStringExpander target = new FlexibleStringExpander(modelFormField.getHeaderLink());        
+            FlexibleStringExpander target = FlexibleStringExpander.getInstance(modelFormField.getHeaderLink());        
             String fullTarget = target.expandString(context);
             targetBuffer.append(fullTarget);
             String targetType = HyperlinkField.DEFAULT_TARGET_TYPE;

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java?rev=687422&r1=687421&r2=687422&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java Wed Aug 20 11:50:04 2008
@@ -567,7 +567,7 @@
      * @param string
      */
     public void setTitle(String string) {
-        this.title = new FlexibleStringExpander(string);
+        this.title = FlexibleStringExpander.getInstance(string);
     }
 
     /**
@@ -588,14 +588,14 @@
      * @param string
      */
     public void setDefaultAssociatedContentId(String string) {
-        this.defaultAssociatedContentId = new FlexibleStringExpander(string);
+        this.defaultAssociatedContentId = FlexibleStringExpander.getInstance(string);
     }
 
     /**
      * @param string
      */
     public void setMenuContainerStyle(String string) {
-        this.menuContainerStyleExdr = new FlexibleStringExpander(string);
+        this.menuContainerStyleExdr = FlexibleStringExpander.getInstance(string);
     }
 
     /**