ikrs.util
Class ByteArrayComparator
java.lang.Object
ikrs.util.ByteArrayComparator
- All Implemented Interfaces:
- java.util.Comparator<byte[]>
public class ByteArrayComparator
- extends java.lang.Object
- implements java.util.Comparator<byte[]>
A very simple byte array comparator.
Method Summary |
int |
compare(byte[] o1,
byte[] o2)
Compared the passed arrays. |
static int |
compareArrays(byte[] o1,
byte[] o2)
Compares the passed byte arrays the way the data would
be compared in a string: byte for byte instead of char by char,
beginning at index 0. |
boolean |
equals(java.lang.Object obj)
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ByteArrayComparator
public ByteArrayComparator()
compare
public int compare(byte[] o1,
byte[] o2)
- Compared the passed arrays.
See compareArrays( o1, o2 ).
- Specified by:
compare
in interface java.util.Comparator<byte[]>
- See Also:
compareArrays( byte[], byte[] )
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interface java.util.Comparator<byte[]>
- Overrides:
equals
in class java.lang.Object
compareArrays
public static int compareArrays(byte[] o1,
byte[] o2)
- Compares the passed byte arrays the way the data would
be compared in a string: byte for byte instead of char by char,
beginning at index 0.
If one array is prefix of the other, the longest is considered
to be 'larger'.
null is considered to be 'smaller' than non-null.
null equals null.
If both arrays have the same length and all bytes are equal
both arrays are considered equal.
- Parameters:
o1
- The first byte array.o2
- The second byte array.