Class StringUtils
java.lang.Object
org.apache.jackrabbit.oak.commons.StringUtils
Some string utility methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull String
convertBytesToHex
(@org.jetbrains.annotations.NotNull byte[] value) Convert a byte array to a hex encoded string.static @org.jetbrains.annotations.NotNull byte[]
convertHexToBytes
(@NotNull String s) Convert a hex encoded string to a byte array.static String
emptyToNull
(@Nullable String string) Returns the string if it is not empty, ornull
otherwise.static int
Estimates the memory usage of the given string.
-
Method Details
-
convertBytesToHex
@NotNull public static @NotNull String convertBytesToHex(@NotNull @org.jetbrains.annotations.NotNull byte[] value) Convert a byte array to a hex encoded string.- Parameters:
value
- the byte array- Returns:
- the hex encoded string
-
convertHexToBytes
@NotNull public static @org.jetbrains.annotations.NotNull byte[] convertHexToBytes(@NotNull @NotNull String s) Convert a hex encoded string to a byte array.- Parameters:
s
- the hex encoded string- Returns:
- the byte array
-
estimateMemoryUsage
Estimates the memory usage of the given string.- Parameters:
s
- the string to estimate.- Returns:
- the estimated memory usage.
-
emptyToNull
Returns the string if it is not empty, ornull
otherwise.- Parameters:
string
- the string to test and possibly return, may benull
- Returns:
- the input string if it is not empty, or
null
if the input string isnull
or empty
-