Package uk.gov.gchq.gaffer.commonutil
Class ByteArrayEscapeUtils
- java.lang.Object
-
- uk.gov.gchq.gaffer.commonutil.ByteArrayEscapeUtils
-
public final class ByteArrayEscapeUtils extends Object
Removes the 0 byte from a byte array. Preserves ordering.
-
-
Field Summary
Fields Modifier and Type Field Description static byteDELIMITERstatic byteDELIMITER_PLUS_ONE
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]escape(byte[] bytes, byte... appendAfterEscaping)Escapes the provided byte[] so that it no longer contains the Constants.DELIMITER character.static byte[]unEscape(byte[] bytes)Unescapes the provided byte array - this should only be called on byte arrays that have been through theescapemethod.static byte[]unEscape(byte[] allBytes, int start, int end)Unescapes the provided byte array - this should only be called on byte arrays that have been through theescapemethod.static byte[]unEscapeByLength(byte[] allBytes, int offset, int length)Unescapes the provided byte array - this should only be called on byte arrays that have been through theescapemethod.static byte[]unEscapeByPosition(byte[] allBytes, int start, int end)Unescapes the provided byte array - this should only be called on byte arrays that have been through theescapemethod.
-
-
-
Field Detail
-
DELIMITER
public static final byte DELIMITER
- See Also:
- Constant Field Values
-
DELIMITER_PLUS_ONE
public static final byte DELIMITER_PLUS_ONE
- See Also:
- Constant Field Values
-
-
Method Detail
-
escape
public static byte[] escape(byte[] bytes, byte... appendAfterEscaping)Escapes the provided byte[] so that it no longer contains the Constants.DELIMITER character. After escaping the byte[] the appendAfterEscaping[] is appended unescaped.- Parameters:
bytes- the byte array to escapeappendAfterEscaping- the bytes to append to the array after being escaped.- Returns:
- the escaped byte array
-
unEscape
public static byte[] unEscape(byte[] bytes)
Unescapes the provided byte array - this should only be called on byte arrays that have been through theescapemethod.- Parameters:
bytes- the byte array to unescape- Returns:
- the unescaped byte array
-
unEscape
public static byte[] unEscape(byte[] allBytes, int start, int end)Unescapes the provided byte array - this should only be called on byte arrays that have been through theescapemethod.- Parameters:
allBytes- The backing byte array which contains the subset to unEscapestart- The position to start the unEscape, inclusive.end- The position to end the unEscape, exclusive- Returns:
- the unescaped byte array
-
unEscapeByPosition
public static byte[] unEscapeByPosition(byte[] allBytes, int start, int end)Unescapes the provided byte array - this should only be called on byte arrays that have been through theescapemethod.- Parameters:
allBytes- The backing byte array which contains the subset to unEscapestart- The position to start the unEscape, inclusive.end- The position to end the unEscape, exclusive- Returns:
- the unescaped byte array
-
unEscapeByLength
public static byte[] unEscapeByLength(byte[] allBytes, int offset, int length)Unescapes the provided byte array - this should only be called on byte arrays that have been through theescapemethod.- Parameters:
allBytes- The backing byte array which contains the subset to unEscape.offset- The position to start the unEscape, inclusivelength- The length of bytes to unEscape- Returns:
- the unescaped byte array
-
-