public final class StringUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
consoleFormat(java.lang.String string)
Formats specified string for console suitable representation.
|
static java.lang.String |
consoleFormat(java.lang.String string,
int maxLength)
Formats specified string for console suitable representation.
|
static java.lang.String |
getMaskedPassword(java.lang.String string)
Masks password displaying to user.
|
static boolean |
isAsciiWhitespacesOnly(java.lang.CharSequence cs)
Checks if specified characters sequence is empty or contains only ascii whitespace characters.
|
static boolean |
isDecimalInt(java.lang.CharSequence cs)
Checks if specified characters sequence represents a non negative decimal number.
|
static boolean |
isEmpty(java.lang.CharSequence cs)
Returns true if characters sequence is empty (length=0) or null.
|
static java.lang.String |
nullsafeToString(java.lang.Object o)
Returns Null safe string representation of specified object.
|
static java.lang.String |
nullsafeTrim(java.lang.CharSequence cs)
Returns a trimmed value for specified charsequence
|
static java.lang.String |
pad(java.lang.String str,
boolean left,
int width,
char padChar)
Pads a String with a specified character.
|
static java.lang.String |
removePrefix(java.lang.String string,
java.lang.String prefix)
Removes a prefix from a string.
|
public static boolean isEmpty(java.lang.CharSequence cs)
cs
- characters sequence to test.public static java.lang.String nullsafeTrim(java.lang.CharSequence cs)
cs
- charsequence to trim.public static java.lang.String nullsafeToString(java.lang.Object o)
o
- object to convert to String.o.toString()
or ""
if o==null
.public static boolean isAsciiWhitespacesOnly(java.lang.CharSequence cs)
cs
- characters sequence to check.public static boolean isDecimalInt(java.lang.CharSequence cs)
cs
- characters sequence to check.public static java.lang.String consoleFormat(java.lang.String string)
All EOL char sequences are replaced with a single system line.separator, and all other whitespace sequences are replaced with a single space.
String larger than 10KB are trimmed.
string
- string to format. Nulls are allowed.public static java.lang.String consoleFormat(java.lang.String string, int maxLength)
All EOL char sequences are replaced with a single system line.separator, and all other whitespace sequences are replaced with a single space.
string
- string to format. Nulls are allowed.maxLength
- maximum number of characters to show or negative if the string cannot be trimmed.public static java.lang.String removePrefix(java.lang.String string, java.lang.String prefix)
string
- original string. May be null.prefix
- prefix to to check and remove. May be null.public static java.lang.String getMaskedPassword(java.lang.String string)
string
- password.public static java.lang.String pad(java.lang.String str, boolean left, int width, char padChar)
str
- string to pad. Null is treated as empty string.left
- true if left pad, false if rightwidth
- with of the padded stringpadChar
- character to use for paddingCopyright © Copyright 2006-2019 The Scriptella Project Team.