This is an automated email from the ASF dual-hosted git repository. jleroux pushed a commit to branch release22.01 in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
commit 5ec3789ce1f99622a0373d51d7ad0faf3a09b21d Author: Jacques Le Roux <jacques.le.r...@les7arts.com> AuthorDate: Fri May 19 09:51:58 2023 +0200 Fixed: Reducing scope of variables in common and base packages (OFBIZ-10477) (OFBIZ-10478) Following https://lists.apache.org/thread/g1z92gtlf9p1rxlc247yg2zqd6bczq7s conversation, this fixes SAFE util methods being transformed to private when obviously they should be public Thanks: Michael for spotting, reporting and confirming it's OK # Conflicts: # framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java # framework/base/src/main/java/org/apache/ofbiz/base/util/UtilFormatOut.java --- .../src/main/java/org/apache/ofbiz/base/util/StringUtil.java | 10 +++++++++- .../main/java/org/apache/ofbiz/base/util/UtilFormatOut.java | 3 ++- .../src/main/java/org/apache/ofbiz/base/util/UtilNumber.java | 2 +- .../src/main/java/org/apache/ofbiz/base/util/UtilValidate.java | 8 ++++---- .../src/main/java/org/apache/ofbiz/common/geo/GeoWorker.java | 7 ++++--- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java index 15a6bc7fec..29de6eae72 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java @@ -156,7 +156,7 @@ public final class StringUtil { * and want to replace "=" to avoid clashes with parameters values in a not encoded URL, default to "=" * @return a Map of name/value pairs */ - private static Map<String, String> strToMap(String str, String delim, boolean trim, String pairsSeparator) { + public static Map<String, String> strToMap(String str, String delim, boolean trim, String pairsSeparator) { if (UtilValidate.isEmpty(str)) { return null; } @@ -435,5 +435,13 @@ public final class StringUtil { public String toString() { return this.theString; } + + /** + * @return true, if wrapped string is null or empty; false otherwise + */ + @Override + public boolean isEmpty() { + return (theString == null || theString.isEmpty()); + } } } diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilFormatOut.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilFormatOut.java index 87149fd486..e769f74abf 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilFormatOut.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilFormatOut.java @@ -26,10 +26,11 @@ import java.util.Date; import java.util.Locale; import java.util.TimeZone; -import com.ibm.icu.text.DecimalFormat; import org.apache.ofbiz.entity.Delegator; import org.apache.ofbiz.entity.util.EntityUtilProperties; +import com.ibm.icu.text.DecimalFormat; + /** * General output formatting functions - mainly for helping in JSPs */ diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java index 922ce65c21..0eac51b432 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java @@ -23,9 +23,9 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.util.HashMap; import java.util.Locale; +import java.util.Map; import com.ibm.icu.text.RuleBasedNumberFormat; -import java.util.Map; public final class UtilNumber { diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java index 8117565c87..271e33f0b5 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java @@ -270,7 +270,7 @@ public final class UtilValidate { * first character is allowed to be + or - as well. * Does not accept floating point, exponential notation, etc. */ - private static boolean isSignedInteger(String s) { + public static boolean isSignedInteger(String s) { if (isEmpty(s)) { return DEFAULT_EMPTY_OK; } @@ -1130,7 +1130,7 @@ public final class UtilValidate { * @param cc - a string representing a credit card number; Sample number: 6331100000000096 (16 digits) * @return true, if the credit card number is a valid Solo card number, false otherwise */ - private static boolean isSolo(String cc) { + public static boolean isSolo(String cc) { String first4digs = cc.substring(0, 4); String first2digs = cc.substring(0, 2); if (((cc.length() == 16) || (cc.length() == 18) || (cc.length() == 19)) && ("63".equals(first2digs) || "6767".equals(first4digs))) { @@ -1143,7 +1143,7 @@ public final class UtilValidate { * @param cc - a string representing a credit card number; Sample number: 4175000000000001(16 digits) * @return true, if the credit card number is a valid Visa Electron card number, false otherwise */ - private static boolean isVisaElectron(String cc) { + public static boolean isVisaElectron(String cc) { String first6digs = cc.substring(0, 6); String first4digs = cc.substring(0, 4); @@ -1311,7 +1311,7 @@ public final class UtilValidate { return isValidPhoneNumber(phoneNumber, geoId, delegator); } - private static boolean isValidPhoneNumber(String phoneNumber, String geoId, Delegator delegator) { + public static boolean isValidPhoneNumber(String phoneNumber, String geoId, Delegator delegator) { boolean isValid = false; try { GenericValue geo = EntityQuery.use(delegator).from("Geo").where("geoId", geoId).cache().queryOne(); diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/geo/GeoWorker.java b/framework/common/src/main/java/org/apache/ofbiz/common/geo/GeoWorker.java index bba5a49cc0..7b82a4737e 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/geo/GeoWorker.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/geo/GeoWorker.java @@ -21,11 +21,9 @@ package org.apache.ofbiz.common.geo; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; -import java.util.Map; import java.util.Locale; +import java.util.Map; -import com.ibm.icu.util.LocaleData; -import com.ibm.icu.util.ULocale; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.UtilMisc; import org.apache.ofbiz.base.util.UtilValidate; @@ -35,6 +33,9 @@ import org.apache.ofbiz.entity.GenericValue; import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.entity.util.EntityUtil; +import com.ibm.icu.util.LocaleData; +import com.ibm.icu.util.ULocale; + /** * Worker methods for Geos */