Package org.fest.util
Class Strings
java.lang.Object
org.fest.util.Strings
Utility methods related to
String
s.- Author:
- Alex Ruiz
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Knows how to joinString
s using a given delimiter.static class
Knows how to append a givenString
to the given target, only if the target does not end with the givenString
to append. -
Method Summary
Modifier and TypeMethodDescriptionstatic Strings.StringToAppend
Appends a givenString
to the given target, only if the target does not end with the givenString
to append.static String
Concatenates the given objects into a singleString
.static boolean
Deprecated.static boolean
Indicates whether the givenString
isnull
or empty.static Strings.StringsToJoin
Joins the givenString
s using a given delimiter.static Object
Returns the given object surrounded by single quotes, only if the object is aString
.static String
Returns the givenString
surrounded by single quotes, ornull
if the givenString
isnull
.
-
Method Details
-
isNullOrEmpty
Indicates whether the givenString
isnull
or empty.- Parameters:
s
- theString
to check.- Returns:
true
if the givenString
isnull
or empty, otherwisefalse
.
-
isEmpty
Deprecated.Only there for backward compatibility reasons - useisNullOrEmpty(String)
instead. -
quote
Returns the givenString
surrounded by single quotes, ornull
if the givenString
isnull
.- Parameters:
s
- the givenString
.- Returns:
- the given
String
surrounded by single quotes, ornull
if the givenString
isnull
.
-
quote
Returns the given object surrounded by single quotes, only if the object is aString
.- Parameters:
o
- the given object.- Returns:
- the given object surrounded by single quotes, only if the object is a
String
. - See Also:
-
concat
Concatenates the given objects into a singleString
. This method is more efficient than concatenating using "+", since only one
is created.StringBuilder
- Parameters:
objects
- the objects to concatenate.- Returns:
- a
String
containing the given objects.
-
join
Joins the givenString
s using a given delimiter. The following example illustrates proper usage of this method:Strings.join("a", "b", "c").with("|")
which will result in theString
"a|b|c"
.- Parameters:
strings
- theString
s to join.- Returns:
- an intermediate object that takes a given delimiter and knows how to join the given
String
s. - See Also:
-
append
Appends a givenString
to the given target, only if the target does not end with the givenString
to append. The following example illustrates proper usage of this method:Strings.append("c").to("ab"); Strings.append("c").to("abc");
resulting in theString
"abc"
for both cases.- Parameters:
toAppend
- theString
to append.- Returns:
- an intermediate object that takes the target
String
and knows to append the givenString
. - See Also:
-