Package smile.util
Interface Strings
public interface Strings
String utility functions.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
fill
(char ch, int len) Returns the string with a single repeated character to a specific length.static String
format
(double x) Returns the string representation of a floating number without trailing zeros.static String
format
(double x, boolean trailingZeros) Returns the string representation of a floating number.static String
format
(float x) Returns the string representation of a floating number without trailing zeros.static String
format
(float x, boolean trailingZeros) Returns the string representation of a floating number.static String
htmlEscape
(String input) Turn special characters into HTML character references.static String
htmlEscape
(String input, String encoding) Turn special characters into HTML character references.static boolean
Returns true if the string is null or empty.static String
Left pad a string with a specified character.static String
ordinal
(int i) Returns the string representation of ordinal number with suffix.static double[]
Parses a double array in format '[1.0, 2.0, 3.0]'.static int[]
Parses an integer array in format '[1, 2, 3]'.static String
Right pad a string with a specified character.static String
Unescapes a string that contains standard Java escape sequences.
-
Field Details
-
DECIMAL_FORMAT
Decimal format for floating numbers.
-
-
Method Details
-
isNullOrEmpty
Returns true if the string is null or empty.- Parameters:
s
- the string.- Returns:
- true if the string is null or empty.
-
unescape
Unescapes a string that contains standard Java escape sequences.- Parameters:
s
- the string.- Returns:
- the translated string.
-
htmlEscape
Turn special characters into HTML character references.- Parameters:
input
- the (unescaped) input string- Returns:
- the escaped string
-
htmlEscape
Turn special characters into HTML character references.- Parameters:
input
- the (unescaped) input stringencoding
- the name of a supportedcharset
- Returns:
- the escaped string
-
ordinal
Returns the string representation of ordinal number with suffix.- Parameters:
i
- the ordinal number.- Returns:
- the string representation of ordinal number with suffix.
-
leftPad
Left pad a string with a specified character.- Parameters:
s
- the string to pad out, may be nullsize
- the size to pad topadChar
- the character to pad with- Returns:
- left padded String or original String if no padding is necessary, null if null String input
-
rightPad
Right pad a string with a specified character.- Parameters:
s
- the string to pad out, may be nullsize
- the size to pad topadChar
- the character to pad with- Returns:
- left padded String or original String if no padding is necessary, null if null String input
-
fill
Returns the string with a single repeated character to a specific length.- Parameters:
ch
- the character.len
- the length of string.- Returns:
- the string.
-
format
Returns the string representation of a floating number without trailing zeros.- Parameters:
x
- a real number.- Returns:
- the string representation.
-
format
Returns the string representation of a floating number.- Parameters:
x
- a real number.trailingZeros
- the flag if removes the trailing zeros.- Returns:
- the string representation.
-
format
Returns the string representation of a floating number without trailing zeros.- Parameters:
x
- a real number.- Returns:
- the string representation.
-
format
Returns the string representation of a floating number.- Parameters:
x
- a real number.trailingZeros
- the flag if removes the trailing zeros.- Returns:
- the string representation.
-
parseIntArray
Parses an integer array in format '[1, 2, 3]'. Returns null if s is null or empty.- Parameters:
s
- the string.- Returns:
- the array.
-
parseDoubleArray
Parses a double array in format '[1.0, 2.0, 3.0]'. Returns null if s is null or empty.- Parameters:
s
- the string.- Returns:
- the array.
-