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().
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1095998 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
27b468c81f
commit
95008b9efd
|
@ -4473,7 +4473,7 @@ public class StringUtils {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
if (inputLength == 1 && repeat <= PAD_LIMIT) {
|
if (inputLength == 1 && repeat <= PAD_LIMIT) {
|
||||||
return padding(repeat, str.charAt(0));
|
return pad(repeat, str.charAt(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
int outputLength = inputLength * repeat;
|
int outputLength = inputLength * repeat;
|
||||||
|
@ -4540,7 +4540,7 @@ public class StringUtils {
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.padding(0, 'e') = ""
|
* StringUtils.padding(0, 'e') = ""
|
||||||
* StringUtils.padding(3, 'e') = "eee"
|
* StringUtils.padding(3, 'e') = "eee"
|
||||||
* StringUtils.padding(-2, 'e') = IndexOutOfBoundsException
|
* StringUtils.padding(-2, 'e') throws IndexOutOfBoundsException
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* <p>Note: this method doesn't not support padding with
|
* <p>Note: this method doesn't not support padding with
|
||||||
|
@ -4556,7 +4556,7 @@ public class StringUtils {
|
||||||
* @throws IndexOutOfBoundsException if <code>repeat < 0</code>
|
* @throws IndexOutOfBoundsException if <code>repeat < 0</code>
|
||||||
* @see #repeat(String, int)
|
* @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) {
|
if (repeat < 0) {
|
||||||
throw new IndexOutOfBoundsException("Cannot pad a negative amount: " + repeat);
|
throw new IndexOutOfBoundsException("Cannot pad a negative amount: " + repeat);
|
||||||
}
|
}
|
||||||
|
@ -4622,7 +4622,7 @@ public class StringUtils {
|
||||||
if (pads > PAD_LIMIT) {
|
if (pads > PAD_LIMIT) {
|
||||||
return rightPad(str, size, String.valueOf(padChar));
|
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) {
|
if (pads > PAD_LIMIT) {
|
||||||
return leftPad(str, size, String.valueOf(padChar));
|
return leftPad(str, size, String.valueOf(padChar));
|
||||||
}
|
}
|
||||||
return padding(pads, padChar).concat(str);
|
return pad(pads, padChar).concat(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue