public class Format
extends java.lang.Object
The places in the format strings where the arguments will be inserted are
marked with %1
to %9
thus allowing reordering.
Arguments must be objects, primitive types are not allowed. If needed,
primitive bytes must be boxed by their standard wrappers.
Constructor and Description |
---|
Format() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
center(java.lang.String str,
int length,
java.lang.String fill)
Produce a string where
str is centered. |
static java.lang.String |
format(java.lang.Object mask,
java.lang.Object... args)
Parses a format string with arguments marked by %0 to %9
(max.) and substitutes in the arguments accordingly.
|
static int |
getMaxStringLength(java.lang.String[] strings)
Get the length of the longest string in a set of strings.
|
static java.lang.String |
lpad(java.lang.String str,
int length,
java.lang.String fill)
Left pads the given string with the fill until
length
characters are reached. |
static void |
main(java.lang.String[] args)
Test routines.
|
static java.lang.String |
replace(java.lang.String str1,
java.lang.String str2,
java.lang.String str3)
Replaces all occurencies of
str2 in str1 by str3 |
static java.lang.String |
rpad(java.lang.String str,
int length,
java.lang.String fill)
Right pads the given string with the fill until
length
is reached. |
static java.lang.String |
toString(java.lang.Object obj)
Make a string from objects.
|
static java.lang.String |
trimLeft(java.lang.String str)
Trims the left side of a string.
|
static java.lang.String |
trimRight(java.lang.String str)
Trims the right side of a string.
|
public static java.lang.String format(@NotNull java.lang.Object mask, java.lang.Object... args)
mask
- format stringargs
- further arguments (minimal length needed is as much as the
highest digit used in the markers)public static java.lang.String toString(@Nullable java.lang.Object obj)
Handles arrays specially.
obj
- objectpublic static int getMaxStringLength(@NotNull java.lang.String[] strings)
strings
- the set of strings as an arraypublic static java.lang.String rpad(@NotNull java.lang.String str, int length, @NotNull java.lang.String fill)
length
is reached.str
- the string to be right paddedlength
- the length when the padding stopsfill
- the string with which str
is paddedlength
charspublic static java.lang.String lpad(@NotNull java.lang.String str, int length, @NotNull java.lang.String fill)
length
characters are reached.str
- the string to be left paddedlength
- the length when the padding stopsfill
- the string with which str
is paddedlength
charspublic static java.lang.String center(@NotNull java.lang.String str, int length, @NotNull java.lang.String fill)
str
is centered.
str
is left padded with fill.str
- the string to be centeredlength
- the length where str
is centeredfill
- the string with which str
is paddedlength
charspublic static java.lang.String replace(@NotNull java.lang.String str1, @NotNull java.lang.String str2, @NotNull java.lang.String str3)
str2
in str1
by str3
str1
- in this string substrings will be replaced, must be != nullstr2
- string to be replaced, must be != null and != ""str3
- string to replace, must be != nullpublic static java.lang.String trimLeft(@Nullable java.lang.String str)
str
- string to trimpublic static java.lang.String trimRight(@Nullable java.lang.String str)
str
- string to trimpublic static void main(java.lang.String[] args)
args
- unused