public class ByteArrayFunctions extends java.lang.Object implements ArrayFunctions<byte[]>
| Modifier and Type | Field and Description |
|---|---|
static ByteArrayFunctions |
INSTANCE |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
concat(byte[] array1,
byte[] array2)
Concatenates two arrays into one and returns it.
|
void |
copyArray(byte[] from,
int fromOffset,
byte[] to,
int toOffset,
int length)
Copies part of the first array to the second array.
|
byte[] |
copyOfRange(byte[] original,
int from,
int to)
Copies the specified range.
|
boolean |
endsWith(byte[] array,
byte[] subarray)
Checks if
array[length - subarray.length:] == subarray. |
boolean |
equals(byte[] array1,
byte[] array2)
Checks if the two arrays have the same content.
|
boolean |
equals(byte[] array1,
int array1Index,
byte[] array2,
int array2Index)
Checks if
array1[array1Index] == array2[array2Index]. |
int |
getCommonPrefixLength(byte[] array1,
byte[] array2)
Determines the longest common prefix, that is, the number of items at
the start of the arrays that are equal.
|
int |
getCommonSuffixLength(byte[] array1,
byte[] array2)
Determines the longest common suffix, that is, the number of items at
the end of the arrays that are equal.
|
int |
getLength(byte[] value)
Gets the length of the given array.
|
byte[] |
newArray(int length)
Constructs a new array of the given length.
|
byte[] |
read(BytesDataInput input)
Reads an array from the given input stream.
|
byte[] |
read(DataInput input)
Reads an array from the given input stream.
|
byte[] |
readRaw(BytesDataInput input,
int length)
Reads an array from the given input stream.
|
byte[] |
readRaw(DataInput input,
int length)
Reads an array from the given input stream.
|
boolean |
startsWith(byte[] array,
byte[] subarray)
Checks if
array[:subarray.length] == subarray. |
void |
write(BytesDataOutput output,
byte[] value)
Writes the contents of the given array to the output stream.
|
void |
write(DataOutput output,
byte[] value)
Writes the contents of the given array to the output stream.
|
void |
writeRaw(BytesDataOutput output,
byte[] value)
Writes the contents of the given array to the output stream.
|
void |
writeRaw(DataOutput output,
byte[] value)
Writes the contents of the given array to the output stream.
|
public static final ByteArrayFunctions INSTANCE
public byte[] newArray(int length)
ArrayFunctionsnewArray in interface ArrayFunctions<byte[]>length - array lengthpublic int getLength(byte[] value)
ArrayFunctionsgetLength in interface ArrayFunctions<byte[]>value - array valuepublic boolean equals(byte[] array1,
byte[] array2)
ArrayFunctionsequals in interface ArrayFunctions<byte[]>array1 - first arrayarray2 - second arraypublic byte[] concat(byte[] array1,
byte[] array2)
ArrayFunctionsconcat in interface ArrayFunctions<byte[]>array1 - first arrayarray2 - second arraypublic boolean startsWith(byte[] array,
byte[] subarray)
ArrayFunctionsarray[:subarray.length] == subarray.startsWith in interface ArrayFunctions<byte[]>array - array to checksubarray - array prefix to check forpublic boolean endsWith(byte[] array,
byte[] subarray)
ArrayFunctionsarray[length - subarray.length:] == subarray.endsWith in interface ArrayFunctions<byte[]>array - array to checksubarray - array suffix to check forpublic int getCommonSuffixLength(byte[] array1,
byte[] array2)
ArrayFunctionsgetCommonSuffixLength in interface ArrayFunctions<byte[]>array1 - first arrayarray2 - second arraypublic int getCommonPrefixLength(byte[] array1,
byte[] array2)
ArrayFunctionsgetCommonPrefixLength in interface ArrayFunctions<byte[]>array1 - first arrayarray2 - second arraypublic byte[] copyOfRange(byte[] original,
int from,
int to)
ArrayFunctionscopyOfRange in interface ArrayFunctions<byte[]>original - array to copy fromfrom - range start indexto - range end indexpublic void copyArray(byte[] from,
int fromOffset,
byte[] to,
int toOffset,
int length)
ArrayFunctionscopyArray in interface ArrayFunctions<byte[]>from - array to copy fromfromOffset - offset to copy fromto - array to copy tcotoOffset - offset to copy tolength - number of items to copypublic boolean equals(byte[] array1,
int array1Index,
byte[] array2,
int array2Index)
ArrayFunctionsarray1[array1Index] == array2[array2Index].equals in interface ArrayFunctions<byte[]>array1 - first arrayarray1Index - first array indexarray2 - second arrayarray2Index - second array indexpublic void write(DataOutput output, byte[] value) throws java.io.IOException
ArrayFunctionswrite in interface ArrayFunctions<byte[]>output - stream to write tovalue - array to be writtenjava.io.IOException - if an I/O error occurspublic void writeRaw(DataOutput output, byte[] value) throws java.io.IOException
ArrayFunctionswriteRaw in interface ArrayFunctions<byte[]>output - stream to write tovalue - array to be writtenjava.io.IOException - if an I/O error occurspublic void write(BytesDataOutput output, byte[] value)
ArrayFunctionswrite in interface ArrayFunctions<byte[]>output - stream to write tovalue - array to be writtenpublic void writeRaw(BytesDataOutput output, byte[] value)
ArrayFunctionswriteRaw in interface ArrayFunctions<byte[]>output - stream to write tovalue - array to be writtenpublic byte[] read(DataInput input) throws java.io.IOException
ArrayFunctionsread in interface ArrayFunctions<byte[]>input - stream to read fromjava.io.IOException - if an I/O error occurspublic byte[] readRaw(DataInput input, int length) throws java.io.IOException
ArrayFunctionsreadRaw in interface ArrayFunctions<byte[]>input - stream to read fromlength - array lengthjava.io.IOException - if an I/O error occurspublic byte[] read(BytesDataInput input)
ArrayFunctionsread in interface ArrayFunctions<byte[]>input - stream to read frompublic byte[] readRaw(BytesDataInput input, int length)
ArrayFunctionsreadRaw in interface ArrayFunctions<byte[]>input - stream to read fromlength - array length