Package com.nomagic.magicreport.helper
Class StringUtils
java.lang.Object
com.nomagic.magicreport.helper.StringUtils
Contains collection of String utilities.
- Since:
- Jun 15, 2007
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic CharSequenceleftTrim(CharSequence input) Returns a copy of the string, with leading whitespace omitted.static StringlPad(CharSequence src, char pad, int length) Padding a character to left of string.static StringBufferreplace(CharSequence input, String target, String replacement) Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence.static StringBufferreplaceAll(CharSequence input, String regex, String replacement) Replaces each substring of this subsequence that matches the given regular expression with the given replacement.static StringBuilderreplaceAllBuilder(CharSequence input, String regex, String replacement) Replaces each substring of this subsequence that matches the given regular expression with the given replacement.static StringBuilderreplaceBuilder(CharSequence input, String target, String replacement) Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence.static CharSequencerightTrim(CharSequence input) Returns a copy of the string, with trailing whitespace omitted.static StringrPad(CharSequence src, char pad, int length) Padding a character to right of string.static CharSequencetrim(CharSequence input) Returns a copy of the string, with leading whitespace and trailing whitespace are omitted.
-
Field Details
-
LINE_SEPARATOR
A line separator string. The line separator string is defined by the system propertyline.separator, and is not necessarily a single newline ('\n') character.
-
-
Method Details
-
replaceAll
Replaces each substring of this subsequence that matches the given regular expression with the given replacement.- Parameters:
input- The character sequence to be matchedregex- the regular expression to which this string is to be matchedreplacement- The replacement string- Returns:
- The StringBuffer constructed by replacing each matching subsequence by the replacement string, substituting captured subsequences as needed
-
replaceAllBuilder
Replaces each substring of this subsequence that matches the given regular expression with the given replacement.- Parameters:
input- The character sequence to be matchedregex- the regular expression to which this string is to be matchedreplacement- The replacement string- Returns:
- The StringBuilder constructed by replacing each matching subsequence by the replacement string, substituting captured subsequences as needed
-
replace
Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence. The replacement proceeds from the beginning of the string to the end.- Parameters:
input- The character sequence to be matchedtarget- The sequence of char values to be replacedreplacement- The replacement string- Returns:
- The StringBuffer constructed by replacing each matching subsequence by the replacement string, substituting captured subsequences as needed
-
replaceBuilder
Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence. The replacement proceeds from the beginning of the string to the end.- Parameters:
input- The character sequence to be matchedtarget- The sequence of char values to be replacedreplacement- The replacement string- Returns:
- The StringBuilder constructed by replacing each matching subsequence by the replacement string, substituting captured subsequences as needed
-
leftTrim
Returns a copy of the string, with leading whitespace omitted. This method may be used to trim whitespace from the beginning of a string.- Parameters:
input- string to be trim.- Returns:
- A copy of this string with leading white space removed, or this string if it has no leading white space
-
rightTrim
Returns a copy of the string, with trailing whitespace omitted. This method may be used to trim whitespace from the end of a string.- Parameters:
input- string to be trim.- Returns:
- A copy of this string with trailing white space removed, or this string if it has no trailing white space
-
trim
Returns a copy of the string, with leading whitespace and trailing whitespace are omitted.- Parameters:
input- string to be trim.- Returns:
- A copy of this string with leading whitespace trailing white space removed, or this string if it has no leading whitespace and trailing white space
-
lPad
Padding a character to left of string.- Parameters:
src- String to paddingpad- Pad characterlength- Final length of string- Returns:
- new string
-
rPad
Padding a character to right of string.- Parameters:
src- String to paddingpad- Pad characterlength- Final length of string- Returns:
- new string
-