Package uk.gov.gchq.gaffer.commonutil
Class StringUtil
- java.lang.Object
-
- uk.gov.gchq.gaffer.commonutil.StringUtil
-
-
Field Summary
Fields Modifier and Type Field Description static charCOMMA
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Set<Class<? extends T>>csvToClasses(byte[] bytes, Class<? extends T> clazz)static StringescapeComma(String str)Escapes the provided string so that it no longer contains the COMMA character.static StringnullIfEmpty(String string)Checks if aStringis null or empty and returns null if true.static byte[]toBytes(String string)Create a byte array representation of a string.static byte[]toCsv(Class<?>... classes)Create a CSV entry containing a list of class names (in byte array representation).static StringtoString(byte[] bytes)Create a string representation of a byte array.static StringunescapeComma(String escapedStr)Unescapes the provided byte array - this should only be called on byte arrays that have been through theescapemethod.
-
-
-
Field Detail
-
COMMA
public static final char COMMA
- See Also:
- Constant Field Values
-
-
Method Detail
-
toString
public static String toString(byte[] bytes)
Create a string representation of a byte array.- Parameters:
bytes- the byte array to convert to a string representation- Returns:
- the resulting string
-
toBytes
public static byte[] toBytes(String string)
Create a byte array representation of a string.- Parameters:
string- the string to convert into a byte array representation- Returns:
- the resulting byte array
-
escapeComma
public static String escapeComma(String str)
Escapes the provided string so that it no longer contains the COMMA character.- Parameters:
str- the string to escape- Returns:
- the escaped string
-
unescapeComma
public static String unescapeComma(String escapedStr)
Unescapes the provided byte array - this should only be called on byte arrays that have been through theescapemethod.- Parameters:
escapedStr- the escaped string- Returns:
- the unescaped string
-
toCsv
public static byte[] toCsv(Class<?>... classes)
Create a CSV entry containing a list of class names (in byte array representation).- Parameters:
classes- the classes to write as a CSV entry- Returns:
- the CSV entry, as a byte array
-
csvToClasses
public static <T> Set<Class<? extends T>> csvToClasses(byte[] bytes, Class<? extends T> clazz)
-
-