You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/12/02 13:38:19 UTC

(commons-validator) branch master updated: Use Java 5 API

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-validator.git


The following commit(s) were added to refs/heads/master by this push:
     new 7ce4d97f Use Java 5 API
7ce4d97f is described below

commit 7ce4d97f913e48675cf568612beba82ca1495ee3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 2 08:38:15 2023 -0500

    Use Java 5 API
---
 .../commons/validator/util/ValidatorUtils.java     | 27 +---------------------
 1 file changed, 1 insertion(+), 26 deletions(-)

diff --git a/src/main/java/org/apache/commons/validator/util/ValidatorUtils.java b/src/main/java/org/apache/commons/validator/util/ValidatorUtils.java
index bf575824..b0fad437 100644
--- a/src/main/java/org/apache/commons/validator/util/ValidatorUtils.java
+++ b/src/main/java/org/apache/commons/validator/util/ValidatorUtils.java
@@ -146,35 +146,10 @@ public class ValidatorUtils {
      * @return The modified value.
      */
     public static String replace(String value, final String key, final String replaceValue) {
-
         if (value == null || key == null || replaceValue == null) {
             return value;
         }
-
-        final int pos = value.indexOf(key);
-
-        if (pos < 0) {
-            return value;
-        }
-
-        final int length = value.length();
-        final int start = pos;
-        final int end = pos + key.length();
-
-        if (length == key.length()) {
-            value = replaceValue;
-
-        } else if (end == length) {
-            value = value.substring(0, start) + replaceValue;
-
-        } else {
-            value =
-                    value.substring(0, start)
-                    + replaceValue
-                    + replace(value.substring(end), key, replaceValue);
-        }
-
-        return value;
+        return value.replace(key, replaceValue);
     }
 
 }