Package org.syncany.util
Class StringUtil
- java.lang.Object
-
- org.syncany.util.StringUtil
-
public class StringUtil extends java.lang.Object
Utility class for common application string functions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
StringUtil.StringJoinListener<T>
-
Constructor Summary
Constructors Constructor Description StringUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
fromHex(java.lang.String hexString)
Creates byte array from a hex represented string.static java.lang.String
getStackTrace(java.lang.Exception exception)
static <T> java.lang.String
join(java.util.List<T> objects, java.lang.String delimiter)
static <T> java.lang.String
join(java.util.List<T> objects, java.lang.String delimiter, StringUtil.StringJoinListener<T> listener)
static <T> java.lang.String
join(T[] objects, java.lang.String delimiter)
static <T> java.lang.String
join(T[] objects, java.lang.String delimiter, StringUtil.StringJoinListener<T> listener)
static int
substrCount(java.lang.String haystack, java.lang.String needle)
Returns the count of the substringstatic byte[]
toBytesUTF8(java.lang.String s)
Creates a byte array from a given string, using the UTF-8 encoding.static java.lang.String
toCamelCase(java.lang.String str)
Transforms a string to a camel case representation, including the first character.static java.lang.String
toHex(byte[] bytes)
Converts a byte array to a lower case hex representation.static java.lang.String
toSnakeCase(java.lang.String str)
Transforms a string to underscore-delimited representation.
-
-
-
Constructor Detail
-
StringUtil
public StringUtil()
-
-
Method Detail
-
toCamelCase
public static java.lang.String toCamelCase(java.lang.String str)
Transforms a string to a camel case representation, including the first character.Examples:
toCamelCase("hello world") -> "HelloWorld"
toCamelCase("hello_world") -> "HelloWorld"
toCamelCase("hello_World") -> "HelloWorld"
toCamelCase("helloWorld") -> "HelloWorld"
toCamelCase("HelloWorld") -> "HelloWorld"
-
toSnakeCase
public static java.lang.String toSnakeCase(java.lang.String str)
Transforms a string to underscore-delimited representation.Examples:
toUnderScoreDelimited("HelloWorld") -> "hello_world"
toUnderScoreDelimited("helloWorld") -> "hello_world"
-
toHex
public static java.lang.String toHex(byte[] bytes)
Converts a byte array to a lower case hex representation. If the given byte array isnull
, an empty string is returned.
-
fromHex
public static byte[] fromHex(java.lang.String hexString)
Creates byte array from a hex represented string.
-
toBytesUTF8
public static byte[] toBytesUTF8(java.lang.String s)
Creates a byte array from a given string, using the UTF-8 encoding. This callsString.getBytes(java.nio.charset.Charset)
internally with "UTF-8" as charset.
-
substrCount
public static int substrCount(java.lang.String haystack, java.lang.String needle)
Returns the count of the substring
-
getStackTrace
public static java.lang.String getStackTrace(java.lang.Exception exception)
-
join
public static <T> java.lang.String join(java.util.List<T> objects, java.lang.String delimiter, StringUtil.StringJoinListener<T> listener)
-
join
public static <T> java.lang.String join(java.util.List<T> objects, java.lang.String delimiter)
-
join
public static <T> java.lang.String join(T[] objects, java.lang.String delimiter, StringUtil.StringJoinListener<T> listener)
-
join
public static <T> java.lang.String join(T[] objects, java.lang.String delimiter)
-
-