Package org.apache.tika.utils
Class StringUtils
java.lang.Object
org.apache.tika.utils.StringUtils
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
static boolean
isEmpty
(CharSequence cs) static String
static String
static String
Left pad a String with a specified String.static String
repeat
(char ch, int repeat) Returns padding using the specified delimiter repeated to a given length.static String
Repeat a Stringrepeat
times to form a new String.
-
Field Details
-
EMPTY
The empty String""
.- Since:
- 2.0
- See Also:
-
SPACE
A String for a space character.- Since:
- 3.2
- See Also:
-
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
isEmpty
-
isBlank
-
leftPad
Left pad a String with a specified String.
Pad to a size of
size
.StringUtils.leftPad(null, *, *) = null StringUtils.leftPad("", 3, "z") = "zzz" StringUtils.leftPad("bat", 3, "yz") = "bat" StringUtils.leftPad("bat", 5, "yz") = "yzbat" StringUtils.leftPad("bat", 8, "yz") = "yzyzybat" StringUtils.leftPad("bat", 1, "yz") = "bat" StringUtils.leftPad("bat", -1, "yz") = "bat" StringUtils.leftPad("bat", 5, null) = " bat" StringUtils.leftPad("bat", 5, "") = " bat"
- Parameters:
str
- the String to pad out, may be nullsize
- the size to pad topadStr
- the String to pad with, null or empty treated as single space- Returns:
- left padded String or original String if no padding is necessary,
null
if null String input
-
leftPad
-
repeat
Returns padding using the specified delimiter repeated to a given length.
StringUtils.repeat('e', 0) = "" StringUtils.repeat('e', 3) = "eee" StringUtils.repeat('e', -2) = ""
Note: this method does not support padding with Unicode Supplementary Characters as they require a pair of
char
s to be represented. If you are needing to support full I18N of your applications consider usingrepeat(String, int)
instead.- Parameters:
ch
- character to repeatrepeat
- number of times to repeat char, negative treated as zero- Returns:
- String with repeated character
- See Also:
-
repeat
Repeat a String
repeat
times to form a new String.StringUtils.repeat(null, 2) = null StringUtils.repeat("", 0) = "" StringUtils.repeat("", 2) = "" StringUtils.repeat("a", 3) = "aaa" StringUtils.repeat("ab", 2) = "abab" StringUtils.repeat("a", -2) = ""
- Parameters:
str
- the String to repeat, may be nullrepeat
- number of times to repeat str, negative treated as zero- Returns:
- a new String consisting of the original String repeated,
null
if null String input
-
joinWith
-