@Internal public abstract class EncodingUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
decodeBase64ToBytes(String base64) |
static String |
decodeBase64ToString(String base64) |
static <T extends Serializable> |
decodeStringToObject(String base64String,
Class<T> baseClass) |
static <T extends Serializable> |
decodeStringToObject(String base64String,
Class<T> baseClass,
ClassLoader classLoader) |
static String |
encodeBytesToBase64(byte[] bytes) |
static String |
encodeObjectToString(Serializable obj) |
static String |
encodeStringToBase64(String string) |
static String |
escapeBackticks(String s) |
static String |
escapeIdentifier(String s) |
static String |
escapeJava(String str)
Escapes the characters in a
String using Java String rules. |
static String |
escapeSingleQuotes(String s) |
static String |
hex(byte[] bytes) |
static String |
hex(String string) |
static Class<?> |
loadClass(String qualifiedName) |
static Class<?> |
loadClass(String qualifiedName,
ClassLoader classLoader) |
static byte[] |
md5(String string) |
static String |
objectToString(Object object) |
static String |
repeat(char ch,
int repeat)
Returns padding using the specified delimiter repeated to a given length.
|
static String |
repeat(String str,
int repeat)
Repeat a String
repeat times to form a new String. |
public static String encodeObjectToString(Serializable obj)
public static <T extends Serializable> T decodeStringToObject(String base64String, Class<T> baseClass)
public static <T extends Serializable> T decodeStringToObject(String base64String, Class<T> baseClass, ClassLoader classLoader)
public static Class<?> loadClass(String qualifiedName, ClassLoader classLoader)
public static String encodeBytesToBase64(byte[] bytes)
public static byte[] decodeBase64ToBytes(String base64)
public static byte[] md5(String string)
public static String hex(byte[] bytes)
public static String repeat(String str, int repeat)
repeat times to form a new String.
StringUtils.repeat(null, 2) = null
StringUtils.repeat("", 0) = ""
StringUtils.repeat("", 2) = ""
StringUtils.repeat("a", 3) = "aaa"
StringUtils.repeat("ab", 2) = "abab"
StringUtils.repeat("a", -2) = ""
str - the String to repeat, may be nullrepeat - number of times to repeat str, negative treated as zeronull if null String inputpublic static String repeat(char ch, int repeat)
StringUtils.repeat('e', 0) = ""
StringUtils.repeat('e', 3) = "eee"
StringUtils.repeat('e', -2) = ""
Note: this method doesn't not support padding with
Unicode Supplementary Characters
as they require a pair of chars to be represented.
If you are needing to support full I18N of your applications
consider using repeat(String, int) instead.
ch - character to repeatrepeat - number of times to repeat char, negative treated as zerorepeat(String, int)public static String escapeJava(String str)
String using Java String rules.
Deals correctly with quotes and control-chars (tab, backslash, cr, ff, etc.)
So a tab becomes the characters '\\' and 't'.
The only difference between Java strings and JavaScript strings is that in JavaScript, a single quote must be escaped.
Example:
input string: He didn't say, "Stop!" output string: He didn't say, \"Stop!\"
str - String to escape values in, may be nullnull if null string inputCopyright © 2014–2019 The Apache Software Foundation. All rights reserved.