public final class Strings
extends java.lang.Object
String
s.Modifier and Type | Class and Description |
---|---|
static class |
Strings.StringsToJoin
Knows how to join
String s using a given delimiter. |
static class |
Strings.StringToAppend
Knows how to append a given
String to the given target, only if the target does not end with the given
String to append. |
Modifier | Constructor and Description |
---|---|
private |
Strings() |
Modifier and Type | Method and Description |
---|---|
static Strings.StringToAppend |
append(java.lang.String toAppend)
Appends a given
String to the given target, only if the target does not end with the given String
to append. |
static java.lang.String |
concat(java.lang.Object... objects)
Concatenates the given objects into a single
String . |
static java.lang.String |
escapePercent(java.lang.String value)
Escape any
% to %% to avoid interpreting it in String.format(String, Object...) . |
private static java.lang.String |
escapePercentExceptWhenFollowedBy_n(java.lang.String message) |
static java.lang.String |
formatIfArgs(java.lang.String message,
java.lang.Object... args)
Format with
String.format(String, Object...) the given message iif some args have been given otherwise juts
return the message. |
static boolean |
isNullOrEmpty(java.lang.String s)
Indicates whether the given
String is null or empty. |
static Strings.StringsToJoin |
join(java.lang.Iterable<?> toStringable)
Joins the given
Object s using a given delimiter. |
static Strings.StringsToJoin |
join(java.lang.String... strings)
Joins the given
String s using a given delimiter. |
static java.lang.Object |
quote(java.lang.Object o)
Returns the given object surrounded by single quotes, only if the object is a
String . |
static java.lang.String |
quote(java.lang.String s)
Returns the given
String surrounded by single quotes, or null if the given String is
null . |
private static java.lang.String |
revertEscapingPercent_n(java.lang.String value) |
public static boolean isNullOrEmpty(java.lang.String s)
String
is null
or empty.s
- the String
to check.true
if the given String
is null
or empty, otherwise false
.public static java.lang.String quote(java.lang.String s)
String
surrounded by single quotes, or null
if the given String
is
null
.s
- the given String
.String
surrounded by single quotes, or null
if the given String
is
null
.public static java.lang.Object quote(java.lang.Object o)
String
.o
- the given object.String
.quote(String)
public static java.lang.String concat(java.lang.Object... objects)
String
. This method is more efficient than concatenating using
"+", since only one StringBuilder
is created.objects
- the objects to concatenate.String
containing the given objects.public static java.lang.String formatIfArgs(java.lang.String message, java.lang.Object... args)
String.format(String, Object...)
the given message iif some args have been given otherwise juts
return the message.message
- the string to formatargs
- args used to format the message, can be null or emptypublic static java.lang.String escapePercent(java.lang.String value)
%
to %%
to avoid interpreting it in String.format(String, Object...)
.value
- the String to escapepublic static Strings.StringsToJoin join(java.lang.String... strings)
String
s using a given delimiter. The following example illustrates proper usage of this
method:
Strings.join("a", "b", "c").with("|");
which will result in the String
"a|b|c"
.strings
- the String
s to join.String
s.Strings.StringsToJoin.with(String)
public static Strings.StringsToJoin join(java.lang.Iterable<?> toStringable)
Object
s using a given delimiter. The following example illustrates proper usage of this
method:
Strings.join(new ArrayList("a", "b", "c")).with("|");
which will result in the String
"a|b|c"
.toStringable
- the Object
s to join.Object
s.Strings.StringsToJoin.with(String)
public static Strings.StringToAppend append(java.lang.String toAppend)
String
to the given target, only if the target does not end with the given String
to append. The following example illustrates proper usage of this method:
Strings.append("c").to("ab");
Strings.append("c").to("abc");
resulting in the String
"abc"
for both cases.toAppend
- the String
to append.String
and knows to append the given String
.Strings.StringToAppend.to(String)
private static java.lang.String escapePercentExceptWhenFollowedBy_n(java.lang.String message)
private static java.lang.String revertEscapingPercent_n(java.lang.String value)