svn commit: r949615 - in /ofbiz/trunk/framework/entity/src/org/ofbiz/entity: datasource/GenericDAO.java model/ModelEntity.java

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

svn commit: r949615 - in /ofbiz/trunk/framework/entity/src/org/ofbiz/entity: datasource/GenericDAO.java model/ModelEntity.java

doogie-3
Author: doogie
Date: Sun May 30 22:07:44 2010
New Revision: 949615

URL: http://svn.apache.org/viewvc?rev=949615&view=rev
Log:
Add new variants of fieldsStringList that take a StringBuilder, and deprecate the old versions that don't.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java?rev=949615&r1=949614&r2=949615&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java Sun May 30 22:07:44 2010
@@ -163,7 +163,7 @@ public class GenericDAO {
 
         modelEntity.colNameString(fieldsToSave, sqlB, "");
         sqlB.append(") VALUES (");
-        sqlB.append(modelEntity.fieldsStringList(fieldsToSave, "?", ", "));
+        modelEntity.fieldsStringList(fieldsToSave, sqlB, "?", ", ");
         String sql = sqlB.append(")").toString();
 
         try {

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java?rev=949615&r1=949614&r2=949615&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java Sun May 30 22:07:44 2010
@@ -847,42 +847,70 @@ public class ModelEntity extends ModelIn
         return fieldsStringList(fields, "null", ", ", false, true);
     }
 
+    @Deprecated
     public String fieldsStringList(String eachString, String separator, ModelField... flds) {
         return fieldsStringList(Arrays.asList(flds), eachString, separator, false, false);
     }
 
+    public StringBuilder fieldsStringList(StringBuilder sb, String eachString, String separator, ModelField... flds) {
+        return fieldsStringList(Arrays.asList(flds), sb, eachString, separator, false, false);
+    }
+
+    @Deprecated
     public String fieldsStringList(List<ModelField> flds, String eachString, String separator) {
         return fieldsStringList(flds, eachString, separator, false, false);
     }
 
+    public StringBuilder fieldsStringList(List<ModelField> flds, StringBuilder sb, String eachString, String separator) {
+        return fieldsStringList(flds, sb, eachString, separator, false, false);
+    }
+
+    @Deprecated
     public String fieldsStringList(String eachString, String separator, boolean appendIndex, ModelField... flds) {
         return fieldsStringList(Arrays.asList(flds), eachString, separator, appendIndex, false);
     }
 
+    public StringBuilder fieldsStringList(StringBuilder sb, String eachString, String separator, boolean appendIndex, ModelField... flds) {
+        return fieldsStringList(Arrays.asList(flds), sb, eachString, separator, appendIndex, false);
+    }
+
+    @Deprecated
     public String fieldsStringList(List<ModelField> flds, String eachString, String separator, boolean appendIndex) {
         return fieldsStringList(flds, eachString, separator, appendIndex, false);
     }
 
+    public StringBuilder fieldsStringList(List<ModelField> flds, StringBuilder sb, String eachString, String separator, boolean appendIndex) {
+        return fieldsStringList(flds, sb, eachString, separator, appendIndex, false);
+    }
+
+    @Deprecated
     public String fieldsStringList(String eachString, String separator, boolean appendIndex, boolean onlyNonPK, ModelField... flds) {
         return fieldsStringList(Arrays.asList(flds), eachString, separator, appendIndex, onlyNonPK);
     }
 
+    public StringBuilder fieldsStringList(StringBuilder sb, String eachString, String separator, boolean appendIndex, boolean onlyNonPK, ModelField... flds) {
+        return fieldsStringList(Arrays.asList(flds), sb, eachString, separator, appendIndex, onlyNonPK);
+    }
+
+    @Deprecated
     public String fieldsStringList(List<ModelField> flds, String eachString, String separator, boolean appendIndex, boolean onlyNonPK) {
-        StringBuilder returnString = new StringBuilder();
+        return fieldsStringList(flds, new StringBuilder(), eachString, separator, appendIndex, onlyNonPK).toString();
+    }
 
+    public StringBuilder fieldsStringList(List<ModelField> flds, StringBuilder sb, String eachString, String separator, boolean appendIndex, boolean onlyNonPK) {
         if (flds.size() < 1) {
-            return "";
+            return sb;
         }
 
         int i = 0;
 
         for (; i < flds.size(); i++) {
             if (onlyNonPK && flds.get(i).isPk) continue;
-            returnString.append(eachString);
-            if (appendIndex) returnString.append(i + 1);
-            if (i < flds.size() - 1) returnString.append(separator);
+            sb.append(eachString);
+            if (appendIndex) sb.append(i + 1);
+            if (i < flds.size() - 1) sb.append(separator);
         }
-        return returnString.toString();
+        return sb;
     }
 
     @Deprecated