commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: svn commit: r1095998 - /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
Date Sun, 24 Apr 2011 00:57:44 GMT
On Apr 23, 2011, at 13:10, Matt Benson <gudnabrsam@gmail.com> wrote:

> Hi, Gary--now that this method is public, it would seem to fit better
> into StringUtils as an alternate repeat() signature.  I would also
> switch the int/char parameters for consistency with the rest of the
> group, then FormattableUtils can also use it for its padding behavior.
> :)
>
> Matt

That all sounds good. I'm in the middle of a move so feel free to make
the changes.

Gary

>
> On Fri, Apr 22, 2011 at 2:28 PM,  <ggregory@apache.org> wrote:
>> Author: ggregory
>> Date: Fri Apr 22 19:28:58 2011
>> New Revision: 1095998
>>
>> URL: http://svn.apache.org/viewvc?rev=1095998&view=rev
>> Log:
>> Make the pad method public. I can use this now :) ! The method used to be private
and named padding. It is used internally and covered by unit tests through leftPad(), rightPad()
and repeat().
>>
>> Modified:
>>    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
>>
>> Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
>> URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java?rev=1095998&r1=1095997&r2=1095998&view=diff
>> ==============================================================================
>> --- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
(original)
>> +++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
Fri Apr 22 19:28:58 2011
>> @@ -4473,7 +4473,7 @@ public class StringUtils {
>>             return str;
>>         }
>>         if (inputLength == 1 && repeat <= PAD_LIMIT) {
>> -            return padding(repeat, str.charAt(0));
>> +            return pad(repeat, str.charAt(0));
>>         }
>>
>>         int outputLength = inputLength * repeat;
>> @@ -4540,7 +4540,7 @@ public class StringUtils {
>>      * <pre>
>>      * StringUtils.padding(0, 'e')  = ""
>>      * StringUtils.padding(3, 'e')  = "eee"
>> -     * StringUtils.padding(-2, 'e') = IndexOutOfBoundsException
>> +     * StringUtils.padding(-2, 'e') throws IndexOutOfBoundsException
>>      * </pre>
>>      *
>>      * <p>Note: this method doesn't not support padding with
>> @@ -4556,7 +4556,7 @@ public class StringUtils {
>>      * @throws IndexOutOfBoundsException if <code>repeat &lt; 0</code>
>>      * @see #repeat(String, int)
>>      */
>> -    private static String padding(int repeat, char padChar) throws IndexOutOfBoundsException
{
>> +    public static String pad(int repeat, char padChar) throws IndexOutOfBoundsException
{
>>         if (repeat < 0) {
>>             throw new IndexOutOfBoundsException("Cannot pad a negative amount: "
+ repeat);
>>         }
>> @@ -4622,7 +4622,7 @@ public class StringUtils {
>>         if (pads > PAD_LIMIT) {
>>             return rightPad(str, size, String.valueOf(padChar));
>>         }
>> -        return str.concat(padding(pads, padChar));
>> +        return str.concat(pad(pads, padChar));
>>     }
>>
>>     /**
>> @@ -4734,7 +4734,7 @@ public class StringUtils {
>>         if (pads > PAD_LIMIT) {
>>             return leftPad(str, size, String.valueOf(padChar));
>>         }
>> -        return padding(pads, padChar).concat(str);
>> +        return pad(pads, padChar).concat(str);
>>     }
>>
>>     /**
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>

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


Mime
View raw message