APIdia Launch Partner
Top Description Constructors Methods
sun.security.util

public Class ByteArrayLexOrder

extends Object
implements Comparator<byte[]>
Class Inheritance
All Implemented Interfaces
java.util.Comparator
Imports
java.util.Comparator

Compare two byte arrays in lexicographical order.
Author
D. N. Hoover

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final int

Returns:

negative number if bytes1 < bytes2, 0 if bytes1 == bytes2, positive number if bytes1 > bytes2.
compare
(byte[]
first byte array to compare.
bytes1
,
byte[]
second byte array to compare.
bytes2
)

Implements java.util.Comparator.compare.

Perform lexicographical comparison of two byte arrays, regarding each byte as unsigned.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ByteArrayLexOrderback to summary
public ByteArrayLexOrder()

Method Detail

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

Implements java.util.Comparator.compare.

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:byte[]

first byte array to compare.

bytes2:byte[]

second byte array to compare.

Returns:int

negative number if bytes1 < bytes2, 0 if bytes1 == bytes2, positive number if bytes1 > bytes2.

Exceptions
ClassCastException:
if either argument is not a byte array.