public class StringUtils
| Modifiers | Name | Description |
|---|---|---|
static java.lang.String |
ASTERISK |
|
static java.lang.String |
BACKWARD_SOLIDUS |
|
static java.lang.String |
BOOLEAN_FALSE_VALUE |
|
static java.lang.String |
BOOLEAN_TRUE_VALUE |
|
static java.lang.String |
BREAK_LINE_HTML_TAG |
Html tag that is used for breaking lines |
static char |
CHAR_WITH_ZERO_WIDTH |
Zero-width space |
static java.lang.String |
COLON |
|
static char |
DEFAULT_CSV_DELIMITER |
Default Comma-Separated-Values sign |
static char |
DEFAULT_FILENAME_WHITESPACE_CHAR |
Default char that it used instead of whitespaces in file names |
static java.lang.String |
DEFAULT_NEWLINE |
New line elements that are considered default |
static java.lang.String |
DOUBLE_QUOTE |
|
static char |
ELLIPSIS |
Series of three dots as a symbol |
static java.lang.String |
EMPTY |
|
static java.lang.String |
GREATER_THAN_SIGN |
|
static java.lang.String |
LESS_THAN_SIGN |
|
static java.lang.String |
NEWLINE |
OS dependent line separator |
static java.lang.String |
QUESTION_MARK |
|
static java.lang.String |
QUOTE |
|
static java.lang.String |
SOLIDUS |
|
static java.lang.String |
VERTICAL_BAR |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static java.lang.String |
addEndingDotIfNecessary(java.lang.String value)Puts a full stop at the end of the sentence, if there is no dot |
|
public static java.lang.String |
capitalize(java.lang.String string)Null safe method; capitalizes the word |
|
public static boolean |
containsIgnoreCase(java.lang.String str, java.lang.String searchStr)Determines whether a string contains a substring. |
|
public static java.lang.String |
createFileName(java.lang.String str, char whitespaceChar)Replaces whitespaces from the file name |
|
public static java.lang.String |
createFileName(java.lang.String str)Replaces the whitespaces from the file name replacing them with the DEFAULT_FILENAME_WHITESPACE_CHAR |
|
public static java.lang.String |
createFileName2(java.lang.String str, char replace)Replaces all non letter and non digit characters from the file name |
|
public static void |
createSeparatedRow(java.io.Writer writer, StringList values, char separator, char quote)Splits the content of the provided StringList with the specified separator and frame each word with the specified quotation marks |
|
public static java.lang.String |
createXmlName(java.lang.String str)Creates the appropriate name for the file in xml format by removing all the unacceptable symbols. |
|
public static java.lang.String |
decapitalize(java.lang.String name) |
|
public static java.lang.String |
defaultIfEmpty(java.lang.String string, java.lang.String defaultString)
|
|
public static java.lang.String |
emptyIfNull(java.lang.String baseString)Converts the String into a null safe parameter |
|
public static java.lang.String |
fixLineSeparator(java.lang.String xml)Null safe method, replaces all the line separators to OS friendly ones |
|
public static java.lang.String |
generateUniqueAutoincrementName(java.lang.String template, java.util.List<java.lang.String> existingNamelist) |
|
public static java.lang.String |
getEncodedStringSafely(byte[] bytes, java.lang.String encoding)Constructs the new String by decoding the provided array of bytes using the the specified charset |
|
public static java.lang.String |
getLineSeparator(java.lang.String text, boolean fileExists) |
|
public static java.lang.String |
getSubstringBeforeFirstWhitespace(java.lang.String originalString)Returns a String that is positioned before the first whitespace in the specified text |
|
public static java.lang.String |
getValidFileName(java.lang.String name)Replaces all the punctuation marks with the underscore symbol |
|
public static boolean |
hasContent(java.lang.String str)Checks if there any content in the provided String |
|
public static boolean |
isAnyNullOrEmpty(java.lang.String strArr) |
|
public static boolean |
isBlank(java.lang.String string) |
|
public static boolean |
isNullOrEmpty(java.lang.String str)Checks if the input string is empty or null |
|
public static boolean |
isNumeric(java.lang.String s)Null safe method; checks if the String is numeric |
|
public static boolean |
isValidTagName(java.lang.String tagName)Checks if the tag name is valid |
|
public static java.lang.String |
join(java.lang.String[] array, java.lang.String separator)Builds a String from the array elements and separates them with provided separator |
|
public static java.lang.String |
maybePlural(java.lang.String str, int count)Simplest possible pluralization of provided word by adding an 's' to it |
|
public static java.lang.String[] |
merge(java.lang.String[] incomingNames, java.lang.String string)Increases the size of a String array, adding the provided String to it. |
|
public static void |
normalizeLineBreak(java.io.BufferedWriter out, java.io.BufferedReader in, java.io.File file)Converts line breaks in the content into the current system line breaks. |
|
public static void |
normalizeLineBreak(java.io.BufferedWriter out, java.io.BufferedReader in, java.lang.String fileContent, boolean fileExists)Converts line breaks in the content into the current system line breaks. |
|
public static java.lang.String |
normalizeSpace(java.lang.String str)Removes multiple whitespaces if any of them appears in the provided text, replacing them with single ones |
|
public static java.lang.String |
nullIfEmtpy(java.lang.String string)Handles the input String, this method returns null, if it is empty or null |
|
public static int |
parseInt(java.lang.String str, int defaultValue)Parses the string argument into a signed decimal integer; null safe method |
|
public static java.lang.String |
quote(java.lang.String str)Null safe method; surrounds the initial String with double quotes |
|
public static StringList |
readSeparatedRow(java.lang.String row, char separator, char quote)Converts the text which was created by StringUtils.createSeparatedRow to StringList |
|
public static java.lang.String |
removeQuotes(java.lang.String str, boolean forNumbers, boolean forBooleanValues) |
|
public static java.lang.String |
removeSingleAndDoubleQuotes(java.lang.String input)Removes leading and trailing whitespaces and single or double quotes from the provided string |
|
public static java.lang.String |
repeat(java.lang.String s, int count)Repeats the String as many times as it was asked for |
|
public static java.lang.String |
replace(java.lang.String data, java.lang.String from, java.lang.String to)Replaces the provided part of a String with another one, the 'case insensitivity' option
is false by default |
|
public static java.lang.String |
replace(java.lang.String data, java.lang.String from, java.lang.String to, boolean caseInsensitive)Replaces the provided part in a String with another one with presence of the case insensitivity option |
|
public static java.lang.String |
replace(java.lang.String data, java.lang.String from, java.lang.String to, boolean caseInsensitive, boolean firstOnly)Replaces the provided part in a String with another one with the case insensitivity option. |
|
public static java.lang.String |
replaceFirst(java.lang.String data, java.lang.String from, java.lang.String to, boolean caseInsensitive)Replaces the first entry of the provided part in a String with another one with the case insensitivity option |
|
public static java.lang.String |
replaceRegExLineSeparatorWithUpdatedSeparator(java.lang.String text, java.lang.String lineSeparator) |
|
public static java.lang.String |
replaceRegExUnescaped(java.lang.String text)Replaces escaped sequences in the provided String by adding leading backslash |
|
public static java.lang.String |
replaceRegExUnescapedInPropertyValue(java.lang.String text) |
|
public static java.lang.String |
requestLogCountTitle(int count)Create log count title |
|
public static boolean |
sameString(java.lang.String str1, java.lang.String str2)Null safe method that checks if provided strings are equal to each other |
|
public static boolean |
sameStringLists(java.util.List<java.lang.String> strList1, java.util.List<java.lang.String> strList2)Null safe method checks if provided string lists are equal to each other. |
|
public static boolean |
sameText(java.lang.String str1, java.lang.String str2)Null safe method checks if provided strings are equal to each other ignoring case |
|
public static java.lang.String |
sanitizeFilename(java.lang.String name)Replaces a pound sign with the proper unicode symbol, also replaces the symbols that are incorrect for file naming with a dash |
|
public static java.lang.String |
singleQuote(java.lang.String str)Null safe method; surrounds initial String with single quotes |
|
public static java.lang.String[] |
sortNames(java.lang.String[] names)Sorts the String array according to Comparable natural ordering of its elements |
|
public static java.lang.String |
spacifyOnCapital(java.lang.String name)
|
|
public static java.lang.String |
specifyOnCapital(java.lang.String name)Separates the word with the whitespace aligning capital letters, also the method trims the leading and trailing whitespaces. |
|
public static java.util.List<java.lang.String> |
splitLines(java.lang.String string)Splits the text by lines |
|
public static boolean |
startsWithCaseInsensitive(java.lang.String string, java.lang.String prefix)Checks if the provided string begins with the specified prefix ignoring case |
|
public static java.lang.String |
stripStartAndEnd(java.lang.String s, java.lang.String start, java.lang.String end)Truncates the String according to given parameters |
|
public static java.lang.String |
toHtml(java.lang.String string)Transforms the String to the content of an html format document with the default max size that is 0 |
|
public static java.lang.String |
toHtml(java.lang.String string, int maxSize)Transforms the String to the content of a simple html format document, taking down the initial string
with tag depending on the presence of the newline characters in the string |
|
public static java.lang.String |
toString(java.lang.Object object)Returns the String representation of a provided {@code} Object |
|
public static java.lang.String[] |
toStringArray(java.lang.Object[] selectedOptions)Returns the String array representation of the provided Object array |
|
public static java.util.List<java.lang.String> |
toStringList(java.lang.Object[] selectedOptions)Returns the List<String> representation of the provided Object array |
|
public static java.lang.String |
toStringOrEmpty(java.lang.Object toString) |
|
public static java.lang.String |
toStringOrNull(java.lang.Object toString)Null safe method, that transforms the provided Object to the String. |
|
public static java.lang.String |
trimRight(java.lang.String str, java.lang.String substring)Trims the end of the word as many times as it equals to provided substring |
|
public static java.lang.String |
truncate(java.lang.String originalString, int limit)Reduces the length of the provided String in order to reach the limit |
|
public static java.lang.String |
truncate(java.lang.String originalString, int limit, java.lang.String ending)
|
|
public static java.lang.String |
truncateStart(java.lang.String str, int limit)Truncates the beginning of the word in order to reach limit |
|
public static java.lang.String |
truncateStartOfUrl(java.lang.String urlString, int limit)Truncates the query parameters from the String url and then cuts it from the beginning
to reach the limit. |
|
public static java.lang.String |
truncateUrl(java.lang.String urlString, int limit)Truncates the query parameters from the String url and then cuts it from the end
to reach the limit. |
|
public static java.lang.String |
unquote(java.lang.String str)Removes leading and trailing double quotes from the provided string |
|
public static java.lang.String |
unquoteStartAndEnd(java.lang.String str)Removes leading and/or trailing double quotes from the provided string |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Html tag that is used for breaking lines
Zero-width space
Default Comma-Separated-Values sign
Default char that it used instead of whitespaces in file names
New line elements that are considered default
Series of three dots as a symbol
OS dependent line separator
Puts a full stop at the end of the sentence, if there is no dot
value - the provided String in the end of which a full stop should be putString ends with dot initial String in case if there was a dot in the end of it.Null safe method; capitalizes the word
string - the initial wordDetermines whether a string contains a substring. The search is made case-insensitively.
str - the string to search {@param searchStr} insearchStr - the string to search fortrue if {@param searchStr} is found in {@param str}, false otherwiseReplaces whitespaces from the file name
str - the file name where all the whitespaces should be replaced with a specified symbol
whitespaceCharwhitespaceChar - the symbol that replaces all the whitespace in the file nameReplaces the whitespaces from the file name replacing them with the DEFAULT_FILENAME_WHITESPACE_CHAR
str - the filename where all the whitespaces should be replaced with
DEFAULT_FILENAME_WHITESPACE_CHARString with the replaced whitespacesReplaces all non letter and non digit characters from the file name
str - the file namereplace - the symbol for replacingSplits the content of the provided StringList with the specified separator and frame each word with the specified quotation marks
writer - character stream which contains resultvalues - list of Stringsseparator - char that separates wordsquote - char that is used as a quotation mark to frame each wordCreates the appropriate name for the file in xml format by removing all the unacceptable symbols. This method also validate file name {
str - the initial String to be transformed
defaultString when provided string is null or empty,
else the method returns initial string Converts the String into a null safe parameter
baseString - the null safe StringString in case when provided baseString is null or empty,
else the method returns initial baseStringNull safe method, replaces all the line separators to OS friendly ones
xml - the String to be transformedString Constructs the new String by decoding the provided array of bytes using the the specified charset
bytes - the array of bytes to be decoded into Stringencoding - the name of a supported java.nio.charset.CharsetString Returns a String that is positioned before the first whitespace in the specified text
originalString - the String to be cutString that contains all the symbols before the first whitespace in initial StringReplaces all the punctuation marks with the underscore symbol
name - the String with the punctuation marks in its structureString without any punctuation marks Checks if there any content in the provided String
str - the word to be checkedtrue if there is any content in the str, false otherwiseChecks if the input string is empty or null
str - the word for checking Null safe method; checks if the String is numeric
s - the String to be checkedtrue if the provided String consists of decimal or floating-point number,
admits '+' and 'minus' symbols beforehead, returns false if the provided String is null or
its content is not numericChecks if the tag name is valid
tagName - the tag to be checkedtrue if provided String matches following conditions:
- not null
- not empty
- the length of it is less or equal to StringUtils#MAX_TAG_LEN
- should consists of letters or whitespaces and letters
returns false in any other case. Builds a String from the array elements and separates them with provided separator
array - the initial array all the elements of which should be unitedseparator - the word that should separate united elementsString from the array contentsSimplest possible pluralization of provided word by adding an 's' to it
str - the word to be pluralizedcount - should be equals any number but 1 in order to evaluate transformationcount was equal to 1 Increases the size of a String array, adding the provided String to it.
incomingNames - the initial array to be increasedstring - the String that should be added into incomingNamesincomingNames and stringConverts line breaks in the content into the current system line breaks.
out - where we write the content with the current system line breaksin - where we read the contentfile - from where existing line breaks will be detectedConverts line breaks in the content into the current system line breaks.
out - where we write the content with the current system line breaksin - where we read the contentfileContent - existing file text to detect current line breaksfileExists - is file being created or updatedRemoves multiple whitespaces if any of them appears in the provided text, replacing them with single ones
str - null safe parameter; the text to be formattedString with absence of multiple whitespaces; returns the empty String in case if the
initial text is empty Handles the input String, this method returns null, if it is empty or null
string - the word for handlingnull if provided string is empty or consists of whitespace/s only,
else the method returns the initial wordParses the string argument into a signed decimal integer; null safe method
str - the String to be parseddefaultValue - returns this value in case of the str parameter is null or {@exception NullFormatException} Null safe method; surrounds the initial String with double quotes
str - the initial String; it should not starts or end with double quotesString surrounded by double quotesConverts the text which was created by StringUtils.createSeparatedRow to StringList
row - the provided String to be separatedseparator - the char element which is considered as a separating elementquote - the quotation mark which is used in the rowStringList that consists of provided String elementsRemoves leading and trailing whitespaces and single or double quotes from the provided string
input - the word to be transformed Repeats the String as many times as it was asked for
s - null safe parameter; the text to be repeatedcount - the decimal parameter that shows the necessarily number of repeatingString that was copied as many times as the count variable determined Replaces the provided part of a String with another one, the 'case insensitivity' option
is false by default
data - the provided String to be changedfrom - the part of the data that should be changedto - from will be changed to that variableString Replaces the provided part in a String with another one with presence of the case insensitivity option
data - the String to be changedfrom - the part of the data that should be changedto - from will be changed to that variablecaseInsensitive - the case insensitivity optionString Replaces the provided part in a String with another one with the case insensitivity option. Also it allows
to choose either one or every entry should be changed
data - the String to be changedfrom - the part of the data that should be changedto - from will be changed to that variablecaseInsensitive - the setting of case-sensitivity; true - ignore case, false - consider casefirstOnly - the setting that figured out if the first entry only should be replacedString Replaces the first entry of the provided part in a String with another one with the case insensitivity option
data - the String to be changedfrom - the part of the data that should be changedto - from will be changed to that variablecaseInsensitive - the case insensitivity optionString Replaces escaped sequences in the provided String by adding leading backslash
text - the initial String in which there are symbols to be replacedString in which escaped sequences were replaced by adding leading backslashCreate log count title
count - number of item in log listNull safe method that checks if provided strings are equal to each other
str1 - The first word to comparestr2 - The second word to comparetrue if both of the arguments are nullable or they are equal to each other considering case;
false otherwise Null safe method checks if provided string lists are equal to each other. According to
this method the lists are equal if they both are null or contain the same amount
of equal items.
strList1 - The first string list to comparestrList2 - The second string list to comparetrue if the arguments are equal to each other, or both of them are null;
false otherwiseNull safe method checks if provided strings are equal to each other ignoring case
str1 - The first word to comparestr2 - The second word to comparetrue if the arguments are equal to each other ignoring case, or both of them are nullable;
false otherwiseReplaces a pound sign with the proper unicode symbol, also replaces the symbols that are incorrect for file naming with a dash
name - the provided file name Null safe method; surrounds initial String with single quotes
str - the initial String; it should not starts or end with single quotesString surrounded by single quotes Sorts the String array according to Comparable natural ordering of its elements
names - the array to be sortedSeparates the word with the whitespace aligning capital letters, also the method trims the leading and trailing whitespaces.
name - {theStringSplits the text by lines
string - the text to be split, not null value is requiredstring Checks if the provided string begins with the specified prefix ignoring case
string - the initial String to be validatedprefix - the String prefix for validatingtrue if the string begins with the prefix ignoring case; else returns false Truncates the String according to given parameters
s - the String to be truncatedstart - should be equal to the beginning of the s to remove it from the provided send - should be equal to the end of the s to remove it from provided sString Transforms the String to the content of an html format document with the default max size that is 0
string - the initital String to be transformedString Transforms the String to the content of a simple html format document, taking down the initial string
with
tag depending on the presence of the newline characters in the string
string - the initial String to be transformedmaxSize - limits the length of the result String, it includes the default opening tags length ()
and the text that precede the newline character. The excess text is replaced by ellipses.
0 value means infinite size of the resulting text
any other value restricts result StringString that is transformed into the content of an html format document Returns the String representation of a provided {@code} Object
object - the object which toString() method we want to callString representation of an Object Returns the String array representation of the provided Object array
selectedOptions - the array every element of which should be represent as a String element in the arrayString Returns the List<String> representation of the provided Object array
selectedOptions - the array every element of which should be represent as a String element in ListList consisted of Strings, which was created from an array of Objects Null safe method, that transforms the provided Object to the String.
toString - an object to be converted to StringtoString#toString() methodTrims the end of the word as many times as it equals to provided substring
str - null safe parameter; Provided value should ends with substring for proper transformationsubstring - the sequence of characters to be truncated from the word Reduces the length of the provided String in order to reach the limit
originalString - null safe String parameter; the word to be truncatedlimit - the length of the resulting word. That value should be shorter than the length of the initial
strString
if str was null
Truncates the beginning of the word in order to reach limit
str - the word to be truncatedlimit - the length of the resulting word. That value should be shorter than the length of provided str Truncates the query parameters from the String url and then cuts it from the beginning
to reach the limit. Removed symbols will be replaced with the ellipsis
urlString - url to be truncatedlimit - quantity of symbols that should remain in url including ellipsis symbols Truncates the query parameters from the String url and then cuts it from the end
to reach the limit. Removed symbols will be replaced with the ellipsis
urlString - the url to be truncatedlimit - the quantity of symbols that should remain in urlRemoves leading and trailing double quotes from the provided string
str - null safe String parameter to be transformed. It should begins and ends with
double quotation marks for proper transformationRemoves leading and/or trailing double quotes from the provided string
str - null safe String parameter to be transformed. It should begins and/or ends with
double quotation marks for proper transformation