svn commit: r1751296 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java

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

svn commit: r1751296 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java

Arun Patidar-4
Author: arunpatidar
Date: Mon Jul  4 14:36:44 2016
New Revision: 1751296

URL: http://svn.apache.org/viewvc?rev=1751296&view=rev
Log:
Applied patch from jira issue - OFBIZ-7715 - Enforce noninstantiability to SqlJdbcUtil class. Thanks Rishi solanki and Rohit Koushal for your contribution.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java?rev=1751296&r1=1751295&r2=1751296&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java Mon Jul  4 14:36:44 2016
@@ -68,11 +68,55 @@ import org.ofbiz.entity.model.ModelViewE
  * GenericDAO Utility methods for general tasks
  *
  */
-public class SqlJdbcUtil {
+public final class SqlJdbcUtil {
     public static final String module = SqlJdbcUtil.class.getName();
 
-    public static final int CHAR_BUFFER_SIZE = 4096;
+    private static final int CHAR_BUFFER_SIZE = 4096;
+    private static Map<String, Integer> fieldTypeMap = new HashMap<String, Integer>();
+    static {
+        fieldTypeMap.put("java.lang.String", 1);
+        fieldTypeMap.put("String", 1);
+        fieldTypeMap.put("java.sql.Timestamp", 2);
+        fieldTypeMap.put("Timestamp", 2);
+        fieldTypeMap.put("java.sql.Time", 3);
+        fieldTypeMap.put("Time", 3);
+        fieldTypeMap.put("java.sql.Date", 4);
+        fieldTypeMap.put("Date", 4);
+        fieldTypeMap.put("java.lang.Integer", 5);
+        fieldTypeMap.put("Integer", 5);
+        fieldTypeMap.put("java.lang.Long", 6);
+        fieldTypeMap.put("Long", 6);
+        fieldTypeMap.put("java.lang.Float", 7);
+        fieldTypeMap.put("Float", 7);
+        fieldTypeMap.put("java.lang.Double", 8);
+        fieldTypeMap.put("Double", 8);
+        fieldTypeMap.put("java.math.BigDecimal", 9);
+        fieldTypeMap.put("BigDecimal", 9);
+        fieldTypeMap.put("java.lang.Boolean", 10);
+        fieldTypeMap.put("Boolean", 10);
 
+        fieldTypeMap.put("java.lang.Object", 11);
+        fieldTypeMap.put("Object", 11);
+
+        fieldTypeMap.put("java.sql.Blob", 12);
+        fieldTypeMap.put("Blob", 12);
+        fieldTypeMap.put("byte[]", 12);
+        fieldTypeMap.put("java.nio.ByteBuffer", 12);
+        fieldTypeMap.put("java.nio.HeapByteBuffer", 12);
+
+        fieldTypeMap.put("java.sql.Clob", 13);
+        fieldTypeMap.put("Clob", 13);
+
+        fieldTypeMap.put("java.util.Date", 14);
+
+        // all of these treated as Collection
+        fieldTypeMap.put("java.util.ArrayList", 15);
+        fieldTypeMap.put("java.util.HashSet", 15);
+        fieldTypeMap.put("java.util.LinkedHashSet", 15);
+        fieldTypeMap.put("java.util.LinkedList", 15);
+    }
+
+    private SqlJdbcUtil () {}
     /** Makes the FROM clause and when necessary the JOIN clause(s) as well */
     public static String makeFromClause(ModelEntity modelEntity, ModelFieldTypeReader modelFieldTypeReader, Datasource datasourceInfo) throws GenericEntityException {
         StringBuilder sql = new StringBuilder(" FROM ");
@@ -913,50 +957,6 @@ public class SqlJdbcUtil {
         }
     }
 
-    protected static Map<String, Integer> fieldTypeMap = new HashMap<String, Integer>();
-    static {
-        fieldTypeMap.put("java.lang.String", 1);
-        fieldTypeMap.put("String", 1);
-        fieldTypeMap.put("java.sql.Timestamp", 2);
-        fieldTypeMap.put("Timestamp", 2);
-        fieldTypeMap.put("java.sql.Time", 3);
-        fieldTypeMap.put("Time", 3);
-        fieldTypeMap.put("java.sql.Date", 4);
-        fieldTypeMap.put("Date", 4);
-        fieldTypeMap.put("java.lang.Integer", 5);
-        fieldTypeMap.put("Integer", 5);
-        fieldTypeMap.put("java.lang.Long", 6);
-        fieldTypeMap.put("Long", 6);
-        fieldTypeMap.put("java.lang.Float", 7);
-        fieldTypeMap.put("Float", 7);
-        fieldTypeMap.put("java.lang.Double", 8);
-        fieldTypeMap.put("Double", 8);
-        fieldTypeMap.put("java.math.BigDecimal", 9);
-        fieldTypeMap.put("BigDecimal", 9);
-        fieldTypeMap.put("java.lang.Boolean", 10);
-        fieldTypeMap.put("Boolean", 10);
-
-        fieldTypeMap.put("java.lang.Object", 11);
-        fieldTypeMap.put("Object", 11);
-
-        fieldTypeMap.put("java.sql.Blob", 12);
-        fieldTypeMap.put("Blob", 12);
-        fieldTypeMap.put("byte[]", 12);
-        fieldTypeMap.put("java.nio.ByteBuffer", 12);
-        fieldTypeMap.put("java.nio.HeapByteBuffer", 12);
-
-        fieldTypeMap.put("java.sql.Clob", 13);
-        fieldTypeMap.put("Clob", 13);
-
-        fieldTypeMap.put("java.util.Date", 14);
-
-        // all of these treated as Collection
-        fieldTypeMap.put("java.util.ArrayList", 15);
-        fieldTypeMap.put("java.util.HashSet", 15);
-        fieldTypeMap.put("java.util.LinkedHashSet", 15);
-        fieldTypeMap.put("java.util.LinkedList", 15);
-    }
-
     public static int getType(String fieldType) throws GenericNotImplementedException {
         Integer val = fieldTypeMap.get(fieldType);