From f6eb3a10a799d93e701fbb0f689aa033d83d97a7 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 7 Mar 2007 03:53:53 +0000 Subject: [PATCH] * [ 1673714 ] String comparison using == is wrong contribution from Stefan Huehner --- .classpath | 1 + dbPort/src/org/compiere/util/AmtInWords_ES.java | 4 ++-- looks/src/org/compiere/swing/CComboBox.java | 2 +- print/src/org/compiere/print/layout/PrintElement.java | 2 +- .../src/main/servlet/org/compiere/www/WebField.java | 4 ++-- sqlj/src/org/compiere/sqlj/Adempiere.java | 2 +- sqlj/src/org/compiere/sqlj/Compiere.java | 2 +- .../src/main/servlet/org/compiere/cm/request/Request.java | 8 ++++---- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.classpath b/.classpath index 5830d5613a..b990791890 100644 --- a/.classpath +++ b/.classpath @@ -76,5 +76,6 @@ + diff --git a/dbPort/src/org/compiere/util/AmtInWords_ES.java b/dbPort/src/org/compiere/util/AmtInWords_ES.java index eb76646025..7fd25cdcf7 100644 --- a/dbPort/src/org/compiere/util/AmtInWords_ES.java +++ b/dbPort/src/org/compiere/util/AmtInWords_ES.java @@ -97,7 +97,7 @@ public class AmtInWords_ES implements AmtInWords soFar = numNames[number % 10]; number /= 10; String s = Integer.toString (number); - if (s.endsWith ("2") && soFar != "") + if (s.endsWith ("2") && !soFar.equals("")) soFar = " VEINTI" + soFar.trim (); else if (soFar.equals("")) soFar = tensNames[number % 10] + soFar; @@ -112,7 +112,7 @@ public class AmtInWords_ES implements AmtInWords // End e-Evolution ogi-cd if (number > 1) soFar = "S" + soFar; - if (number == 1 && soFar != "") + if (number == 1 && !soFar.equals("")) number = 0; return numNames[number] + " CIENTO" + soFar; } // convertLessThanOneThousand diff --git a/looks/src/org/compiere/swing/CComboBox.java b/looks/src/org/compiere/swing/CComboBox.java index c28f7ccbe6..7c05bf59e4 100644 --- a/looks/src/org/compiere/swing/CComboBox.java +++ b/looks/src/org/compiere/swing/CComboBox.java @@ -78,7 +78,7 @@ public class CComboBox extends JComboBox public CComboBox(final Object items[], String key) { this(items); - if (key.equals(null)) + if (key == null) return; for (int i = 0; i < 0; i++) { diff --git a/print/src/org/compiere/print/layout/PrintElement.java b/print/src/org/compiere/print/layout/PrintElement.java index 55847f27bc..1465b5d620 100644 --- a/print/src/org/compiere/print/layout/PrintElement.java +++ b/print/src/org/compiere/print/layout/PrintElement.java @@ -126,7 +126,7 @@ public abstract class PrintElement implements ImageObserver p_maxWidth = maxWidth; // p_FieldAlignmentType = FieldAlignmentType; - if (p_FieldAlignmentType.equals(null) || p_FieldAlignmentType.equals(MPrintFormatItem.FIELDALIGNMENTTYPE_Default)) + if (p_FieldAlignmentType == null || p_FieldAlignmentType.equals(MPrintFormatItem.FIELDALIGNMENTTYPE_Default)) p_FieldAlignmentType = MPrintFormatItem.FIELDALIGNMENTTYPE_LeadingLeft; // p_sizeCalculated = calculateSize(); diff --git a/serverApps/src/main/servlet/org/compiere/www/WebField.java b/serverApps/src/main/servlet/org/compiere/www/WebField.java index a312be8299..e97835c28c 100644 --- a/serverApps/src/main/servlet/org/compiere/www/WebField.java +++ b/serverApps/src/main/servlet/org/compiere/www/WebField.java @@ -446,10 +446,10 @@ public class WebField { ValueNamePair p = (ValueNamePair)list[i]; key = p.getValue(); - if (key.equals(null) || key.length() == 0) + if (key == null || key.length() == 0) key = "??"; String name = p.getName(); - if (name.equals(null) || name.length() == 0) + if (name == null || name.length() == 0) name = "???"; name = Util.maskHTML(name); options[i] = new option(key).addElement(name); diff --git a/sqlj/src/org/compiere/sqlj/Adempiere.java b/sqlj/src/org/compiere/sqlj/Adempiere.java index 1b0feae738..61ee482831 100644 --- a/sqlj/src/org/compiere/sqlj/Adempiere.java +++ b/sqlj/src/org/compiere/sqlj/Adempiere.java @@ -66,7 +66,7 @@ public class Adempiere implements Serializable */ public static String getProperty (String key) throws SQLException { - if (key .equals(null) || key.length() == 0) + if (key == null || key.length() == 0) return "null"; return System.getProperty(key, "NotFound"); } // environment diff --git a/sqlj/src/org/compiere/sqlj/Compiere.java b/sqlj/src/org/compiere/sqlj/Compiere.java index 3994526a33..d67efe59f6 100755 --- a/sqlj/src/org/compiere/sqlj/Compiere.java +++ b/sqlj/src/org/compiere/sqlj/Compiere.java @@ -66,7 +66,7 @@ public class Compiere implements Serializable */ public static String getProperty (String key) throws SQLException { - if (key.equals(null) || key.length() == 0) + if (key == null || key.length() == 0) return "null"; return System.getProperty(key, "NotFound"); } // environment diff --git a/webCM/src/main/servlet/org/compiere/cm/request/Request.java b/webCM/src/main/servlet/org/compiere/cm/request/Request.java index a9eb5db0a2..cc3b3d2075 100644 --- a/webCM/src/main/servlet/org/compiere/cm/request/Request.java +++ b/webCM/src/main/servlet/org/compiere/cm/request/Request.java @@ -325,7 +325,7 @@ public class Request { private static String getParameterAsString(HttpServletRequest request, String parameterName) { String l_szReturn = new String(""); - if (!request.getParameter(parameterName).equals(null) && !request.getParameter(parameterName).equals("")) { + if (request.getParameter(parameterName) != null && !request.getParameter(parameterName).equals("")) { l_szReturn = request.getParameter(parameterName).toString(); l_szReturn = l_szReturn.replace("\r",""); l_szReturn = l_szReturn.replace("\n",""); @@ -343,7 +343,7 @@ public class Request { private static int getParameterAsInt(HttpServletRequest request, String parameterName) { int l_nID = 0; - if (!request.getParameter(parameterName).equals(null) && !request.getParameter(parameterName).equals("")) { + if (request.getParameter(parameterName) != null && !request.getParameter(parameterName).equals("")) { try { l_nID = Integer.parseInt(request.getParameter(parameterName)); } catch (Exception e) { @@ -363,7 +363,7 @@ public class Request { private static BigDecimal getParameterAsBD(HttpServletRequest request, String parameterName) { BigDecimal l_bdValue = new BigDecimal(0); - if (!request.getParameter(parameterName).equals(null) && !request.getParameter(parameterName).equals("")) { + if (request.getParameter(parameterName) != null && !request.getParameter(parameterName).equals("")) { try { String l_szValue = request.getParameter(parameterName); l_szValue = l_szValue.replace(",", "."); @@ -404,7 +404,7 @@ public class Request { SimpleDateFormat ger = new SimpleDateFormat("dd.MM.yyyy"); long time = 0; - if (!request.getParameter(parameterName).equals(null) && !request.getParameter(parameterName).equals("")) { + if (request.getParameter(parameterName) != null && !request.getParameter(parameterName).equals("")) { try { myDate = ger.parse(request.getParameter(parameterName).toString()); time = myDate.getTime();