public class StringUtils
extends java.lang.Object
This class contains static methods for performing various operations on Strings. For example, this class has methods for counting the number of occurrences of a particular character in a String, and methods for splitting a String into elements that were separated by a specific character.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string.
|
Constructor and Description |
---|
StringUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
alphaNumericOnly(java.lang.String pStr)
Returns a string with all characters not in the following ranges removed:
(c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z').
|
static java.lang.String |
alphaNumOnly(java.lang.String iString)
Returns a string with only alphanumeric characters.
|
static boolean |
arrayEquals(java.lang.String[] a,
java.lang.String[] b)
Return true if two arrays of strings contain the same contents.
|
static boolean |
arrayEqualsIgnoreCase(java.lang.String[] a,
java.lang.String[] b)
Return true if two arrays of strings contain the same contents,
ignoring case.
|
static java.lang.String |
convertStringFromPropertiesFileFormat(java.lang.String in)
Converts encoded \uxxxx to unicode chars and changes special saved.
|
static java.lang.String |
convertStringToPropertiesFileFormat(java.lang.String theString,
boolean escapeSpace,
boolean escapeUnicode)
Converts unicodes to encoded \uxxxx and escapes special characters with
a preceding slash.
|
static java.lang.String |
decodeFromJavaString(java.lang.String pJavaString,
boolean pDecodeUnicode)
This decodes a "Java" String, which is a String (complete with
enclosing quotation marks) containing java escape characters.
|
static java.lang.String |
encodeToJavaString(java.lang.String pString)
Encodes the specified String to a Java string - all non-printable
characters are escaped, and the resulting string is enclosed in
quotation marks.
|
static java.lang.String |
escapeHtmlString(java.lang.String pStr)
Returns a string that is properly escaped for use either as an
HTML attribute value or an HTML content section.
|
static java.lang.String |
escapeHtmlString(java.lang.String pStr,
boolean pEscapeAmp)
Returns a string that is properly escaped for use either as an
HTML attribute value or an HTML content section.
|
static java.lang.String |
expandEntries(java.lang.String pValue,
java.util.Map pMap)
Expand any instances of "{key}" in with the corresponding value
from pMap.
|
static java.lang.String |
expandEntries(java.lang.String pValue,
java.util.Map pMap,
java.lang.String pOpen,
java.lang.String pClose)
Expand any instances of "{key}" (where pOpen is "{" and pClose is "}")
with the corresponding value from pMap.
|
static java.lang.String |
extractString(java.lang.String pStr)
Return pStr if incoming value is not null, or return
empty string otherwise.
|
static java.lang.String |
extractString(java.lang.String pStr,
java.lang.String pDefault)
Return pStr if incoming value is not null, or return
pDefault otherwise.
|
static java.lang.String |
extractStringIfBlank(java.lang.String pStr,
java.lang.String pDefault)
Return pStr if incoming value is not blank, or return
pDefault otherwise.
|
static java.lang.String |
extractStringIfEmpty(java.lang.String pStr,
java.lang.String pDefault)
Return pStr if incoming value is not empty, or return
pDefault otherwise.
|
static boolean |
isAlphaNumOnly(java.lang.String iString)
Test for a string with only alphanumeric characters, spaces, -, and _.
|
static boolean |
isAlphaNumOnlyNoDash(java.lang.String iString)
Test for a string with only alphanumeric characters.
|
static boolean |
isBlank(java.lang.String pStr)
Return true if pStr is null, the empty string, or consists
entirely of whitespace where whitespace is defined by the
String.trim method.
|
static boolean |
isEmpty(java.lang.String pStr)
Return true if pStr is null or has length zero.
|
static boolean |
isNotBlank(java.lang.String pStr)
Return true if pStr is not null, not empty string, or does
not consist entirely of whitespace where whitespace is defined
by the String.trim method.
|
static boolean |
isNotEmpty(java.lang.String pStr)
Return true if pStr is not a null or zero length String.
|
static boolean |
isNumericOnly(java.lang.String iString)
Test for a string with only numeric characters.
|
static java.lang.String[] |
join(java.lang.String[] pFirst,
java.lang.String[] pSecond)
Joins two string arrays together to form a new string array.
|
static java.lang.String |
joinStrings(java.lang.String[] pStrings,
char pSeparator)
Join the specified string with the specified separator.
|
static java.lang.String |
joinStringsWithNonRepeatingSeparator(java.lang.String[] pStrings,
char pSeparator,
boolean pLeadingSeparator,
boolean pTrailingSeparator)
Join the specified strings with the specified separator
but do not repeat the separator.
|
static java.lang.String |
joinStringsWithQuoting(java.lang.String[] pStrings,
char pSeparator)
Join the specified string with the specified separator.
|
static java.lang.String |
literalizeForRegex(java.lang.String pString)
Attempt to literalize a string for use with
java.util.regex.
|
static java.lang.String |
makeList(java.util.Enumeration pElements,
java.lang.String pSeparator)
Format elements of an enumeration into a string, separating items
with a specified separator string.
|
static java.lang.String |
makeList(java.util.Enumeration pElements,
java.lang.String pFormat,
java.lang.String pSeparator)
Format elements of an enumeration into a string, formatting each item
according to a template and separating items with a specified separator
string.
|
static java.lang.StringBuffer |
makeList(java.util.Enumeration pElements,
java.lang.String pSeparator,
java.lang.StringBuffer pResult)
Append elements of an enumeration to a string buffer, separating items
with a specified separator string.
|
static java.lang.StringBuilder |
makeList(java.util.Enumeration pElements,
java.lang.String pSeparator,
java.lang.StringBuilder pResult)
Takes an enumeration of elements and adds their toString result
to a String.
|
static java.lang.StringBuffer |
makeList(java.util.Enumeration pElements,
java.lang.String pFormat,
java.lang.String pSeparator,
java.lang.StringBuffer pResult)
Append elements of an enumeration to a string buffer, formatting
each item according to a template and separating items with a
specified separator string.
|
static java.lang.StringBuilder |
makeList(java.util.Enumeration pElements,
java.lang.String pFormat,
java.lang.String pSeparator,
java.lang.StringBuilder pResult)
Format elements of an enumeration into a string, formatting each item
according to a template and separating items with a specified separator
string.
|
static java.lang.String |
makeList(java.lang.Object[] pElements,
java.lang.String pSeparator)
Format elements of an array into a string, separating items
with a specified separator string.
|
static java.lang.String |
makeList(java.lang.Object[] pElements,
java.lang.String pFormat,
java.lang.String pSeparator)
Format elements of an array into a string, formatting each item
according to a template and separating items with a specified separator
string.
|
static java.lang.StringBuffer |
makeList(java.lang.Object[] pElements,
java.lang.String pSeparator,
java.lang.StringBuffer pResult)
Append elements of an array to a string buffer, separating items
with a specified separator string.
|
static java.lang.StringBuilder |
makeList(java.lang.Object[] pElements,
java.lang.String pSeparator,
java.lang.StringBuilder pResult)
Append elements of an array to a string builder, separating items
with a specified separator string.
|
static java.lang.StringBuffer |
makeList(java.lang.Object[] pElements,
java.lang.String pFormat,
java.lang.String pSeparator,
java.lang.StringBuffer pResult)
Append elements of an array to a string buffer, formatting
each item according to a template and separating items with a
specified separator string.
|
static java.lang.StringBuilder |
makeList(java.lang.Object[] pElements,
java.lang.String pFormat,
java.lang.String pSeparator,
java.lang.StringBuilder pResult)
Append elements of an array to a string builder, formatting
each item according to a template and separating items with a
specified separator string.
|
static java.lang.String |
normalizeWhitespace(java.lang.String s)
Converts newlines, tabs, and carriage returns to spaces and then
removes repetitive spaces.
|
static int |
numOccurrences(java.lang.String pString,
char pDelimiter)
Returns the number of times the specified character appears in
the specified String.
|
static int |
numOccurrences(java.lang.String pString,
char pDelimiter,
char pEscape)
Returns the number of times the specified character appears in
the specified String.
|
static int |
numOccurrences(java.lang.String pString,
java.lang.String pDelimiter)
Returns the number of times the specified character appears in
the specified String.
|
static java.lang.String |
or(java.lang.String... pStrings)
Return the first non-null string, or null.
|
static java.lang.String |
removeCharacters(java.lang.String iString,
java.lang.String iFilter)
Creates a new string with any characters in iFilter removed.
|
static java.lang.String |
removeConsecutiveStrings(java.lang.String pString,
char pToRemove)
Removes any consecutive slashes from the given string
e.g.
|
static java.lang.String |
removeConsecutiveStrings(java.lang.String pString,
java.lang.String pToRemove)
Removes any consecutive slashes from the given string
e.g.
|
static java.lang.String |
removeCRLF(java.lang.String iString)
Creates a new string and remove Carriage Return & Line Feed characters.
|
static java.lang.String |
removeExtension(java.lang.String pSrc)
Return a string with the trailing extension removed.
|
static java.lang.String |
removeWhiteSpace(java.lang.String iString)
Creates a new string with any whitespace removed.
|
static java.lang.String |
replace(java.lang.String pSrc,
char pFrom,
java.lang.String pTo)
Returns a copy of the src string where all occurrences of pFrom are
replaced by copies of pTo.
|
static java.lang.String |
replace(java.lang.String pSrc,
java.lang.String pFrom,
java.lang.String pTo)
Returns a copy of the src string where all occurrences of pFrom are
replaced by copies of pTo.
|
static java.lang.String |
replaceCharacters(java.lang.String pString,
char[] pReplacements)
Replaces individual characters in a string.
|
static java.lang.String |
replaceSubstrings(java.lang.String pString,
java.lang.String[] pReplacements)
Replaces substrings of a string.
|
static java.lang.String[] |
splitStringAtCharacter(java.lang.String pString,
char pDelimiter)
Splits the specified String containing the specified character
into individual Strings that were delimited by the specified
character.
|
static java.lang.String[] |
splitStringAtCharacter(java.lang.String pString,
char pDelimiter,
char pEscape)
Splits the specified String containing the specified character
into individual Strings that were delimited by the specified
character.
|
static int |
splitStringAtCharacter(java.lang.String pString,
char pDelimiter,
char pEscape,
java.lang.String[] pStrings,
int pStart)
Splits the specified String containing the specified character
into individual Strings that were delimited by the specified
character.
|
static int |
splitStringAtCharacter(java.lang.String pString,
char pDelimiter,
java.lang.String[] pStrings,
int pStart)
Splits the specified String containing the specified character
into individual Strings that were delimited by the specified
character.
|
static java.lang.String[] |
splitStringAtCharacterWithQuoting(java.lang.String pString,
char pDelimiter)
Splits the specified String containing the specified character
into individual Strings that were delimited by the specified
character, but which treat double occurrences of the character
as a quote of that character.
|
static int |
splitStringAtCharacterWithQuoting(java.lang.String pString,
char pDelimiter,
java.lang.String[] pStrings,
int pStart)
Splits the specified String containing the specified character
into individual Strings that were delimited by the specified
character, but which treat double occurrences of the character
as a quote of that character.
|
static java.lang.String[] |
splitStringAtString(java.lang.String pString,
java.lang.String pDelimiter)
Splits the specified String containing the specified substring
into individual Strings that were delimited by the specified
substring.
|
static int |
splitStringAtString(java.lang.String pString,
java.lang.String pDelimiter,
java.lang.String[] pStrings,
int pStart)
Splits the specified String containing the specified substring
into individual Strings that were delimited by the specified
substring.
|
static java.util.Vector |
tokenizer(java.lang.String pSrc,
java.lang.String pToken)
Returns a Vector of the tokenized source.
|
static java.lang.String |
toLowerCase(java.lang.String pSrc)
This is a faster version of the toLowerCase method that only works
in the english locale.
|
static java.lang.String |
toUpperCase(java.lang.String pSrc)
This is a faster version of the toUpperCase method that only works
in the english locale.
|
static java.lang.String |
trimToNull(java.lang.String pString)
Return the result of trimming pString, if pString is not null or
empty.
|
public static int numOccurrences(java.lang.String pString, char pDelimiter)
pString
- The string to check for the character.pDelimiter
- The character being searched for.public static int numOccurrences(java.lang.String pString, java.lang.String pDelimiter)
pString
- The string to check for the character.pDelimiter
- The character being searched for.public static int numOccurrences(java.lang.String pString, char pDelimiter, char pEscape)
String | Number of occurrences |
"" | 0 |
"2.5,1\,000,10\0,ab\\c" | 3 |
"a,,b,c" | 3 |
"a," | 1 |
",a" | 1 |
"a,," | 2 |
"," | 1 |
"\" | 0 |
"\\" | 0 |
"\," | 0 |
"\\," | 1 |
"\\\" | 0 |
"\\\," | 0 |
",\\\" | 1 |
pString
- The string to check for the character.pDelimiter
- The character being searched for.pEscape
- The escape character.for more details
public static int splitStringAtCharacter(java.lang.String pString, char pDelimiter, java.lang.String[] pStrings, int pStart)
pString
- the String to be splitpDelimiter
- the character delimiting the individual StringspStrings
- the String array into which the individual Strings
will be written. If there are more Strings than will fit into this
array, then only the first Strings that fit will be put into this
array.pStart
- the starting index into the array where the first
String should gopublic static int splitStringAtCharacter(java.lang.String pString, char pDelimiter, char pEscape, java.lang.String[] pStrings, int pStart)
String | Number of split strings | Result |
"" | 0 | empty array |
"2.5,1\,000,10\0,ab\\c" | 4 | "2.5", "1,000", "10\0" and "ab\\c" |
"a,,b,c" | 4 | "a", "", "b" and "c" |
"a," | 1 | "a" |
",a" | 2 | "" and "a" |
"a,," | 2 | "a" and "" |
"," | 1 | "" |
"\" | 1 | "\" |
"\\" | 1 | "\\" |
"\," | 1 | "," |
"\\," | 1 | "\," |
"\\\," | 1 | "\\," |
"\\\" | 1 | "\\\" |
",\\\" | 2 | "" and "\\\" |
pString
- the String to be splitpDelimiter
- the character delimiting the individual StringspEscape
- the escape character that includes the character following it.pStrings
- the String array into which the individual Strings
will be written. If there are more Strings than will fit into this
array, then only the first Strings that fit will be put into this
array.pStart
- the starting index into the array where the first
String should gopublic static int splitStringAtString(java.lang.String pString, java.lang.String pDelimiter, java.lang.String[] pStrings, int pStart)
pString
- the String to be splitpDelimiter
- the String delimiting the individual StringspStrings
- the String array into which the individual Strings
will be written. If there are more Strings than will fit into this
array, then only the first Strings that fit will be put into this
array.pStart
- the starting index into the array where the first
String should gopublic static java.lang.String[] splitStringAtCharacter(java.lang.String pString, char pDelimiter)
pString
- the String to be splitpDelimiter
- the character delimiting the individual Stringspublic static java.lang.String[] splitStringAtCharacter(java.lang.String pString, char pDelimiter, char pEscape)
pString
- the String to be splitpDelimiter
- the character delimiting the individual StringspEscape
- the escape character.public static java.lang.String[] splitStringAtString(java.lang.String pString, java.lang.String pDelimiter)
pString
- the String to be splitpDelimiter
- the String delimiting the individual Stringspublic static int splitStringAtCharacterWithQuoting(java.lang.String pString, char pDelimiter, java.lang.String[] pStrings, int pStart)
pString
- the String to be splitpDelimiter
- the character delimiting the individual StringspStrings
- the String array into which the individual Strings
will be written. If there are more Strings than will fit into this
array, then only the first Strings that fit will be put into this
array.pStart
- the starting index into the array where the first
String should gopublic static java.lang.String[] splitStringAtCharacterWithQuoting(java.lang.String pString, char pDelimiter)
pString
- the String to be splitpDelimiter
- the character delimiting the individual Stringspublic static java.lang.String replace(java.lang.String pSrc, char pFrom, java.lang.String pTo)
pSrc
- the source stringpFrom
- the character to be replacedpTo
- the string to substitutepublic static java.lang.String replace(java.lang.String pSrc, java.lang.String pFrom, java.lang.String pTo)
pSrc
- the source stringpFrom
- the string to be replacedpTo
- the string to substitutepublic static java.lang.String toUpperCase(java.lang.String pSrc)
pSrc
- the string to turn into upper casepublic static java.lang.String toLowerCase(java.lang.String pSrc)
pSrc
- the string to turn into upper casepublic static boolean arrayEquals(java.lang.String[] a, java.lang.String[] b)
a
- The first array.b
- The second array.public static boolean arrayEqualsIgnoreCase(java.lang.String[] a, java.lang.String[] b)
a
- The first array.b
- The second array.public static java.lang.String removeCharacters(java.lang.String iString, java.lang.String iFilter)
iString
- The string to to have characters removed from.iFilter
- The characters to remove from the string.public static java.lang.String removeWhiteSpace(java.lang.String iString)
iString
- The string to have whitespace removed from.public static java.lang.String removeCRLF(java.lang.String iString)
iString
- The string to have Carriage Return & Line Feed characters removed.public static java.lang.String alphaNumOnly(java.lang.String iString)
iString
- The string to remove non-alphanumeric characters from.public static java.lang.String alphaNumericOnly(java.lang.String pStr)
pStr
- The string to processpublic static boolean isAlphaNumOnly(java.lang.String iString)
iString
- The string being checked.public static boolean isAlphaNumOnlyNoDash(java.lang.String iString)
iString
- The string being checked.public static boolean isNumericOnly(java.lang.String iString)
iString
- The String being checkedpublic static java.lang.String replaceSubstrings(java.lang.String pString, java.lang.String[] pReplacements)
pString
- The input string on which to do replacement.pReplacements
- An array of strings; the 0th element is the first
text to replace, the 1st element is the text to replace it with, the 2nd
element is the second text to replace, the 3rd element is the text to replace
that with, and so on.public static java.lang.String replaceCharacters(java.lang.String pString, char[] pReplacements)
pString
- The input string on which to do replacement.pReplacements
- An array of chars; the 0th element is the first
character to replace, the 1st element is the character to replace it with, the 2nd
element is the second character to replace, the 3rd element is the character to replace
that with, and so on.public static java.util.Vector tokenizer(java.lang.String pSrc, java.lang.String pToken)
pSrc
- the String to tokenizepToken
- the String to use as the tokenpublic static java.lang.String removeExtension(java.lang.String pSrc)
pSrc
- The string to have its extension removed.public static java.lang.String makeList(java.util.Enumeration pElements, java.lang.String pSeparator)
pElements
- An enumeration whose elements are to be
printed, one at a time. Each element is
converted to a string by calling its
toString
method.pSeparator
- The string used to separate adjacent items
in the list, for example ","
item1, item2, item3
public static java.lang.StringBuffer makeList(java.util.Enumeration pElements, java.lang.String pSeparator, java.lang.StringBuffer pResult)
pElements
- An enumeration whose elements are to be
printed, one at a time. Each element is
converted to a string by calling its
toString
method.pSeparator
- The string used to separate adjacent items
in the list, for example ","
pResult
- A StringBuffer used to hold the result of the
formatting operation.item1, item2, item3
appended to itpublic static java.lang.StringBuilder makeList(java.util.Enumeration pElements, java.lang.String pSeparator, java.lang.StringBuilder pResult)
pElements
- The enumeration of elements.pSeparator
- The separator added between the elements in
the string.pResult
- The converted elements are added to this StringBuilderpublic static java.lang.String makeList(java.util.Enumeration pElements, java.lang.String pFormat, java.lang.String pSeparator)
pElements
- An enumeration whose elements are to be
printed, one at a time. Each element is
converted to a string by using an instance
of java.text.MessageFormat
with the specified format template.pFormat
- A formatting template to apply to each element
of the enumeration. The {0}
placeholder will be replaced by the element
currently being processed.pSeparator
- The string used to separate adjacent items
in the list, for example ","
item1, item2, item3
,
where each item's appearance is determine by
the format string in pFormatpublic static java.lang.StringBuffer makeList(java.util.Enumeration pElements, java.lang.String pFormat, java.lang.String pSeparator, java.lang.StringBuffer pResult)
pElements
- An enumeration whose elements are to be
printed, one at a time. Each element is
converted to a string by using an instance
of java.text.MessageFormat
with the specified format template.pFormat
- A formatting template to apply to each element
of the enumeration. The {0}
placeholder will be replaced by the element
currently being processed.pSeparator
- The string used to separate adjacent items
in the list, for example ","
pResult
- A StringBuffer used to hold the result of the
formatting operation.item1, item2, item3
,
where each item's appearance is determine by
the format string in pFormatpublic static java.lang.StringBuilder makeList(java.util.Enumeration pElements, java.lang.String pFormat, java.lang.String pSeparator, java.lang.StringBuilder pResult)
pElements
- An enumeration whose elements are to be
printed, one at a time. Each element is
converted to a string by using an instance
of java.text.MessageFormat
with the specified format template.pFormat
- A formatting template to apply to each element
of the enumeration. The {0}
placeholder will be replaced by the element
currently being processed.pSeparator
- The string used to separate adjacent items
in the list, for example ","
pResult
- A StringBuilder used to hold the result of the
formatting operation.item1, item2, item3
,
where each item's appearance is determine by
the format string in pFormatpublic static java.lang.String makeList(java.lang.Object[] pElements, java.lang.String pSeparator)
pElements
- An array whose elements are to be
printed, one at a time. Each element is
converted to a string by calling its
toString
method.pSeparator
- The string used to separate adjacent items
in the list, for example ","
item1, item2, item3
public static java.lang.StringBuffer makeList(java.lang.Object[] pElements, java.lang.String pSeparator, java.lang.StringBuffer pResult)
pElements
- An array whose elements are to be
printed, one at a time. Each element is
converted to a string by calling its
toString
method.pSeparator
- The string used to separate adjacent items
in the list, for example ","
pResult
- A StringBuffer used to hold the result of the
formatting operation.item1, item2, item3
appended to itpublic static java.lang.StringBuilder makeList(java.lang.Object[] pElements, java.lang.String pSeparator, java.lang.StringBuilder pResult)
pElements
- An array whose elements are to be
printed, one at a time. Each element is
converted to a string by calling its
toString
method.pSeparator
- The string used to separate adjacent items
in the list, for example ","
pResult
- A StringBuilder used to hold the result of the
formatting operation.item1, item2, item3
appended to itpublic static java.lang.String makeList(java.lang.Object[] pElements, java.lang.String pFormat, java.lang.String pSeparator)
pElements
- An array whose elements are to be
printed, one at a time. Each element is
converted to a string by using an instance
of java.text.MessageFormat
with the specified format template.pFormat
- A formatting template to apply to each element
of the array. The {0}
placeholder will be replaced by the element
currently being processed.pSeparator
- The string used to separate adjacent items
in the list, for example ","
item1, item2, item3
,
where each item's appearance is determine by
the format string in pFormatpublic static java.lang.StringBuffer makeList(java.lang.Object[] pElements, java.lang.String pFormat, java.lang.String pSeparator, java.lang.StringBuffer pResult)
pElements
- An array whose elements are to be
printed, one at a time. Each element is
converted to a string by using an instance
of java.text.MessageFormat
with the specified format template.pFormat
- A formatting template to apply to each element
of the array. The {0}
placeholder will be replaced by the element
currently being processed.pSeparator
- The string used to separate adjacent items
in the list, for example ","
pResult
- A StringBuffer used to hold the result of the
formatting operation.item1, item2, item3
,
where each item's appearance is determine by
the format string in pFormatpublic static java.lang.StringBuilder makeList(java.lang.Object[] pElements, java.lang.String pFormat, java.lang.String pSeparator, java.lang.StringBuilder pResult)
pElements
- An array whose elements are to be
printed, one at a time. Each element is
converted to a string by using an instance
of java.text.MessageFormat
with the specified format template.pFormat
- A formatting template to apply to each element
of the array. The {0}
placeholder will be replaced by the element
currently being processed.pSeparator
- The string used to separate adjacent items
in the list, for example ","
pResult
- A StringBuilder used to hold the result of the
formatting operation.item1, item2, item3
,
where each item's appearance is determine by
the format string in pFormatpublic static java.lang.String normalizeWhitespace(java.lang.String s)
s
- The string to normalize.public static java.lang.String literalizeForRegex(java.lang.String pString)
pString
- The string to literalize.public static java.lang.String decodeFromJavaString(java.lang.String pJavaString, boolean pDecodeUnicode)
pJavaString
- The string to be decoded.pDecodeUnicode
- True indicates that unicode escapes should be decoded.public static java.lang.String encodeToJavaString(java.lang.String pString)
pString
- The string to encodepublic static boolean isEmpty(java.lang.String pStr)
pStr
- The string to check for null or zero length.public static boolean isNotEmpty(java.lang.String pStr)
pStr
- The string to check is not null or zero lengthpublic static boolean isBlank(java.lang.String pStr)
pStr
- The String to check is null, zero length or just whitespace.String
public static boolean isNotBlank(java.lang.String pStr)
pStr
- The String to check is not null, zero length or just whitespace.String
public static java.lang.String trimToNull(java.lang.String pString)
pString
- the source string.public static java.lang.String extractString(java.lang.String pStr)
pStr
- The source string.public static java.lang.String extractString(java.lang.String pStr, java.lang.String pDefault)
pStr
- The source string.pDefault
- The string to return if pStr is null.public static java.lang.String extractStringIfEmpty(java.lang.String pStr, java.lang.String pDefault)
pStr
- The source stringpDefault
- The string to return if pStr is empty.isEmpty(String)
public static java.lang.String extractStringIfBlank(java.lang.String pStr, java.lang.String pDefault)
pStr
- The source stringpDefault
- The string to return if pStr is blank.isBlank(String)
public static java.lang.String expandEntries(java.lang.String pValue, java.util.Map pMap, java.lang.String pOpen, java.lang.String pClose)
This method is not particularly efficient.
pValue
- the string value containing curly brace
map keys to be replaced.pMap
- the value mappOpen
- the opening string around the variable name. Typically
"{" or "${"pClose
- the closing string around the variable name Typically
"}".public static java.lang.String expandEntries(java.lang.String pValue, java.util.Map pMap)
This method is not particularly efficient.
pValue
- the source stringpMap
- the value map.public static java.lang.String joinStrings(java.lang.String[] pStrings, char pSeparator)
pStrings
- the strings to be joinedpSeparator
- the character to use as a separatorpublic static java.lang.String joinStringsWithQuoting(java.lang.String[] pStrings, char pSeparator)
pStrings
- the strings to be quotedpSeparator
- the character to use as a separatorpublic static java.lang.String joinStringsWithNonRepeatingSeparator(java.lang.String[] pStrings, char pSeparator, boolean pLeadingSeparator, boolean pTrailingSeparator)
pStrings
- the strings to be quotedpSeparator
- the character to use as a separatorpLeadingSeparator
- whether the returned value should start with pSeparatorpTrailingSeparator
- whether the returned value should end with pSeparatorpublic static java.lang.String escapeHtmlString(java.lang.String pStr)
The characters &, <, >, and " are all converted to &&, &<, &>, and &" respectively.
pStr
- the string to be escapedpublic static java.lang.String escapeHtmlString(java.lang.String pStr, boolean pEscapeAmp)
The characters &, <, >, and " are all converted to &&, &<, &>, and &" respectively.
pStr
- the string to be escapedpEscapeAmp
- whether to escape ampersandpublic static java.lang.String convertStringToPropertiesFileFormat(java.lang.String theString, boolean escapeSpace, boolean escapeUnicode)
theString
- The string to encodeescapeSpace
- Whether or not spaces should be escapedescapeUnicode
- Whether or not unicode characters should be escapedpublic static java.lang.String convertStringFromPropertiesFileFormat(java.lang.String in)
in
- The string to convertpublic static java.lang.String[] join(java.lang.String[] pFirst, java.lang.String[] pSecond)
pFirst
- The first string array.pSecond
- The second string array.public static java.lang.String removeConsecutiveStrings(java.lang.String pString, char pToRemove)
pString
- the string to remove slashes frompToRemove
- The character to remove.public static java.lang.String removeConsecutiveStrings(java.lang.String pString, java.lang.String pToRemove)
pString
- the string to remove slashes frompToRemove
- The string to remove.public static java.lang.String or(java.lang.String... pStrings)
pStrings
- input streams.