commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java
Date Fri, 15 Nov 2002 00:06:40 GMT
scolebourne    2002/11/14 16:06:40

  Modified:    lang/src/test/org/apache/commons/lang StringUtilsIsTest.java
               lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Change the isTrue() method to cope with strings case insensitively
  
  Revision  Changes    Path
  1.3       +5 -1      jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsIsTest.java
  
  Index: StringUtilsIsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsIsTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StringUtilsIsTest.java	28 Oct 2002 04:33:29 -0000	1.2
  +++ StringUtilsIsTest.java	15 Nov 2002 00:06:40 -0000	1.3
  @@ -139,6 +139,10 @@
           assertEquals(true, StringUtils.isTrue("true"));
           assertEquals(true, StringUtils.isTrue("yes"));
           assertEquals(true, StringUtils.isTrue("on"));
  +        assertEquals(true, StringUtils.isTrue("TRUE"));
  +        assertEquals(true, StringUtils.isTrue("ON"));
  +        assertEquals(true, StringUtils.isTrue("YES"));
  +        assertEquals(true, StringUtils.isTrue("TruE"));
       }
   
       public void testIsAlphaspace() {
  
  
  
  1.23      +6 -8      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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- StringUtils.java	14 Nov 2002 22:29:25 -0000	1.22
  +++ StringUtils.java	15 Nov 2002 00:06:40 -0000	1.23
  @@ -1502,19 +1502,17 @@
   
       /**
        * Checks if the String contains a 'true' value. These are defined 
  -     * as the words 'true', 'on' and 'yes'.
  +     * as the words 'true', 'on' and 'yes', case insensitive.
        *
        * @param str the String to check
  -     * @return true if the string is 'true|on|yes'
  +     * @return true if the string is 'true|on|yes' case insensitive
        */
       public static boolean isTrue(String str) {
  -        if("true".equals(str)) {
  +        if ("true".equalsIgnoreCase(str)) {
               return true;
  -        } else
  -        if("on".equals(str)) {
  +        } else if ("on".equalsIgnoreCase(str)) {
               return true;
  -        } else
  -        if("yes".equals(str)) {
  +        } else if ("yes".equalsIgnoreCase(str)) {
               return true;
           }
           return false;
  
  
  

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


Mime
View raw message