Modifier and Type | Method and Description |
---|---|
static byte[] |
decodeBase64ToBytes(String base64) |
static String |
decodeBase64ToString(String base64) |
static byte[] |
decodeHex(String str)
Converts an array of characters representing hexadecimal values into an array of bytes of
those same values.
|
static <T extends Serializable> |
decodeStringToObject(String base64String,
Class<T> baseClass) |
static <T extends Serializable> |
decodeStringToObject(String base64String,
Class<T> baseClass,
ClassLoader classLoader) |
static <T> T |
decodeStringToObject(String encodedStr,
ClassLoader classLoader) |
static String |
encodeBytesToBase64(byte[] bytes) |
static String |
encodeObjectToString(Object serializable) |
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)
Deprecated.
Use
loadClass(String, ClassLoader) instead, in order to explicitly
provide the correct classloader. |
static Class<?> |
loadClass(String qualifiedName,
ClassLoader classLoader) |
static byte[] |
md5(String string) |
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> T decodeStringToObject(String encodedStr, ClassLoader classLoader) throws IOException
IOException
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)
@Deprecated public static Class<?> loadClass(String qualifiedName)
loadClass(String, ClassLoader)
instead, in order to explicitly
provide the correct 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 byte[] decodeHex(String str) throws TableException
Copied from https://github.com/apache/commons-codec/blob/master/src/main/java/org/apache/commons/codec/binary/Hex.java.
str
- An array of characters containing hexadecimal digitsTableException
- Thrown if an odd number of characters or illegal characters are
suppliedpublic 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 char
s 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–2023 The Apache Software Foundation. All rights reserved.