Package org.jclouds.util
Class Strings2
- java.lang.Object
-
- org.jclouds.util.Strings2
-
public class Strings2 extends Object
-
-
Constructor Summary
Constructors Constructor Description Strings2()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisCidrFormat(String in)static booleanisIPv6CIDR(String in)static StringreplaceTokens(String input, com.google.common.collect.Multimap<String,?> tokenValues)static StringreplaceTokens(String input, Map<String,String> replacements)replaces tokens that are expressed as{token}static InputStreamtoInputStream(String in)static StringtoStringAndClose(InputStream input)static StringurlDecode(String in)url decodes the input param, if set.static StringurlEncode(String in, char... skipEncode)Web browsers do not always handle '+' characters well, use the well-supported '%20' instead.static StringurlEncode(String in, Iterable<Character> skipEncode)
-
-
-
Method Detail
-
urlEncode
public static String urlEncode(String in, char... skipEncode)
Web browsers do not always handle '+' characters well, use the well-supported '%20' instead.
-
isCidrFormat
public static boolean isCidrFormat(String in)
-
isIPv6CIDR
public static boolean isIPv6CIDR(String in)
-
urlDecode
public static String urlDecode(@Nullable String in)
url decodes the input param, if set.- Parameters:
in- nullable- Returns:
- null if input was null
- Throws:
IllegalStateException- if encoding isn'tUTF-8
-
toStringAndClose
public static String toStringAndClose(InputStream input) throws IOException
- Throws:
IOException
-
toInputStream
public static InputStream toInputStream(String in)
-
replaceTokens
public static String replaceTokens(String input, Map<String,String> replacements)
replaces tokens that are expressed as{token}ex. if input is "hello {where}"
and replacements is "where" -> "world"
then replaceTokens returns "hello world"- Parameters:
input- source to replacereplacements- token/value pairs
-
-