public class

ByteArrayLexOrder

extends Object
implements Comparator<T>
java.lang.Object
   ↳ sun.security.util.ByteArrayLexOrder

Class Overview

Compare two byte arrays in lexicographical order.

Summary

Public Constructors
ByteArrayLexOrder()
Public Methods
final int compare(byte[] bytes1, byte[] bytes2)
Perform lexicographical comparison of two byte arrays, regarding each byte as unsigned.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.util.Comparator

Public Constructors

public ByteArrayLexOrder ()

Public Methods

public final int compare (byte[] bytes1, byte[] bytes2)

Perform lexicographical comparison of two byte arrays, regarding each byte as unsigned. That is, compare array entries in order until they differ--the array with the smaller entry is "smaller". If array entries are equal till one array ends, then the longer array is "bigger".

Parameters
bytes1 first byte array to compare.
bytes2 second byte array to compare.
Returns
  • negative number if bytes1 < bytes2, 0 if bytes1 == bytes2, positive number if bytes1 > bytes2.
Throws
if either argument is not a byte array.