Author: niallp Date: Sun Jan 9 02:10:44 2011 New Revision: 1056864 URL: http://svn.apache.org/viewvc?rev=1056864&view=rev Log: Port LANG-643 to LANG 2.x Branch - Javadoc StringUtils.left() claims to throw an exception on negative lenth, but doesn't
Modified: commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/StringUtils.java Modified: commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/StringUtils.java URL: http://svn.apache.org/viewvc/commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/StringUtils.java?rev=1056864&r1=1056863&r2=1056864&view=diff ============================================================================== --- commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/StringUtils.java (original) +++ commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/StringUtils.java Sun Jan 9 02:10:44 2011 @@ -1937,7 +1937,7 @@ public class StringUtils { * * <p>If <code>len</code> characters are not available, or the * String is <code>null</code>, the String will be returned without - * an exception. An exception is thrown if len is negative.</p> + * an exception. An empty String is returned if len is negative.</p> * * <pre> * StringUtils.left(null, *) = null @@ -1949,7 +1949,7 @@ public class StringUtils { * </pre> * * @param str the String to get the leftmost characters from, may be null - * @param len the length of the required String, must be zero or positive + * @param len the length of the required String * @return the leftmost characters, <code>null</code> if null String input */ public static String left(String str, int len) { @@ -1970,7 +1970,7 @@ public class StringUtils { * * <p>If <code>len</code> characters are not available, or the String * is <code>null</code>, the String will be returned without an - * an exception. An exception is thrown if len is negative.</p> + * an exception. An empty String is returned if len is negative.</p> * * <pre> * StringUtils.right(null, *) = null @@ -1982,7 +1982,7 @@ public class StringUtils { * </pre> * * @param str the String to get the rightmost characters from, may be null - * @param len the length of the required String, must be zero or positive + * @param len the length of the required String * @return the rightmost characters, <code>null</code> if null String input */ public static String right(String str, int len) { @@ -2004,7 +2004,8 @@ public class StringUtils { * <p>If <code>len</code> characters are not available, the remainder * of the String will be returned without an exception. If the * String is <code>null</code>, <code>null</code> will be returned. - * An exception is thrown if len is negative.</p> + * An empty String is returned if len is negative or exceeds the + * length of <code>str</code>.</p> * * <pre> * StringUtils.mid(null, *, *) = null @@ -2019,7 +2020,7 @@ public class StringUtils { * * @param str the String to get the characters from, may be null * @param pos the position to start from, negative treated as zero - * @param len the length of the required String, must be zero or positive + * @param len the length of the required String * @return the middle characters, <code>null</code> if null String input */ public static String mid(String str, int pos, int len) {