public class ByteArrayUtil
extends java.lang.Object
printable(byte[])
for debugging non-text keys and values.Modifier and Type | Method and Description |
---|---|
static int |
compareUnsigned(byte[] l,
byte[] r)
Compare byte arrays for equality and ordering purposes.
|
static long |
decodeInt(byte[] src)
Decode a little-endian encoded long integer from an 8-byte array.
|
static byte[] |
encodeInt(long i)
Encode an 64-bit integer (long) into a byte array.
|
static byte[] |
join(byte[]... parts)
Joins a variable number of byte arrays into one larger array.
|
static byte[] |
join(byte[] interlude,
java.util.List<byte[]> parts)
Joins a set of byte arrays into a larger array.
|
static java.lang.String |
printable(byte[] val)
Gets a human readable version of a byte array.
|
static byte[] |
replace(byte[] src,
byte[] pattern,
byte[] replacement)
Replaces occurrences of a pattern in a byte array.
|
static byte[] |
replace(byte[] src,
int offset,
int length,
byte[] pattern,
byte[] replacement)
Replaces occurrences of a pattern in a byte array.
|
static java.util.List<byte[]> |
split(byte[] src,
byte[] delimiter)
Splits a byte array at each occurrence of a pattern.
|
static java.util.List<byte[]> |
split(byte[] src,
int offset,
int length,
byte[] delimiter)
Splits a byte array at each occurrence of a pattern.
|
static boolean |
startsWith(byte[] array,
byte[] prefix)
Check if a byte array starts with another byte array.
|
static byte[] |
strinc(byte[] key)
Computes the first key that would sort outside the range prefixed by
key . |
public static byte[] join(byte[] interlude, java.util.List<byte[]> parts)
interlude
is placed
between each of the elements, but not at the beginning or end. In the case that
the list is empty or null
, a zero-length byte array will be returned.interlude
- can be null
or zero length. Placed internally between
concatenated elements.parts
- the pieces to be joined. May be null
, but does not allow
for elements in the list to be null
.public static byte[] join(byte[]... parts)
parts
- the elements to join. null
elements are not allowed.public static byte[] replace(byte[] src, byte[] pattern, byte[] replacement)
src
.src
- the source to search for pattern
pattern
- the pattern for which to searchreplacement
- the sequence of bytes to replace pattern
with.pattern
replaced with replacement
public static byte[] replace(byte[] src, int offset, int length, byte[] pattern, byte[] replacement)
src
.src
- the source to search for pattern
offset
- the location in src
at which to start the operationlength
- the number of bytes past offset
to search for pattern
pattern
- the pattern for which to searchreplacement
- the sequence of bytes to replace pattern
with.pattern
replaced with replacement
public static java.util.List<byte[]> split(byte[] src, byte[] delimiter)
src
- the array to splitdelimiter
- the byte pattern on which to splitsrc
now not containing delimiter
public static java.util.List<byte[]> split(byte[] src, int offset, int length, byte[] delimiter)
src
- the array to splitoffset
- the location in the array at which to start the operationlength
- the number of bytes to search, must not extend past the end of src
delimiter
- the byte pattern on which to splitsrc
now not containing delimiter
public static int compareUnsigned(byte[] l, byte[] r)
null
.l
- byte array on the left-hand side of the inequalityr
- byte array on the right-hand side of the inequalityl
is less than, equal to, or greater than
r
.public static boolean startsWith(byte[] array, byte[] prefix)
array
- the source byte arrayprefix
- the byte array that we are checking if src
starts with.true
if array
starts with prefix
public static byte[] strinc(byte[] key)
key
.
key
must be non-null, and contain at least some character this is not
\xFF
(255).key
- prefix keypublic static byte[] encodeInt(long i)
Transaction.mutate(...)
.i
- the number to encodeTransaction.mutate(com.apple.foundationdb.MutationType, byte[], byte[])
public static long decodeInt(byte[] src)
src
- the non-null, 8-element byte array from which to decodepublic static java.lang.String printable(byte[] val)
\x
followed by a two character zero-padded hex code for the
byte.val
- the byte array for which to create a human readable form