summaryrefslogtreecommitdiffstats
path: root/pki/base/util/src/netscape/security/util/ByteArrayLexOrder.java
diff options
context:
space:
mode:
authorAde Lee <alee@redhat.com>2011-12-08 21:15:59 -0500
committerAde Lee <alee@redhat.com>2011-12-08 21:15:59 -0500
commit171aaece4f23709d33d180cf36eb3af5e454b0c9 (patch)
tree1485f9f0a7bd10de4ff25030db575dbb8dafae74 /pki/base/util/src/netscape/security/util/ByteArrayLexOrder.java
parentadad2fcee8a29fdb82376fbce07dedb11fccc182 (diff)
downloadpki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.gz
pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.xz
pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.zip
Revert "Formatting"
This reverts commit 32150d3ee32f8ac27118af7c792794b538c78a2f.
Diffstat (limited to 'pki/base/util/src/netscape/security/util/ByteArrayLexOrder.java')
-rw-r--r--pki/base/util/src/netscape/security/util/ByteArrayLexOrder.java52
1 files changed, 27 insertions, 25 deletions
diff --git a/pki/base/util/src/netscape/security/util/ByteArrayLexOrder.java b/pki/base/util/src/netscape/security/util/ByteArrayLexOrder.java
index 9621deee0..60aede101 100644
--- a/pki/base/util/src/netscape/security/util/ByteArrayLexOrder.java
+++ b/pki/base/util/src/netscape/security/util/ByteArrayLexOrder.java
@@ -21,41 +21,43 @@ import java.util.Comparator;
/**
* Compare two byte arrays in lexicographical order.
- *
+ *
* @version 1.4 97/12/10
* @author D. N. Hoover
*/
public class ByteArrayLexOrder implements Comparator {
/**
- * 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".
- *
- * @param obj1 first byte array to compare.
- * @param obj2 second byte array to compare.
- * @return negative number if obj1 < obj2, 0 if obj1 == obj2, positive
- * number if obj1 > obj2.
- *
- * @exception <code>ClassCastException</code> if either argument is not a
- * byte array.
+ * 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".
+ *
+ * @param obj1 first byte array to compare.
+ * @param obj2 second byte array to compare.
+ * @return negative number if obj1 < obj2, 0 if obj1 == obj2,
+ * positive number if obj1 > obj2.
+ *
+ * @exception <code>ClassCastException</code>
+ * if either argument is not a byte array.
*/
public final int compare(Object obj1, Object obj2) {
- byte[] bytes1 = (byte[]) obj1;
- byte[] bytes2 = (byte[]) obj2;
+ byte[] bytes1 = (byte[]) obj1;
+ byte[] bytes2 = (byte[]) obj2;
- int diff;
- for (int i = 0; i < bytes1.length && i < bytes2.length; i++) {
- diff = (bytes1[i] & 0xFF) - (bytes2[i] & 0xFF);
- if (diff != 0) {
- return diff;
- }
- }
- // if array entries are equal till the first ends, then the
- // longer is "bigger"
- return bytes1.length - bytes2.length;
+ int diff;
+ for (int i = 0; i < bytes1.length && i < bytes2.length; i++) {
+ diff = (bytes1[i] & 0xFF) - (bytes2[i] & 0xFF);
+ if (diff != 0) {
+ return diff;
+ }
+ }
+ // if array entries are equal till the first ends, then the
+ // longer is "bigger"
+ return bytes1.length - bytes2.length;
}
+
}