Package com.palantir.atlasdb.encoding
Class PtBytes
- java.lang.Object
-
- com.palantir.atlasdb.encoding.PtBytes
-
public final class PtBytes extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static com.google.common.collect.Ordering<byte[]>
BYTES_COMPARATOR
static com.google.common.base.Function<byte[],String>
BYTES_TO_HEX_STRING
static byte[]
EMPTY_BYTE_ARRAY
static int
SIZEOF_LONG
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addIfNotEmpty(com.google.common.base.MoreObjects.ToStringHelper helper, String name, byte[] bytes)
static int
compareTo(byte[] left, byte[] right)
Compare two byte arrays.static byte[]
decodeBase64(String data)
static byte[]
decodeHexString(String hexString)
static String
encodeBase64String(byte[] data)
static String
encodeBase64String(byte[] data, int offset, int length)
static String
encodeHexString(byte[] name)
static byte[]
head(byte[] arr, int length)
static boolean
startsWith(byte[] bytes, byte[] prefix)
Return true if the byte array on the right is a prefix of the byte array on the left.static byte[]
tail(byte[] arr, int length)
static byte[]
toBytes(long val)
Convert a long value to a byte array using big-endian.static byte[]
toBytes(String str)
Converts a string to a UTF-8 byte array.static byte[]
toCachedBytes(String str)
Converts a string to a UTF-8 byte array.static long
toLong(byte[] bytes)
Converts a byte array to a long value.static long
toLong(byte[] bytes, int offset)
Converts a byte array to a long value.static String
toString(byte[] arr)
static String
toString(byte[] arr, int off, int len)
-
-
-
Field Detail
-
EMPTY_BYTE_ARRAY
public static final byte[] EMPTY_BYTE_ARRAY
-
SIZEOF_LONG
public static final int SIZEOF_LONG
- See Also:
- Constant Field Values
-
BYTES_COMPARATOR
public static final com.google.common.collect.Ordering<byte[]> BYTES_COMPARATOR
-
BYTES_TO_HEX_STRING
public static final com.google.common.base.Function<byte[],String> BYTES_TO_HEX_STRING
-
-
Method Detail
-
toLong
public static long toLong(byte[] bytes)
Converts a byte array to a long value. ReversestoBytes(long)
-
toLong
public static long toLong(byte[] bytes, int offset)
Converts a byte array to a long value. Assumes there will beSIZEOF_LONG
bytes available.
-
toBytes
public static byte[] toBytes(long val)
Convert a long value to a byte array using big-endian.
-
toBytes
public static byte[] toBytes(String str)
Converts a string to a UTF-8 byte array.
-
toCachedBytes
public static byte[] toCachedBytes(String str)
Converts a string to a UTF-8 byte array. This method will cache results and return cached results, so the resulting byte arrays must not be modified.
-
tail
public static byte[] tail(byte[] arr, int length)
-
head
public static byte[] head(byte[] arr, int length)
-
toString
public static String toString(byte[] arr)
-
toString
public static String toString(byte[] arr, int off, int len)
-
addIfNotEmpty
public static void addIfNotEmpty(com.google.common.base.MoreObjects.ToStringHelper helper, String name, byte[] bytes)
-
encodeBase64String
public static String encodeBase64String(byte[] data)
-
encodeBase64String
public static String encodeBase64String(byte[] data, int offset, int length)
-
decodeBase64
public static byte[] decodeBase64(String data)
-
startsWith
public static boolean startsWith(byte[] bytes, byte[] prefix)
Return true if the byte array on the right is a prefix of the byte array on the left.
-
compareTo
public static int compareTo(byte[] left, byte[] right)
Compare two byte arrays.- Returns:
- 0 if equal, < 0 if left is less than right, etc
-
-