public class TextUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String[] |
EMPTY_STRING_ARRAY |
static List<String> |
EMPTY_STRING_LIST |
static String |
NULL_PRINT |
static String |
SECOND_LINE_INDENT |
| Constructor and Description |
|---|
TextUtil() |
| Modifier and Type | Method and Description |
|---|---|
static String |
escapeXml(String text) |
static int |
findFirstInstanceOf(String toBeSearched,
int searchFrom,
String... toBeFound)
Find the first occurrence of one of an array of possible strings in another string,
starting at the specified position.
|
static int |
findLastInstanceOf(String toBeSearched,
int searchFrom,
String... toBeFound) |
static String |
format(String pattern,
Object... args)
Creates a message with {} instances replaced with values from the args
list, similar to how SLF4J formats messages.
|
static String |
padRight(String base,
String repeatString,
int totalLength)
Pads the right side of the string with repeating repeatString's until the
specified totalLength is reached.
|
static void |
println(PrintStream out,
int maxLineLength,
String linePrefix,
String content)
println to the passed PrintStream, wrapped to a specified line length.
|
static void |
println(PrintStream out,
int maxLineLength,
String linePrefix,
String pattern,
Object... args)
println to the passed PrintStream using the format {} patterning and wrapping
to a specified line length.
|
static void |
println(PrintStream out,
String pattern,
Object... args)
println to the passed PrintStream using the format {} patterning.
|
static String |
repeat(String base,
int repeat) |
static boolean |
toBoolean(String value)
Parses a string to a boolean.
|
static String |
trimToEmpty(String source) |
static String |
trimToNull(String source) |
static List<String> |
wrap(String in,
int length)
Wraps text to be no longer than the specified length, if possible.
|
static List<String> |
wrap(String in,
int length,
String prefix,
String wrappedLineIndent)
Wraps text to be no longer than the specified length, if possible, and adds
a prefix to each line, which is subtracted from the overall length.
|
public static final String[] EMPTY_STRING_ARRAY
public static final String NULL_PRINT
public static final String SECOND_LINE_INDENT
public static void println(PrintStream out, String pattern, Object... args)
out - pattern - args - public static void println(PrintStream out, int maxLineLength, String linePrefix, String pattern, Object... args)
out - maxLineLength - Max characters to place on one line (best effort)linePrefix - Each line will receive this prefix, which counts toward line lengthpattern - Replacement pattern, using the format methods in this classargs - Arguments for replacementpublic static void println(PrintStream out, int maxLineLength, String linePrefix, String content)
out - maxLineLength - Max characters to place on one line (best effort)linePrefix - Each line will receive this prefix, which counts toward line lengthcontent - String to be split up.public static String format(String pattern, Object... args)
pattern - A string pattern with may contain {} references to items in the args list.args - Values to call .toString on to fill in, in order, the {} refs.public static String padRight(String base, String repeatString, int totalLength)
base - repeatString - totalLength - public static boolean toBoolean(String value)
value - public static List<String> wrap(String in, int length, String prefix, String wrappedLineIndent)
in - length - prefix - wrappedLineIndent - Added to each wrapped line after the prefix, not including the first line.public static List<String> wrap(String in, int length)
in - length - public static int findFirstInstanceOf(String toBeSearched, int searchFrom, String... toBeFound)
toBeSearched - searchFrom - Same symantics as String.indexOf(String, int)toBeFound - public static int findLastInstanceOf(String toBeSearched, int searchFrom, String... toBeFound)
toBeSearched - searchFrom - Start looking from this position and to the lefttoBeFound - Copyright © 2017. All rights reserved.