public class StringUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String[] |
EMPTY_STRING |
static String |
FALSE |
static String |
TRUE |
static Collection<String> |
TRUE_FALSE_ARRAY |
Modifier and Type | Method and Description |
---|---|
static String |
cleanPathForWindows(String pathString) |
static String |
convertToQuotelessValue(String value)
Returns
value without surrounding quotes. |
static String |
escapeBackticks(String text) |
static int |
findEndWord(String text,
int offset,
Predicate<Character> isValidChar)
Returns the end word offset from the right of the given
offset
and -1 if no word. |
static int |
findStartWord(String text,
int offset,
Predicate<Character> isValidChar)
Returns the start word offset from the left of the given
offset
and -1 if no word. |
static String |
getDefaultString(String text)
Given a string will give back a non null string that is either the given
string, or an empty string.
|
static int |
getFrontWhitespaceLength(String text)
Returns the number of consecutive whitespace characters in front of text
|
static int |
getNumberOfNewLines(String text,
boolean isWhitespace,
String delimiter,
int newLineLimit)
Given a string that is only whitespace, this will return the amount of
newline characters.
|
static int |
getOffsetAfterWhitespace(String text,
int endOffset)
Traverses backwards from the endOffset until it finds a whitespace character.
|
static String |
getStartWhitespaces(String lineText)
Returns the start whitespaces of the given line text.
|
static String |
getString(Object obj) |
static int |
getTrailingWhitespaceLength(String text)
Returns the number of consecutive whitespace characters from the end of text
|
static String |
getWhitespaces(String text,
int start,
int end)
Returns the whitespaces from the given range start/end of the given text.
|
static boolean |
isBlank(String value)
Checks if a string is null or consists of only whitespace characters.
|
static boolean |
isEmpty(String value) |
static boolean |
isQuote(char c) |
static boolean |
isQuoted(String value)
Returns true if
value has matching surrounding quotes
and false otherwise. |
static boolean |
isSimilar(String reference,
String current)
Uses Levenshtein distance to determine similarity between strings
|
static boolean |
isTagOutsideOfBackticks(String text) |
static boolean |
isWhitespace(String value) |
static boolean |
isWhitespace(String value,
int index) |
static boolean |
isWhitespace(String value,
int index,
int end) |
static String |
lTrim(String value) |
static String |
normalizeSpace(String str)
Returns the result of normalize space of the given string.
|
static void |
normalizeSpace(String str,
StringBuilder b)
Normalizes the whitespace characters of a given string and applies it to the
given string builder.
|
static String |
trimNewLines(String value) |
static void |
trimNewLines(String value,
StringBuilder s) |
public static final String[] EMPTY_STRING
public static final String TRUE
public static final String FALSE
public static final Collection<String> TRUE_FALSE_ARRAY
public static boolean isEmpty(String value)
public static boolean isQuote(char c)
public static boolean isWhitespace(String value, int index)
public static boolean isWhitespace(String value, int index, int end)
public static boolean isWhitespace(String value)
public static boolean isBlank(String value)
value
- The string to checktrue
if any of the below hold, and false otherwise:
null
public static void normalizeSpace(String str, StringBuilder b)
str
- public static String normalizeSpace(String str)
str
- public static String getStartWhitespaces(String lineText)
lineText
- public static String getWhitespaces(String text, int start, int end)
start
- the range startend
- the range endtext
- the textpublic static void trimNewLines(String value, StringBuilder s)
public static int getNumberOfNewLines(String text, boolean isWhitespace, String delimiter, int newLineLimit)
text
- isWhitespace
- delimiter
- public static String getDefaultString(String text)
text
- public static int getOffsetAfterWhitespace(String text, int endOffset)
text
- endOffset
- non-inclusivepublic static int getFrontWhitespaceLength(String text)
text
- String of interestpublic static int getTrailingWhitespaceLength(String text)
text
- String of interestpublic static boolean isTagOutsideOfBackticks(String text)
public static int findStartWord(String text, int offset, Predicate<Character> isValidChar)
offset
and -1 if no word.text
- the textoffset
- the offsetisValidChar
- predicate to check if current character belong to the
word.offset
and -1 if no word.public static int findEndWord(String text, int offset, Predicate<Character> isValidChar)
offset
and -1 if no word.text
- the textoffset
- the offsetisValidChar
- predicate to check if current character belong to the
word.offset
and -1 if no word.public static String convertToQuotelessValue(String value)
value
without surrounding quotes.
If value
does not have matching surrounding quotes,
returns value
.value
- value
without surrounding quotes.public static boolean isQuoted(String value)
value
has matching surrounding quotes
and false otherwise.value
- value
has matching surrounding quotes.Copyright © 2021. All rights reserved.