public class StrUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
CRLF |
static String |
CRLF2 |
static String |
DQT |
static String |
LINE_TERMINATOR |
static String |
SQT |
static Charset |
UTF8 |
static String |
UTF8_STR |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
areEqual(String s1,
String s2,
boolean caseSensitive)
Returns true if two strings are equal.
|
static int |
compare(String s1,
String s2)
Null-safe, case-sensitive comparison of two strings.
|
static int |
compareIgnoreCase(String s1,
String s2)
Null-safe, case-insensitive comparison of two strings.
|
static String |
enquoteDouble(String value)
Surround value with double quotes if not already so.
|
static String |
enquoteSingle(String value)
Surround value with single quotes if not already so.
|
static int |
extractInt(String value)
Extracts an integer portion at the beginning of a string.
|
static String |
extractIntPrefix(String value)
Extracts an integer portion at the beginning of a string.
|
static String |
formatMessage(String msg,
Locale locale,
Object... args)
Formats a message.
|
static String |
formatMessage(String msg,
Object... args)
Formats a message.
|
static String |
fromList(Iterable<?> list)
Builds a newline-delimited string from a list.
|
static String |
fromList(Iterable<?> list,
String delimiter)
Builds a delimited string from a list.
|
static String |
fromList(Iterable<?> list,
String delimiter,
String dflt)
Builds a delimited string from a list.
|
static String |
getLabel(String id,
Locale locale,
Object... args)
Returns a formatted message given a label identifier.
|
static String |
getLabel(String id,
Object... args)
Returns a formatted message given a label identifier.
|
static String |
piece(String text,
String delimiter)
Returns the first piece of text as delimited by delimiter.
|
static String |
piece(String text,
String delimiter,
int position)
Returns the specified piece of text as delimited by delimiter.
|
static String |
piece(String text,
String delimiter,
int start,
int end)
Performs the equivalent of the MUMPS piece function.
|
static String[] |
split(String text,
String delimiter)
Splits a string using the specified delimiter.
|
static String[] |
split(String text,
String delimiter,
int count)
Splits a string using the specified delimiter.
|
static String[] |
split(String text,
String delimiter,
int count,
boolean nonull)
Splits a string using the specified delimiter.
|
static StringBuilder |
strAppend(StringBuilder sb,
String value)
Append a value to a string builder, using specified separator.
|
static StringBuilder |
strAppend(StringBuilder sb,
String value,
String separator)
Append a value to a string builder, using specified separator.
|
static String |
strAppend(String text,
String value)
Append a value to a text string, using default separator (comma).
|
static String |
strAppend(String text,
String value,
String separator)
Append a value to a text string, using specified separator.
|
static String |
stripQuotes(String value)
Strip enclosing quotes (double or single) from a string.
|
static String |
strTruncate(String value,
int maxLength)
Truncates a string if it exceeds a maximum length, appending an ellipsis to the end.
|
static boolean |
toBoolean(String text)
Converts a text value to a boolean result.
|
static String |
toCamelCaseLower(String text)
Converts a string to lower camel case using whitespace and underscores as word boundaries.
|
static String |
toCamelCaseUpper(String text)
Converts a string to upper camel case using whitespace and underscores as word boundaries.
|
static String |
toDelimitedStr(String delimiter,
Object... params)
Converts a parameter list into a delimited string
|
static double |
toDouble(String text)
Converts a text value to a double.
|
static int |
toInt(String text)
Converts a text value to an integer.
|
static List<String> |
toList(String text)
Converts a string containing a '\n'-delimited list of elements to a string list.
|
static List<String> |
toList(String text,
List<String> list)
Converts a string containing a '\n'-delimited list of elements to a string list.
|
static List<String> |
toList(String text,
List<String> list,
String delimiter)
Converts a string containing a delimited list of elements to a string list.
|
static List<String> |
toList(String text,
String delimiter)
Converts a string containing a delimited list of elements to a string list.
|
static long |
toLong(String text)
Converts a text value to a long integer.
|
static String |
xlate(String text,
String from,
String to)
Replaces one set of characters with another.
|
public static final String CRLF
public static final String CRLF2
public static final String LINE_TERMINATOR
public static final String DQT
public static final String SQT
public static final Charset UTF8
public static final String UTF8_STR
public static String[] split(String text, String delimiter)
text - The string to split.delimiter - The delimiter for the split operation.public static String[] split(String text, String delimiter, int count)
text - The string to split.delimiter - The delimiter for the split operation.count - Specifies a minimum number of elements to be returned. If the result of the
split operation results in fewer elements, the returned array is expanded to
contain the minimum number of elements.public static String[] split(String text, String delimiter, int count, boolean nonull)
text - The string to split.delimiter - The delimiter for the split operation.count - Specifies a minimum number of elements to be returned. If the result of the
split operation results in fewer elements, the returned array is expanded to
contain the minimum number of elements.nonull - If true, the returned array is guaranteed not to contain null values by
replacing every occurrence of a null value with an empty string.public static String strTruncate(String value, int maxLength)
value - String value to modify.maxLength - Maximum length for string.public static StringBuilder strAppend(StringBuilder sb, String value)
sb - StringBuilder instance to append to.value - Value to append.public static StringBuilder strAppend(StringBuilder sb, String value, String separator)
sb - StringBuilder instance to append to.value - Value to append.separator - String to use as separator.public static String strAppend(String text, String value)
text - Text string to append to.value - Value to append.public static String strAppend(String text, String value, String separator)
text - Text string to append to.value - Value to append.separator - String to use as separator.public static String toDelimitedStr(String delimiter, Object... params)
delimiter - Delimiter to use.params - The parameter list.public static String piece(String text, String delimiter)
text - Text to piece.delimiter - Delimiter for piecing.public static String piece(String text, String delimiter, int position)
text - Text to piece.delimiter - Delimiter for piecing.position - Position of piece to extract.public static String piece(String text, String delimiter, int start, int end)
text - Text to piece.delimiter - Delimiter for piecing.start - First piece to return.end - Last piece to return.public static int extractInt(String value)
value - String value to parsepublic static String extractIntPrefix(String value)
value - String value to parsepublic static String stripQuotes(String value)
value - Input value.public static String enquoteDouble(String value)
value - Value to enquote.public static String enquoteSingle(String value)
value - Value to enquote.public static int compare(String s1, String s2)
s1 - First string to compare.s2 - Second string to compare.public static int compareIgnoreCase(String s1, String s2)
s1 - First string to compare.s2 - Second string to compare.public static boolean areEqual(String s1, String s2, boolean caseSensitive)
s1 - First string to compare.s2 - Second string to compare.caseSensitive - If true, perform a case-sensitive comparison.public static boolean toBoolean(String text)
text - Value to convert. Non-zero numeric values or values beginning with a T, t, Y, or
y evaluate to true.public static int toInt(String text)
text - Value to convert.public static long toLong(String text)
text - Value to convert.public static double toDouble(String text)
text - Value to convert.public static List<String> toList(String text)
text - The string containing the '\n'-delimited elements.public static List<String> toList(String text, String delimiter)
text - The string containing the delimited elements.delimiter - The delimiter that separates the elements in the input string.public static List<String> toList(String text, List<String> list)
text - The string containing the '\n'-delimited elements.list - The string list that will receive the parsed elements. If null, a new list is
created. If not null, the list is cleared before adding elements.public static List<String> toList(String text, List<String> list, String delimiter)
text - The string containing the delimited elements.list - The string list that will receive the parsed elements. If null, a new list is
created. If not null, the list is cleared before adding elements.delimiter - The delimiter that separates the elements in the input string.public static String fromList(Iterable<?> list)
list - The list of strings to concatenate.public static String fromList(Iterable<?> list, String delimiter)
list - The list of strings to concatenate.delimiter - The delimiter to use to separate elements.public static String fromList(Iterable<?> list, String delimiter, String dflt)
list - The list of strings to concatenate.delimiter - The delimiter to use to separate elements.dflt - The default value to use if a list entry is null.public static String toCamelCaseUpper(String text)
text - Text to convert.public static String toCamelCaseLower(String text)
text - Text to convert.public static String xlate(String text, String from, String to)
text - The string to modify.from - The list of characters to be replaced.to - The list of replacement characters.public static String formatMessage(String msg, Locale locale, Object... args)
msg - Message to format or, if starts with "@", a label reference.locale - Optional localeargs - Optional replaceable parameters.public static String formatMessage(String msg, Object... args)
msg - Message to format or, if starts with "@", a label reference.args - Optional replaceable parameters.public static String getLabel(String id, Object... args)
id - A label identifier.args - Optional replaceable parameters.public static String getLabel(String id, Locale locale, Object... args)
id - A label identifier.locale - The locale.args - Optional replaceable parameters.Copyright © 2023 Fujion Framework. All rights reserved.