You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2013/05/31 00:44:47 UTC
svn commit: r1488041 - in /commons/proper/lang/trunk/src:
changes/changes.xml main/java/org/apache/commons/lang3/BooleanUtils.java
test/java/org/apache/commons/lang3/BooleanUtilsTest.java
Author: sebb
Date: Thu May 30 22:44:47 2013
New Revision: 1488041
URL: http://svn.apache.org/r1488041
Log:
LANG-896 BooleanUtils.toBoolean(String str) javadoc is not updated
Modified:
commons/proper/lang/trunk/src/changes/changes.xml
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java
Modified: commons/proper/lang/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/changes/changes.xml?rev=1488041&r1=1488040&r2=1488041&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/changes/changes.xml (original)
+++ commons/proper/lang/trunk/src/changes/changes.xml Thu May 30 22:44:47 2013
@@ -22,6 +22,7 @@
<body>
<release version="3.2" date="TBA" description="Next release">
+ <action issue="LANG-896" type="fix" due-to="Mark Bryan Yu">BooleanUtils.toBoolean(String str) javadoc is not updated</action>
<action issue="LANG-879" type="fix">LocaleUtils test fails with new Locale "ja_JP_JP_#u-ca-japanese" of JDK7</action>
<action issue="LANG-836" type="fix" due-to="Arnaud Brunet">StrSubstitutor does not support StringBuilder or CharSequence</action>
<action issue="LANG-693" type="fix" due-to="Calvin Echols">Method createNumber from NumberUtils doesn't work for floating point numbers other than Float</action>
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java?rev=1488041&r1=1488040&r2=1488041&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java Thu May 30 22:44:47 2013
@@ -513,26 +513,33 @@ public class BooleanUtils {
/**
* <p>Converts a String to a Boolean.</p>
*
- * <p>{@code 'true'}, {@code 'on'} or {@code 'yes'}
+ * <p>{@code 'true'}, {@code 'on'}, {@code 'y'}, {@code 't'} or {@code 'yes'}
* (case insensitive) will return {@code true}.
- * {@code 'false'}, {@code 'off'} or {@code 'no'}
+ * {@code 'false'}, {@code 'off'}, {@code 'n'}, {@code 'f'} or {@code 'no'}
* (case insensitive) will return {@code false}.
* Otherwise, {@code null} is returned.</p>
*
* <p>NOTE: This returns null and will throw a NullPointerException if autoboxed to a boolean. </p>
*
* <pre>
+ * // N.B. case is not significant
* BooleanUtils.toBooleanObject(null) = null
* BooleanUtils.toBooleanObject("true") = Boolean.TRUE
+ * BooleanUtils.toBooleanObject("T") = Boolean.TRUE // i.e. T[RUE]
* BooleanUtils.toBooleanObject("false") = Boolean.FALSE
+ * BooleanUtils.toBooleanObject("f") = Boolean.FALSE // i.e. f[alse]
+ * BooleanUtils.toBooleanObject("No") = Boolean.FALSE
+ * BooleanUtils.toBooleanObject("n") = Boolean.FALSE // i.e. n[o]
* BooleanUtils.toBooleanObject("on") = Boolean.TRUE
* BooleanUtils.toBooleanObject("ON") = Boolean.TRUE
* BooleanUtils.toBooleanObject("off") = Boolean.FALSE
* BooleanUtils.toBooleanObject("oFf") = Boolean.FALSE
+ * BooleanUtils.toBooleanObject("yes") = Boolean.TRUE
+ * BooleanUtils.toBooleanObject("Y") = Boolean.TRUE // i.e. Y[ES]
* BooleanUtils.toBooleanObject("blue") = null
* </pre>
*
- * @param str the String to check
+ * @param str the String to check; upper and lower case are treated as the same
* @return the Boolean value of the string, {@code null} if no match or {@code null} input
*/
public static Boolean toBooleanObject(final String str) {
@@ -669,13 +676,13 @@ public class BooleanUtils {
/**
* <p>Converts a String to a boolean (optimised for performance).</p>
*
- * <p>{@code 'true'}, {@code 'on'} or {@code 'yes'}
+ * <p>{@code 'true'}, {@code 'on'}, {@code 'y'}, {@code 't'} or {@code 'yes'}
* (case insensitive) will return {@code true}. Otherwise,
* {@code false} is returned.</p>
*
* <p>This method performs 4 times faster (JDK1.4) than
* {@code Boolean.valueOf(String)}. However, this method accepts
- * 'on' and 'yes' as true values.
+ * 'on' and 'yes', 't', 'y' as true values.
*
* <pre>
* BooleanUtils.toBoolean(null) = false
@@ -686,6 +693,10 @@ public class BooleanUtils {
* BooleanUtils.toBoolean("yes") = true
* BooleanUtils.toBoolean("false") = false
* BooleanUtils.toBoolean("x gti") = false
+ * BooleanUtils.toBooleanObject("y") = true
+ * BooleanUtils.toBooleanObject("n") = false
+ * BooleanUtils.toBooleanObject("t") = true
+ * BooleanUtils.toBooleanObject("f") = false
* </pre>
*
* @param str the String to check
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java?rev=1488041&r1=1488040&r2=1488041&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java Thu May 30 22:44:47 2013
@@ -272,13 +272,13 @@ public class BooleanUtilsTest {
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("TruE"));
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("TruE"));
- assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("y"));
+ assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("y")); // yes
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("Y"));
- assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("t"));
+ assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("t")); // true
assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("T"));
- assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("f"));
+ assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("f")); // false
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("F"));
- assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("n"));
+ assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("n")); // No
assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("N"));
assertEquals(null, BooleanUtils.toBooleanObject("z"));