svn commit: r1859927 - in /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util: StringUtil.java test/StringUtilTests.java

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

svn commit: r1859927 - in /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util: StringUtil.java test/StringUtilTests.java

mthl
Author: mthl
Date: Sat May 25 09:21:53 2019
New Revision: 1859927

URL: http://svn.apache.org/viewvc?rev=1859927&view=rev
Log:
Improved: Remove unused ‘StringUtil#convertChar’ method
(OFBIZ-11014)

Modified:
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/test/StringUtilTests.java

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java?rev=1859927&r1=1859926&r2=1859927&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java Sat May 25 09:21:53 2019
@@ -347,18 +347,6 @@ public class StringUtil {
     }
 
     private static char[] hexChar = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
-    public static int convertChar(char c) {
-        if ('0' <= c && c <= '9') {
-            return c - '0' ;
-        } else if ('a' <= c && c <= 'f') {
-            return c - 'a' + 0xa ;
-        } else if ('A' <= c && c <= 'F') {
-            return c - 'A' + 0xa ;
-        } else {
-            throw new IllegalArgumentException("Invalid hex character: [" + c + "]");
-        }
-    }
-
     public static char[] encodeInt(int i, int j, char digestChars[]) {
         if (i < 16) {
             digestChars[j] = '0';

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/test/StringUtilTests.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/test/StringUtilTests.java?rev=1859927&r1=1859926&r2=1859927&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/test/StringUtilTests.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/test/StringUtilTests.java Sat May 25 09:21:53 2019
@@ -20,9 +20,7 @@ package org.apache.ofbiz.base.util.test;
 
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.ofbiz.base.lang.Appender;
 import org.apache.ofbiz.base.lang.SourceMonitored;
@@ -186,32 +184,6 @@ public class StringUtilTests extends Gen
         }
     }
 
-    public void testConvertChar() {
-        Map<Character, Integer> conversions = new HashMap<>();
-        conversions.put('0', 0); conversions.put('1', 1); conversions.put('2', 2); conversions.put('3', 3);
-        conversions.put('4', 4); conversions.put('5', 5); conversions.put('6', 6); conversions.put('7', 7);
-        conversions.put('8', 8); conversions.put('9', 9);
-        conversions.put('a', 10); conversions.put('b', 11); conversions.put('c', 12);
-        conversions.put('d', 13); conversions.put('e', 14); conversions.put('f', 15);
-        conversions.put('A', 10); conversions.put('B', 11); conversions.put('C', 12);
-        conversions.put('D', 13); conversions.put('E', 14); conversions.put('F', 15);
-        for (int i = 0; i < 256; i++) {
-            Integer wanted = conversions.get((char) i);
-            if (wanted == null) {
-                Exception caught = null;
-                try {
-                    StringUtil.convertChar((char) i);
-                } catch (Exception e) {
-                    caught = e;
-                } finally {
-                    assertNotNull(Integer.toString(i), caught);
-                }
-            } else {
-                assertEquals(Integer.toString(i), wanted.intValue(), StringUtil.convertChar((char) i));
-            }
-        }
-    }
-
     public void testEncodeInt() {
         assertEquals("one octet", new char[] {'0', '5'}, StringUtil.encodeInt(5, 0, new char[2]));
         assertEquals("two octets", new char[] {'1', '5'}, StringUtil.encodeInt(21, 0, new char[2]));