summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPekka Enberg <penberg@kernel.org>2012-03-12 19:26:50 +0200
committerPekka Enberg <penberg@kernel.org>2012-03-14 20:49:12 +0200
commitee7992d491d5c079e7dd754300c013efe66bff02 (patch)
treebcfb550315ad6d00ac1a50ddee97524cde227a86
parentab9c8ecc26b873ccad20fb80323b1232c77cbcfd (diff)
downloadclasspath-ee7992d491d5c079e7dd754300c013efe66bff02.tar.gz
Add missing Java 1.7 compare() API methods to java/lang classes
Signed-off-by: Pekka Enberg <penberg@kernel.org>
-rw-r--r--ChangeLog15
-rw-r--r--java/lang/Boolean.java15
-rw-r--r--java/lang/Byte.java17
-rw-r--r--java/lang/Character.java17
-rw-r--r--java/lang/Integer.java17
-rw-r--r--java/lang/Long.java17
-rw-r--r--java/lang/Short.java17
7 files changed, 115 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 2613eb74c..a3a909aca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2012-03-12 Pekka Enberg <penberg@kernel.org>
+ * java/lang/Boolean.java:
+ (compare): Add missing method.
+ * java/lang/Byte.java:
+ (compare): Add missing method.
+ * java/lang/Character.java:
+ (compare): Add missing method.
+ * java/lang/Integer.java:
+ (compare): Add missing method.
+ * java/lang/Long.java:
+ (compare): Add missing method.
+ * java/lang/Short.java:
+ (compare): Add missing method.
+
+2012-03-12 Pekka Enberg <penberg@kernel.org>
+
* java/lang/System.java:
(lineSeparator): Add missing method.
diff --git a/java/lang/Boolean.java b/java/lang/Boolean.java
index f2eaf4125..0e4afa813 100644
--- a/java/lang/Boolean.java
+++ b/java/lang/Boolean.java
@@ -237,6 +237,21 @@ public final class Boolean implements Serializable, Comparable<Boolean>
}
/**
+ * Compares two unboxed boolean values.
+ *
+ * @param x First value to compare.
+ * @param y Second value to compare.
+ * @return 0 if both Booleans represent the same value, a positive number
+ * if this Boolean represents true and the other false, and a negative
+ * number otherwise.
+ * @since 1.7
+ */
+ public static int compare(boolean x, boolean y)
+ {
+ return Boolean.valueOf(x).compareTo(Boolean.valueOf(y));
+ }
+
+ /**
* If the String argument is "true", ignoring case, return true.
* Otherwise, return false.
*
diff --git a/java/lang/Byte.java b/java/lang/Byte.java
index a1536e1be..01e0e03d2 100644
--- a/java/lang/Byte.java
+++ b/java/lang/Byte.java
@@ -370,4 +370,21 @@ public final class Byte extends Number implements Comparable<Byte>
return value - b.value;
}
+ /**
+ * Compares two unboxed byte values.
+ * The result is positive if the first is greater, negative if the second
+ * is greater, and 0 if the two are equal.
+ *
+ * @param x First value to compare.
+ * @param y Second value to compare.
+ *
+ * @return positive int if the first value is greater, negative if the second
+ * is greater, and 0 if the two are equal.
+ * @since 1.7
+ */
+ public static int compare(byte x, byte y)
+ {
+ return Byte.valueOf(x).compareTo(Byte.valueOf(y));
+ }
+
}
diff --git a/java/lang/Character.java b/java/lang/Character.java
index 05e641c3a..f87cde62c 100644
--- a/java/lang/Character.java
+++ b/java/lang/Character.java
@@ -4200,6 +4200,23 @@ public final class Character implements Serializable, Comparable<Character>
}
/**
+ * Compares two unboxed char values.
+ * The result is positive if the first is greater, negative if the second
+ * is greater, and 0 if the two are equal.
+ *
+ * @param x First value to compare.
+ * @param y Second value to compare.
+ *
+ * @return positive int if the first value is greater, negative if the second
+ * is greater, and 0 if the two are equal.
+ * @since 1.7
+ */
+ public static int compare(char x, char y)
+ {
+ return Character.valueOf(x).compareTo(Character.valueOf(y));
+ }
+
+ /**
* Returns an <code>Character</code> object wrapping the value.
* In contrast to the <code>Character</code> constructor, this method
* will cache some values. It is used by boxing conversion.
diff --git a/java/lang/Integer.java b/java/lang/Integer.java
index f379795ea..25eb5d526 100644
--- a/java/lang/Integer.java
+++ b/java/lang/Integer.java
@@ -586,6 +586,23 @@ public final class Integer extends Number implements Comparable<Integer>
}
/**
+ * Compares two unboxed int values.
+ * The result is positive if the first is greater, negative if the second
+ * is greater, and 0 if the two are equal.
+ *
+ * @param x First value to compare.
+ * @param y Second value to compare.
+ *
+ * @return positive int if the first value is greater, negative if the second
+ * is greater, and 0 if the two are equal.
+ * @since 1.7
+ */
+ public static int compare(int x, int y)
+ {
+ return Integer.valueOf(x).compareTo(Integer.valueOf(y));
+ }
+
+ /**
* Return the number of bits set in x.
* @param x value to examine
* @since 1.5
diff --git a/java/lang/Long.java b/java/lang/Long.java
index e7579d865..6f31dfa99 100644
--- a/java/lang/Long.java
+++ b/java/lang/Long.java
@@ -585,6 +585,23 @@ public final class Long extends Number implements Comparable<Long>
}
/**
+ * Compares two unboxed long values.
+ * The result is positive if the first is greater, negative if the second
+ * is greater, and 0 if the two are equal.
+ *
+ * @param x First value to compare.
+ * @param y Second value to compare.
+ *
+ * @return positive int if the first value is greater, negative if the second
+ * is greater, and 0 if the two are equal.
+ * @since 1.7
+ */
+ public static int compare(long x, long y)
+ {
+ return Long.valueOf(x).compareTo(Long.valueOf(y));
+ }
+
+ /**
* Return the number of bits set in x.
* @param x value to examine
* @since 1.5
diff --git a/java/lang/Short.java b/java/lang/Short.java
index ec87f933e..fae9fe763 100644
--- a/java/lang/Short.java
+++ b/java/lang/Short.java
@@ -373,6 +373,23 @@ public final class Short extends Number implements Comparable<Short>
}
/**
+ * Compares two unboxed short values.
+ * The result is positive if the first is greater, negative if the second
+ * is greater, and 0 if the two are equal.
+ *
+ * @param x First value to compare.
+ * @param y Second value to compare.
+ *
+ * @return positive int if the first value is greater, negative if the second
+ * is greater, and 0 if the two are equal.
+ * @since 1.7
+ */
+ public static int compare(short x, short y)
+ {
+ return Short.valueOf(x).compareTo(Short.valueOf(y));
+ }
+
+ /**
* Reverse the bytes in val.
* @since 1.5
*/