commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fred...@apache.org
Subject cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java
Date Tue, 04 Nov 2003 21:00:22 GMT
fredrik     2003/11/04 13:00:22

  Modified:    lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Using StringUtils.isEmpty() when testing Strings.
  Renamed the parameter string to the more commonly used str in removeStart() and removeEnd.
  
  Revision  Changes    Path
  1.117     +15 -15    jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.116
  retrieving revision 1.117
  diff -u -r1.116 -r1.117
  --- StringUtils.java	3 Nov 2003 03:48:59 -0000	1.116
  +++ StringUtils.java	4 Nov 2003 21:00:22 -0000	1.117
  @@ -1114,7 +1114,7 @@
        * @since 2.0
        */
       public static int indexOfAny(String str, char[] searchChars) {
  -        if (str == null || str.length() == 0 || searchChars == null || searchChars.length
== 0) {
  +        if (StringUtils.isEmpty(str) || searchChars == null || searchChars.length == 0)
{
               return -1;
           }
           for (int i = 0; i < str.length(); i++) {
  @@ -1151,7 +1151,7 @@
        * @since 2.0
        */
       public static int indexOfAny(String str, String searchChars) {
  -        if (str == null || str.length() == 0 || searchChars == null || searchChars.length()
== 0) {
  +        if (StringUtils.isEmpty(str) || StringUtils.isEmpty(searchChars)) {
               return -1;
           }
           return indexOfAny(str, searchChars.toCharArray());
  @@ -2485,14 +2485,14 @@
        *  <code>null</code> if null String input
        * @since 2.1
        */
  -    public static String removeStart(String string, String remove) {
  -        if (string == null || string.length() == 0 || remove == null || remove.length()
== 0) {
  -            return string;
  +    public static String removeStart(String str, String remove) {
  +        if (StringUtils.isEmpty(str) || StringUtils.isEmpty(remove)) {
  +            return str;
           }
  -        if (string.startsWith(remove)){
  -            return string.substring(remove.length());
  +        if (str.startsWith(remove)){
  +            return str.substring(remove.length());
           }
  -        return string;
  +        return str;
       }
   
       /**
  @@ -2519,14 +2519,14 @@
        *  <code>null</code> if null String input
        * @since 2.1
        */
  -    public static String removeEnd(String string, String remove) {
  -        if (string == null || string.length() == 0 || remove == null || remove.length()
== 0) {
  -            return string;
  +    public static String removeEnd(String str, String remove) {
  +        if (StringUtils.isEmpty(str) || StringUtils.isEmpty(remove)) {
  +            return str;
           }
  -        if (string.endsWith(remove)) {
  -            return string.substring(0, string.length() - remove.length());
  +        if (str.endsWith(remove)) {
  +            return str.substring(0, str.length() - remove.length());
           }
  -        return string;
  +        return str;
       }
   
       // Replacing
  
  
  

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


Mime
View raw message