svn commit: r726260 - in /ofbiz/trunk/framework: base/src/org/ofbiz/base/util/collections/ entity/src/org/ofbiz/entity/finder/ widget/src/org/ofbiz/widget/menu/

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

svn commit: r726260 - in /ofbiz/trunk/framework: base/src/org/ofbiz/base/util/collections/ entity/src/org/ofbiz/entity/finder/ widget/src/org/ofbiz/widget/menu/

adrianc
Author: adrianc
Date: Sat Dec 13 11:25:33 2008
New Revision: 726260

URL: http://svn.apache.org/viewvc?rev=726260&view=rev
Log:
Implemented FlexibleMapAccessor.getInstance() in the remaining classes. Deprecated the FlexibleMapAccessor constructor.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleServletAccessor.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.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/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java?rev=726260&r1=726259&r2=726260&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleMapAccessor.java Sat Dec 13 11:25:33 2008
@@ -37,7 +37,7 @@
  * accessing sub-map values and the "[]" (square bracket) syntax for accessing
  * list elements. See individual Map operations for more information.
  */
-@SuppressWarnings("serial")
+@SuppressWarnings({ "serial", "deprecation" })
 public class FlexibleMapAccessor<T> implements Serializable {
     public static final String module = FlexibleMapAccessor.class.getName();
     protected static final String openBracket = "${";
@@ -51,8 +51,8 @@
     protected final ExpressionNode node;
     protected boolean isAscending = true;
 
+    /** @deprecated Use getInstance(String original) instead */
     public FlexibleMapAccessor(String name) {
-        // TODO: Change this to protected
         this.original = name;
         if (name != null && name.length() > 0) {
             if (name.charAt(0) == '-') {

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleServletAccessor.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleServletAccessor.java?rev=726260&r1=726259&r2=726260&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleServletAccessor.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleServletAccessor.java Sat Dec 13 11:25:33 2008
@@ -59,7 +59,7 @@
         if (name == null || name.length() == 0) {
             empty = true;
             needsExpand = false;
-            fma = new FlexibleMapAccessor<T>(name);
+            fma = FlexibleMapAccessor.getInstance(name);
             attributeName = name;
         } else {
             empty = false;
@@ -72,7 +72,7 @@
                 int dotIndex = name.indexOf('.');
                 if (dotIndex != -1) {
                     attributeName = name.substring(0, dotIndex);
-                    fma = new FlexibleMapAccessor<T>(name.substring(dotIndex+1));
+                    fma = FlexibleMapAccessor.getInstance(name.substring(dotIndex+1));
                 } else {
                     attributeName = name;
                     fma = null;
@@ -209,7 +209,7 @@
                 int dotIndex = name.indexOf('.');
                 if (dotIndex != -1) {
                     attributeName = name.substring(0, dotIndex);
-                    fma = new FlexibleMapAccessor<T>(name.substring(dotIndex+1));
+                    fma = FlexibleMapAccessor.getInstance(name.substring(dotIndex+1));
                 } else {
                     attributeName = name;
                     fma = null;

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=726260&r1=726259&r2=726260&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 Sat Dec 13 11:25:33 2008
@@ -74,17 +74,17 @@
                 String value = fieldMapElement.getAttribute("value");
                 if (UtilValidate.isEmpty(fieldName)) {
                     // no fieldName, use envName for both
-                    fieldMap.put(new FlexibleMapAccessor<Object>(envName), new FlexibleMapAccessor<Object>(envName));
+                    fieldMap.put(FlexibleMapAccessor.getInstance(envName), FlexibleMapAccessor.getInstance(envName));
                 } else {
                     if (UtilValidate.isNotEmpty(value)) {
-                        fieldMap.put(new FlexibleMapAccessor<Object>(fieldName), FlexibleStringExpander.getInstance(value));
+                        fieldMap.put(FlexibleMapAccessor.getInstance(fieldName), FlexibleStringExpander.getInstance(value));
                     } else {
                         // at this point we have a fieldName and no value, do we have a envName?
                         if (UtilValidate.isNotEmpty(envName)) {
-                            fieldMap.put(new FlexibleMapAccessor<Object>(fieldName), new FlexibleMapAccessor<Object>(envName));
+                            fieldMap.put(FlexibleMapAccessor.getInstance(fieldName), FlexibleMapAccessor.getInstance(envName));
                         } else {
                             // no envName, use fieldName for both
-                            fieldMap.put(new FlexibleMapAccessor<Object>(fieldName), new FlexibleMapAccessor<Object>(fieldName));
+                            fieldMap.put(FlexibleMapAccessor.getInstance(fieldName), FlexibleMapAccessor.getInstance(fieldName));
                         }
                     }
                 }
@@ -167,7 +167,7 @@
             }
 
             this.operatorExdr = FlexibleStringExpander.getInstance(UtilFormatOut.checkEmpty(conditionExprElement.getAttribute("operator"), "equals"));
-            this.envNameAcsr = new FlexibleMapAccessor<Object>(conditionExprElement.getAttribute("env-name"));
+            this.envNameAcsr = FlexibleMapAccessor.getInstance(conditionExprElement.getAttribute("env-name"));
             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"));
@@ -309,10 +309,10 @@
         protected FlexibleMapAccessor<Object> fieldNameAcsr;
         
         public ConditionObject(Element conditionExprElement) {
-            this.fieldNameAcsr = new FlexibleMapAccessor<Object>(conditionExprElement.getAttribute("field-name"));
+            this.fieldNameAcsr = FlexibleMapAccessor.getInstance(conditionExprElement.getAttribute("field-name"));
             if (this.fieldNameAcsr.isEmpty()) {
                 // no "field-name"? try "name"
-                this.fieldNameAcsr = new FlexibleMapAccessor<Object>(conditionExprElement.getAttribute("name"));
+                this.fieldNameAcsr = FlexibleMapAccessor.getInstance(conditionExprElement.getAttribute("name"));
             }
         }
         

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=726260&r1=726259&r2=726260&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 Sat Dec 13 11:25:33 2008
@@ -78,7 +78,7 @@
         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.listAcsr = FlexibleMapAccessor.getInstance(element.getAttribute("list-name"));
         this.resultSetTypeExdr = FlexibleStringExpander.getInstance(element.getAttribute("result-set-type"));
 
         // process select-field

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=726260&r1=726259&r2=726260&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 Sat Dec 13 11:25:33 2008
@@ -51,8 +51,7 @@
 
     public PrimaryKeyFinder(Element entityOneElement) {
         super(entityOneElement);
-        if (UtilValidate.isNotEmpty(entityOneElement.getAttribute("value-name")))
-            this.valueNameAcsr = new FlexibleMapAccessor<Object>(entityOneElement.getAttribute("value-name"));
+        this.valueNameAcsr = FlexibleMapAccessor.getInstance(entityOneElement.getAttribute("value-name"));
         this.autoFieldMapExdr = FlexibleStringExpander.getInstance(entityOneElement.getAttribute("auto-field-map"));
 
         // process field-map
@@ -78,7 +77,7 @@
         
         //Debug.logInfo("PrimaryKeyFinder: valueOut=" + valueOut, module);
         //Debug.logInfo("PrimaryKeyFinder: going into=" + this.valueNameAcsr.getOriginalName(), module);
-        if (valueNameAcsr != null) {
+        if (!valueNameAcsr.isEmpty()) {
            this.valueNameAcsr.put(context, valueOut);
         } else {
            if (valueOut != null) {

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java?rev=726260&r1=726259&r2=726260&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java Sat Dec 13 11:25:33 2008
@@ -132,7 +132,7 @@
             this.type = setElement.getAttribute("type");
             this.toScope = setElement.getAttribute("to-scope");
             this.fromScope = setElement.getAttribute("from-scope");
-            if (!this.fromField.isEmpty() && this.valueExdr != null) {
+            if (!this.fromField.isEmpty() && !this.valueExdr.isEmpty()) {
                 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");
             }
         }
@@ -151,7 +151,7 @@
                     HttpSession session = (HttpSession)context.get("session");
                     newValue = session.getAttribute(newKey);
                     if (Debug.verboseOn()) Debug.logVerbose("In user getting value for field from [" + this.fromField.getOriginalName() + "]: " + newValue, module);
-                } else if (this.valueExdr != null) {
+                } else if (!this.valueExdr.isEmpty()) {
                     newValue = this.valueExdr.expandString(context);
                 }
                 
@@ -163,7 +163,7 @@
                     ServletContext servletContext = (ServletContext)context.get("application");
                     newValue = servletContext.getAttribute(newKey);
                     if (Debug.verboseOn()) Debug.logVerbose("In application getting value for field from [" + this.fromField.getOriginalName() + "]: " + newValue, module);
-                } else if (this.valueExdr != null) {
+                } else if (!this.valueExdr.isEmpty()) {
                     newValue = this.valueExdr.expandString(context);
                 }
                 
@@ -171,7 +171,7 @@
                 if (!this.fromField.isEmpty()) {
                     newValue = this.fromField.get(context);
                     if (Debug.verboseOn()) Debug.logVerbose("In screen getting value for field from [" + this.fromField.getOriginalName() + "]: " + newValue, module);
-                } else if (this.valueExdr != null) {
+                } else if (!this.valueExdr.isEmpty()) {
                     newValue = this.valueExdr.expandString(context);
                 }
             }