You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by de...@apache.org on 2017/10/16 08:25:34 UTC

svn commit: r1812257 - in /ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity: ./ datasource/ jdbc/ model/ serialize/ test/ util/

Author: deepak
Date: Mon Oct 16 08:25:33 2017
New Revision: 1812257

URL: http://svn.apache.org/viewvc?rev=1812257&view=rev
Log:
Inconsistent String Comparisons, Applied patch for framework entity classes.
Thanks Devanshu Vyas for your contribution (OFBIZ-9254)

Modified:
    ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericEntity.java
    ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/datasource/GenericDAO.java
    ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/CursorConnection.java
    ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelUtil.java
    ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/serialize/XmlSerializer.java
    ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityTestSuite.java
    ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntitySaxReader.java

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericEntity.java?rev=1812257&r1=1812256&r2=1812257&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericEntity.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericEntity.java Mon Oct 16 08:25:33 2017
@@ -1143,7 +1143,7 @@ public class GenericEntity implements Ma
             String name = modelField.getName();
 
             String type = modelField.getType();
-            if (type != null && type.equals("blob")) {
+            if (type != null && "blob".equals(type)) {
                 Object obj = get(name);
                 boolean b1 = obj instanceof byte [];
                 if (b1) {

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/datasource/GenericDAO.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/datasource/GenericDAO.java?rev=1812257&r1=1812256&r2=1812257&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/datasource/GenericDAO.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/datasource/GenericDAO.java Mon Oct 16 08:25:33 2017
@@ -856,7 +856,7 @@ public class GenericDAO {
 
     protected StringBuilder makeOffsetString(StringBuilder offsetString, EntityFindOptions findOptions) {
         if (UtilValidate.isNotEmpty(datasource.getOffsetStyle())) {
-            if (datasource.getOffsetStyle().equals("limit")) {
+            if ("limit".equals(datasource.getOffsetStyle())) {
                 // use the LIMIT/OFFSET style
                 if (findOptions.getLimit() > -1) {
                     offsetString.append(" LIMIT " + findOptions.getLimit());
@@ -864,7 +864,7 @@ public class GenericDAO {
                         offsetString.append(" OFFSET " + findOptions.getOffset());
                     }
                 }
-            } else if (datasource.getOffsetStyle().equals("fetch")) {
+            } else if ("fetch".equals(datasource.getOffsetStyle())) {
                 // use SQL2008 OFFSET/FETCH style by default
                 if (findOptions.getOffset() > -1) {
                     offsetString.append(" OFFSET ").append(findOptions.getOffset()).append(" ROWS");

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/CursorConnection.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/CursorConnection.java?rev=1812257&r1=1812256&r2=1812257&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/CursorConnection.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/CursorConnection.java Mon Oct 16 08:25:33 2017
@@ -38,12 +38,12 @@ public class CursorConnection extends Ab
     }
 
     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-        if (method.getName().equals("prepareStatement")) {
+        if ("prepareStatement".equals(method.getName())) {
             System.err.println("prepareStatement");
             args[0] = "DECLARE " + cursorName + " CURSOR FOR " + args[0];
             PreparedStatement pstmt = (PreparedStatement) method.invoke(con, args);
             return CursorStatement.newCursorPreparedStatement(pstmt, cursorName, fetchSize);
-        } else if (method.getName().equals("createStatement")) {
+        } else if ("createStatement".equals(method.getName())) {
             System.err.println("createStatement");
             Statement stmt = (Statement) method.invoke(con, args);
             return CursorStatement.newCursorStatement(stmt, cursorName, fetchSize);

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelUtil.java?rev=1812257&r1=1812256&r2=1812257&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelUtil.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelUtil.java Mon Oct 16 08:25:33 2017
@@ -271,29 +271,29 @@ public final class ModelUtil {
     public static String induceFieldType(String sqlTypeName, int length, int precision, ModelFieldTypeReader fieldTypeReader) {
         if (sqlTypeName == null) return "invalid";
 
-        if (sqlTypeName.equalsIgnoreCase("VARCHAR") || sqlTypeName.equalsIgnoreCase("VARCHAR2") || (sqlTypeName.equalsIgnoreCase("CHAR") && length > 1)) {
+        if ("VARCHAR".equalsIgnoreCase(sqlTypeName) || "VARCHAR2".equalsIgnoreCase(sqlTypeName) || ("CHAR".equalsIgnoreCase(sqlTypeName) && length > 1)) {
             if (length <= 10) return "very-short";
             if (length <= 60) return "short-varchar";
             if (length <= 255) return "long-varchar";
             return "very-long";
-        } else if (sqlTypeName.equalsIgnoreCase("TEXT")) {
+        } else if ("TEXT".equalsIgnoreCase(sqlTypeName)) {
             return "very-long";
-        } else if (sqlTypeName.equalsIgnoreCase("INT") || sqlTypeName.equalsIgnoreCase("SMALLINT") ||
-                sqlTypeName.equalsIgnoreCase("DECIMAL") || sqlTypeName.equalsIgnoreCase("NUMERIC")) {
+        } else if ("INT".equalsIgnoreCase(sqlTypeName) || "SMALLINT".equalsIgnoreCase(sqlTypeName) ||
+                "DECIMAL".equalsIgnoreCase(sqlTypeName) || "NUMERIC".equalsIgnoreCase(sqlTypeName)) {
             if (length > 18 || precision > 6) return "invalid-" + sqlTypeName + ":" + length + ":" + precision;
             if (precision == 0) return "numeric";
             if (precision == 2) return "currency-amount";
             if (precision <= 6) return "floating-point";
             return "invalid-" + sqlTypeName + ":" + length + ":" + precision;
-        } else if (sqlTypeName.equalsIgnoreCase("BLOB") || sqlTypeName.equalsIgnoreCase("OID")) {
+        } else if ("BLOB".equalsIgnoreCase(sqlTypeName) || "OID".equalsIgnoreCase(sqlTypeName)) {
             return "blob";
-        } else if (sqlTypeName.equalsIgnoreCase("DATETIME") || sqlTypeName.equalsIgnoreCase("TIMESTAMP")) {
+        } else if ("DATETIME".equalsIgnoreCase(sqlTypeName) || "TIMESTAMP".equalsIgnoreCase(sqlTypeName)) {
             return "date-time";
-        } else if (sqlTypeName.equalsIgnoreCase("DATE")) {
+        } else if ("DATE".equalsIgnoreCase(sqlTypeName)) {
             return "date";
-        } else if (sqlTypeName.equalsIgnoreCase("TIME")) {
+        } else if ("TIME".equalsIgnoreCase(sqlTypeName)) {
             return "time";
-        } else if (sqlTypeName.equalsIgnoreCase("CHAR") && length == 1) {
+        } else if ("CHAR".equalsIgnoreCase(sqlTypeName) && length == 1) {
             return "indicator";
         } else {
             return "invalid-" + sqlTypeName + ":" + length + ":" + precision;

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/serialize/XmlSerializer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/serialize/XmlSerializer.java?rev=1812257&r1=1812256&r2=1812257&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/serialize/XmlSerializer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/serialize/XmlSerializer.java Mon Oct 16 08:25:33 2017
@@ -293,7 +293,7 @@ public class XmlSerializer {
     public static Object deserializeSingle(Element element, Delegator delegator) throws SerializeException {
         String tagName = element.getLocalName();
 
-        if (tagName.equals("null")) return null;
+        if ("null".equals(tagName)) return null;
 
         if (tagName.startsWith("std-")) {
             // - Standard Objects -

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityTestSuite.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityTestSuite.java?rev=1812257&r1=1812256&r2=1812257&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityTestSuite.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityTestSuite.java Mon Oct 16 08:25:33 2017
@@ -953,7 +953,7 @@ public class EntityTestSuite extends Ent
     /*public void testLimitOffsetOptions() throws Exception {
         String entityName = "Content";
         Datasource datasourceInfo = EntityConfig.getDatasource(delegator.getEntityHelper(entityName).getHelperName());
-        if (UtilValidate.isEmpty(datasourceInfo.offsetStyle) || datasourceInfo.offsetStyle.equals("none")) {
+        if (UtilValidate.isEmpty(datasourceInfo.offsetStyle) || "none".equals(datasourceInfo.offsetStyle)) {
             Debug.logInfo("The offset-stype configured in datasource is " + datasourceInfo.offsetStyle +  ", this test is skipped.", module);
             return;
         } else {

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntitySaxReader.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntitySaxReader.java?rev=1812257&r1=1812256&r2=1812257&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntitySaxReader.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntitySaxReader.java Mon Oct 16 08:25:33 2017
@@ -374,7 +374,7 @@ public class EntitySaxReader extends Def
                         ModelEntity modelEntity = currentValue.getModelEntity();
                         ModelField modelField = modelEntity.getField(currentFieldName.toString());
                         String type = modelField.getType();
-                        if (type != null && type.equals("blob")) {
+                        if (type != null && "blob".equals(type)) {
                             byte[] binData = Base64.base64Decode((new String(currentFieldValue)).getBytes());
                             currentValue.setBytes(currentFieldName.toString(), binData);
                         } else {