You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by ke...@apache.org on 2007/11/08 05:49:35 UTC

svn commit: r593010 - /ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/util/StringUtils.java

Author: kevj
Date: Wed Nov  7 20:49:35 2007
New Revision: 593010

URL: http://svn.apache.org/viewvc?rev=593010&view=rev
Log:
-merge removeSuffix/removePrefix (useful for Rmic fixes from trunk)

Modified:
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/util/StringUtils.java

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/util/StringUtils.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/util/StringUtils.java?rev=593010&r1=593009&r2=593010&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/util/StringUtils.java (original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/util/StringUtils.java Wed Nov  7 20:49:35 2007
@@ -241,4 +241,36 @@
         }
         return factor * Long.parseLong(humanSize);
     }
+    
+    /**
+     * Removes the suffix from a given string, if the string contains
+     * that suffix.
+     * @param string String for check
+     * @param suffix Suffix to remove
+     * @return the <i>string</i> with the <i>suffix</i>
+     * @since Ant 1.7.1
+     */
+    public static String removeSuffix(String string, String suffix) {
+        if (string.endsWith(suffix)) {
+            return string.substring(0, string.length() - suffix.length());
+        } else {
+            return string;
+        }
+    }
+
+    /**
+     * Removes the prefix from a given string, if the string contains
+     * that prefix.
+     * @param string String for check
+     * @param prefix Prefix to remove
+     * @return the <i>string</i> with the <i>prefix</i>
+     * @since Ant 1.7.1
+     */
+    public static String removePrefix(String string, String prefix) {
+        if (string.startsWith(prefix)) {
+            return string.substring(prefix.length());
+        } else {
+            return string;
+        }
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org