You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/08/10 05:41:41 UTC
svn commit: r430231 - in
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang:
Boolean.java Byte.java Character.java Double.java Float.java Integer.java
Long.java Short.java
Author: ndbeyer
Date: Wed Aug 9 20:41:40 2006
New Revision: 430231
URL: http://svn.apache.org/viewvc?rev=430231&view=rev
Log:
Code cleanup, remove warnings, etc for primitive wrapper objects.
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Boolean.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Byte.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Integer.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Long.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Short.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Boolean.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Boolean.java?rev=430231&r1=430230&r2=430231&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Boolean.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Boolean.java Wed Aug 9 20:41:40 2006
@@ -98,7 +98,8 @@
*
* @see #hashCode
*/
- public boolean equals(Object o) {
+ @Override
+ public boolean equals(Object o) {
return (o == this)
|| ((o instanceof Boolean) && (value == ((Boolean) o).value));
}
@@ -120,11 +121,13 @@
* @see java.lang.Comparable
*/
public int compareTo(Boolean that) {
- if (that == null)
+ if (that == null) {
throw new NullPointerException();
+ }
- if (this.value == that.value)
+ if (this.value == that.value) {
return 0;
+ }
return this.value ? 1 : -1;
}
@@ -138,7 +141,8 @@
*
* @see #equals
*/
- public int hashCode() {
+ @Override
+ public int hashCode() {
return value ? 1231 : 1237;
}
@@ -148,6 +152,7 @@
*
* @return a printable representation for the receiver.
*/
+ @Override
public String toString() {
return String.valueOf(value);
}
@@ -160,8 +165,9 @@
* @return The boolean value.
*/
public static boolean getBoolean(String string) {
- if (string == null || string.length() == 0)
+ if (string == null || string.length() == 0) {
return false;
+ }
return (parseBoolean(System.getProperty(string)));
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Byte.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Byte.java?rev=430231&r1=430230&r2=430231&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Byte.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Byte.java Wed Aug 9 20:41:40 2006
@@ -96,7 +96,8 @@
*
* @return byte the value of the receiver.
*/
- public byte byteValue() {
+ @Override
+ public byte byteValue() {
return value;
}
@@ -134,8 +135,9 @@
public static Byte decode(String string) throws NumberFormatException {
int intValue = Integer.decode(string).intValue();
byte result = (byte) intValue;
- if (result == intValue)
- return valueOf(result);
+ if (result == intValue) {
+ return valueOf(result);
+ }
throw new NumberFormatException();
}
@@ -144,7 +146,8 @@
*
* @return double the value of the receiver.
*/
- public double doubleValue() {
+ @Override
+ public double doubleValue() {
return value;
}
@@ -161,7 +164,8 @@
* <code>false</code> if it is different from this object
* @see #hashCode
*/
- public boolean equals(Object object) {
+ @Override
+ public boolean equals(Object object) {
return (object == this) || (object instanceof Byte)
&& (value == ((Byte) object).value);
}
@@ -171,7 +175,8 @@
*
* @return float the value of the receiver.
*/
- public float floatValue() {
+ @Override
+ public float floatValue() {
return value;
}
@@ -184,7 +189,8 @@
*
* @see #equals
*/
- public int hashCode() {
+ @Override
+ public int hashCode() {
return value;
}
@@ -193,7 +199,8 @@
*
* @return int the value of the receiver.
*/
- public int intValue() {
+ @Override
+ public int intValue() {
return value;
}
@@ -202,7 +209,8 @@
*
* @return long the value of the receiver.
*/
- public long longValue() {
+ @Override
+ public long longValue() {
return value;
}
@@ -220,8 +228,9 @@
public static byte parseByte(String string) throws NumberFormatException {
int intValue = Integer.parseInt(string);
byte result = (byte) intValue;
- if (result == intValue)
- return result;
+ if (result == intValue) {
+ return result;
+ }
throw new NumberFormatException();
}
@@ -243,8 +252,9 @@
throws NumberFormatException {
int intValue = Integer.parseInt(string, radix);
byte result = (byte) intValue;
- if (result == intValue)
- return result;
+ if (result == intValue) {
+ return result;
+ }
throw new NumberFormatException();
}
@@ -253,7 +263,8 @@
*
* @return short the value of the receiver.
*/
- public short shortValue() {
+ @Override
+ public short shortValue() {
return value;
}
@@ -263,7 +274,8 @@
*
* @return a printable representation for the receiver.
*/
- public String toString() {
+ @Override
+ public String toString() {
return Integer.toString(value);
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java?rev=430231&r1=430230&r2=430231&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Character.java Wed Aug 9 20:41:40 2006
@@ -566,6 +566,7 @@
* The "Surrogates Area" Unicode Block.
* @deprecated As of Java 5, this block as been replaced by {@link #HIGH_SURROGATES}, {@link #HIGH_PRIVATE_USE_SURROGATES} and {@link #LOW_SURROGATES}.
*/
+ @Deprecated
public static final UnicodeBlock SURROGATES_AREA = new UnicodeBlock("SURROGATES_AREA", 0x0, 0x0);
/**
* The "Basic Latin" Unicode Block.
@@ -1572,11 +1573,13 @@
* @since 1.5
*/
public static UnicodeBlock forName(String blockName) {
- if (blockName == null)
+ if (blockName == null) {
throw new NullPointerException();
+ }
UnicodeBlock match = BLOCKS_BY_NAME.get(blockName);
- if (match == null)
+ if (match == null) {
throw new IllegalArgumentException();
+ }
return match;
}
@@ -1607,8 +1610,9 @@
* @since 1.5
*/
public static UnicodeBlock of(int codePoint) {
- if (!isValidCodePoint(codePoint))
+ if (!isValidCodePoint(codePoint)) {
throw new IllegalArgumentException();
+ }
int low = 0;
int mid = -1;
int high = BLOCKS.length - 1;
@@ -1690,12 +1694,14 @@
* @since 1.5
*/
public static Character valueOf(char c) {
- if (c > CACHE.length)
+ if (c > CACHE.length) {
return new Character(c);
+ }
synchronized (CACHE) {
Character ch = CACHE[c];
- if (ch == null)
+ if (ch == null) {
CACHE[c] = ch = new Character(c);
+ }
return ch;
}
}
@@ -1840,18 +1846,22 @@
* @since 1.5
*/
public static int codePointAt(CharSequence seq, int index) {
- if (seq == null)
+ if (seq == null) {
throw new NullPointerException();
+ }
int len = seq.length();
- if (index < 0 || index >= len)
+ if (index < 0 || index >= len) {
throw new IndexOutOfBoundsException();
+ }
char high = seq.charAt(index++);
- if (index >= len)
+ if (index >= len) {
return high;
+ }
char low = seq.charAt(index);
- if (isSurrogatePair(high, low))
+ if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
+ }
return high;
}
@@ -1875,18 +1885,22 @@
* @since 1.5
*/
public static int codePointAt(char[] seq, int index) {
- if (seq == null)
+ if (seq == null) {
throw new NullPointerException();
+ }
int len = seq.length;
- if (index < 0 || index >= len)
+ if (index < 0 || index >= len) {
throw new IndexOutOfBoundsException();
+ }
char high = seq[index++];
- if (index >= len)
+ if (index >= len) {
return high;
+ }
char low = seq[index];
- if (isSurrogatePair(high, low))
+ if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
+ }
return high;
}
@@ -1919,11 +1933,13 @@
}
char high = seq[index++];
- if (index >= limit)
+ if (index >= limit) {
return high;
+ }
char low = seq[index];
- if (isSurrogatePair(high, low))
+ if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
+ }
return high;
}
@@ -1948,18 +1964,22 @@
* @since 1.5
*/
public static int codePointBefore(CharSequence seq, int index) {
- if (seq == null)
+ if (seq == null) {
throw new NullPointerException();
+ }
int len = seq.length();
- if (index < 1 || index > len)
+ if (index < 1 || index > len) {
throw new IndexOutOfBoundsException();
+ }
char low = seq.charAt(--index);
- if (--index < 0)
+ if (--index < 0) {
return low;
+ }
char high = seq.charAt(index);
- if (isSurrogatePair(high, low))
+ if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
+ }
return low;
}
@@ -1984,18 +2004,22 @@
* @since 1.5
*/
public static int codePointBefore(char[] seq, int index) {
- if (seq == null)
+ if (seq == null) {
throw new NullPointerException();
+ }
int len = seq.length;
- if (index < 1 || index > len)
+ if (index < 1 || index > len) {
throw new IndexOutOfBoundsException();
+ }
char low = seq[--index];
- if (--index < 0)
+ if (--index < 0) {
return low;
+ }
char high = seq[index];
- if (isSurrogatePair(high, low))
+ if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
+ }
return low;
}
@@ -2024,18 +2048,22 @@
* @since 1.5
*/
public static int codePointBefore(char[] seq, int index, int start) {
- if (seq == null)
+ if (seq == null) {
throw new NullPointerException();
+ }
int len = seq.length;
- if (index <= start || index > len || start < 0 || start >= len)
+ if (index <= start || index > len || start < 0 || start >= len) {
throw new IndexOutOfBoundsException();
+ }
char low = seq[--index];
- if (--index < start)
+ if (--index < start) {
return low;
+ }
char high = seq[index];
- if (isSurrogatePair(high, low))
+ if (isSurrogatePair(high, low)) {
return toCodePoint(high, low);
+ }
return low;
}
@@ -2062,16 +2090,20 @@
* @since 1.5
*/
public static int toChars(int codePoint, char[] dst, int dstIndex) {
- if (!isValidCodePoint(codePoint))
+ if (!isValidCodePoint(codePoint)) {
throw new IllegalArgumentException();
- if (dst == null)
+ }
+ if (dst == null) {
throw new NullPointerException();
- if (dstIndex < 0 || dstIndex >= dst.length)
+ }
+ if (dstIndex < 0 || dstIndex >= dst.length) {
throw new IndexOutOfBoundsException();
+ }
if (isSupplementaryCodePoint(codePoint)) {
- if (dstIndex == dst.length - 1)
+ if (dstIndex == dst.length - 1) {
throw new IndexOutOfBoundsException();
+ }
// See RFC 2781, Section 2.1
// http://www.faqs.org/rfcs/rfc2781.html
int cpPrime = codePoint - 0x10000;
@@ -2102,8 +2134,9 @@
* @since 1.5
*/
public static char[] toChars(int codePoint) {
- if (!isValidCodePoint(codePoint))
+ if (!isValidCodePoint(codePoint)) {
throw new IllegalArgumentException();
+ }
if (isSupplementaryCodePoint(codePoint)) {
int cpPrime = codePoint - 0x10000;
@@ -2134,11 +2167,13 @@
*/
public static int codePointCount(CharSequence seq, int beginIndex,
int endIndex) {
- if (seq == null)
+ if (seq == null) {
throw new NullPointerException();
+ }
int len = seq.length();
- if (beginIndex < 0 || endIndex > len || beginIndex > endIndex)
+ if (beginIndex < 0 || endIndex > len || beginIndex > endIndex) {
throw new IndexOutOfBoundsException();
+ }
int result = 0;
for (int i = beginIndex; i < endIndex; i++) {
@@ -2146,8 +2181,9 @@
if (isHighSurrogate(c)) {
if (++i < endIndex) {
c = seq.charAt(i);
- if (!isLowSurrogate(c))
+ if (!isLowSurrogate(c)) {
result++;
+ }
}
}
result++;
@@ -2175,12 +2211,14 @@
* @since 1.5
*/
public static int codePointCount(char[] seq, int offset, int count) {
- if (seq == null)
+ if (seq == null) {
throw new NullPointerException();
+ }
int len = seq.length;
int endIndex = offset + count;
- if (offset < 0 || count < 0 || endIndex > len)
+ if (offset < 0 || count < 0 || endIndex > len) {
throw new IndexOutOfBoundsException();
+ }
int result = 0;
for (int i = offset; i < endIndex; i++) {
@@ -2188,8 +2226,9 @@
if (isHighSurrogate(c)) {
if (++i < endIndex) {
c = seq[i];
- if (!isLowSurrogate(c))
+ if (!isLowSurrogate(c)) {
result++;
+ }
}
}
result++;
@@ -2221,26 +2260,31 @@
*/
public static int offsetByCodePoints(CharSequence seq, int index,
int codePointOffset) {
- if (seq == null)
+ if (seq == null) {
throw new NullPointerException();
+ }
int len = seq.length();
- if (index < 0 || index > len)
+ if (index < 0 || index > len) {
throw new IndexOutOfBoundsException();
+ }
- if (codePointOffset == 0)
+ if (codePointOffset == 0) {
return index;
+ }
if (codePointOffset > 0) {
int codePoints = codePointOffset;
int i = index;
while (codePoints > 0) {
codePoints--;
- if (i >= len)
+ if (i >= len) {
throw new IndexOutOfBoundsException();
+ }
if (isHighSurrogate(seq.charAt(i))) {
int next = i + 1;
- if (next < len && isLowSurrogate(seq.charAt(next)))
+ if (next < len && isLowSurrogate(seq.charAt(next))) {
i++;
+ }
}
i++;
}
@@ -2253,12 +2297,14 @@
while (codePoints > 0) {
codePoints--;
i--;
- if (i < 0)
+ if (i < 0) {
throw new IndexOutOfBoundsException();
+ }
if (isLowSurrogate(seq.charAt(i))) {
int prev = i - 1;
- if (prev >= 0 && isHighSurrogate(seq.charAt(prev)))
+ if (prev >= 0 && isHighSurrogate(seq.charAt(prev))) {
i--;
+ }
}
}
return i;
@@ -2296,27 +2342,32 @@
*/
public static int offsetByCodePoints(char[] seq, int start, int count,
int index, int codePointOffset) {
- if (seq == null)
+ if (seq == null) {
throw new NullPointerException();
+ }
int end = start + count;
if (start < 0 || count < 0 || end > seq.length || index < start
- || index > end)
+ || index > end) {
throw new IndexOutOfBoundsException();
+ }
- if (codePointOffset == 0)
+ if (codePointOffset == 0) {
return index;
+ }
if (codePointOffset > 0) {
int codePoints = codePointOffset;
int i = index;
while (codePoints > 0) {
codePoints--;
- if (i >= end)
+ if (i >= end) {
throw new IndexOutOfBoundsException();
+ }
if (isHighSurrogate(seq[i])) {
int next = i + 1;
- if (next < end && isLowSurrogate(seq[next]))
+ if (next < end && isLowSurrogate(seq[next])) {
i++;
+ }
}
i++;
}
@@ -2329,12 +2380,14 @@
while (codePoints > 0) {
codePoints--;
i--;
- if (i < start)
+ if (i < start) {
throw new IndexOutOfBoundsException();
+ }
if (isLowSurrogate(seq[i])) {
int prev = i - 1;
- if (prev >= start && isHighSurrogate(seq[prev]))
+ if (prev >= start && isHighSurrogate(seq[prev])) {
i--;
+ }
}
}
return i;
@@ -2356,19 +2409,21 @@
if (c < 128) {
// Optimized for ASCII
int result = -1;
- if ('0' <= c && c <= '9')
- result = c - '0';
- else if ('a' <= c && c <= 'z')
- result = c - ('a' - 10);
- else if ('A' <= c && c <= 'Z')
- result = c - ('A' - 10);
+ if ('0' <= c && c <= '9') {
+ result = c - '0';
+ } else if ('a' <= c && c <= 'z') {
+ result = c - ('a' - 10);
+ } else if ('A' <= c && c <= 'Z') {
+ result = c - ('A' - 10);
+ }
return result < radix ? result : -1;
}
int result = BinarySearch.binarySearchRange(digitKeys, c);
if (result >= 0 && c <= digitValues[result * 2]) {
int value = (char) (c - digitValues[result * 2 + 1]);
- if (value >= radix)
- return -1;
+ if (value >= radix) {
+ return -1;
+ }
return value;
}
}
@@ -2405,9 +2460,11 @@
* @return the character which represents the value in the radix
*/
public static char forDigit(int digit, int radix) {
- if (MIN_RADIX <= radix && radix <= MAX_RADIX)
- if (0 <= digit && digit < radix)
- return (char) (digit < 10 ? digit + '0' : digit + 'a' - 10);
+ if (MIN_RADIX <= radix && radix <= MAX_RADIX) {
+ if (0 <= digit && digit < radix) {
+ return (char) (digit < 10 ? digit + '0' : digit + 'a' - 10);
+ }
+ }
return 0;
}
@@ -2422,22 +2479,27 @@
public static int getNumericValue(char c) {
if (c < 128) {
// Optimized for ASCII
- if (c >= '0' && c <= '9')
- return c - '0';
- if (c >= 'a' && c <= 'z')
- return c - ('a' - 10);
- if (c >= 'A' && c <= 'Z')
- return c - ('A' - 10);
+ if (c >= '0' && c <= '9') {
+ return c - '0';
+ }
+ if (c >= 'a' && c <= 'z') {
+ return c - ('a' - 10);
+ }
+ if (c >= 'A' && c <= 'Z') {
+ return c - ('A' - 10);
+ }
return -1;
}
int result = BinarySearch.binarySearchRange(numericKeys, c);
if (result >= 0 && c <= numericValues[result * 2]) {
char difference = numericValues[result * 2 + 1];
- if (difference == 0)
- return -2;
+ if (difference == 0) {
+ return -2;
+ }
// Value is always positive, must be negative value
- if (difference > c)
- return c - (short) difference;
+ if (difference > c) {
+ return c - (short) difference;
+ }
return c - difference;
}
return -1;
@@ -2455,8 +2517,9 @@
int high = typeValues[result * 2];
if (c <= high) {
int code = typeValues[result * 2 + 1];
- if (code < 0x100)
- return code;
+ if (code < 0x100) {
+ return code;
+ }
return (c & 1) == 1 ? code >> 8 : code & 0xff;
}
return UNASSIGNED;
@@ -2474,8 +2537,9 @@
int high = bidiValues[result * 2];
if (c <= high) {
int code = bidiValues[result * 2 + 1];
- if (code < 0x100)
- return (byte) (code - 1);
+ if (code < 0x100) {
+ return (byte) (code - 1);
+ }
return (byte) (((c & 1) == 1 ? code >> 8 : code & 0xff) - 1);
}
return DIRECTIONALITY_UNDEFINED;
@@ -2490,8 +2554,9 @@
*/
public static boolean isMirrored(char c) {
int value = c / 16;
- if (value >= mirrored.length)
- return false;
+ if (value >= mirrored.length) {
+ return false;
+ }
int bit = 1 << (c % 16);
return (mirrored[value] & bit) != 0;
}
@@ -2531,10 +2596,12 @@
*/
public static boolean isDigit(char c) {
// Optimized case for ASCII
- if ('0' <= c && c <= '9')
- return true;
- if (c < 1632)
- return false;
+ if ('0' <= c && c <= '9') {
+ return true;
+ }
+ if (c < 1632) {
+ return false;
+ }
return getType(c) == DECIMAL_DIGIT_NUMBER;
}
@@ -2586,8 +2653,9 @@
*/
public static boolean isJavaIdentifierPart(char c) {
// Optimized case for ASCII
- if (c < 128)
- return (typeTags[c] & ISJAVAPART) != 0;
+ if (c < 128) {
+ return (typeTags[c] & ISJAVAPART) != 0;
+ }
int type = getType(c);
return (type >= UPPERCASE_LETTER && type <= OTHER_LETTER)
@@ -2608,8 +2676,9 @@
*/
public static boolean isJavaIdentifierStart(char c) {
// Optimized case for ASCII
- if (c < 128)
- return (typeTags[c] & ISJAVASTART) != 0;
+ if (c < 128) {
+ return (typeTags[c] & ISJAVASTART) != 0;
+ }
int type = getType(c);
return (type >= UPPERCASE_LETTER && type <= OTHER_LETTER)
@@ -2643,10 +2712,12 @@
* @return true when the character is a letter, false otherwise
*/
public static boolean isLetter(char c) {
- if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z'))
- return true;
- if (c < 128)
- return false;
+ if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')) {
+ return true;
+ }
+ if (c < 128) {
+ return false;
+ }
int type = getType(c);
return type >= UPPERCASE_LETTER && type <= OTHER_LETTER;
}
@@ -2673,10 +2744,12 @@
*/
public static boolean isLowerCase(char c) {
// Optimized case for ASCII
- if ('a' <= c && c <= 'z')
- return true;
- if (c < 128)
- return false;
+ if ('a' <= c && c <= 'z') {
+ return true;
+ }
+ if (c < 128) {
+ return false;
+ }
return getType(c) == LOWERCASE_LETTER;
}
@@ -2701,10 +2774,12 @@
* otherwise
*/
public static boolean isSpaceChar(char c) {
- if (c == 0x20 || c == 0xa0 || c == 0x1680)
- return true;
- if (c < 0x2000)
- return false;
+ if (c == 0x20 || c == 0xa0 || c == 0x1680) {
+ return true;
+ }
+ if (c < 0x2000) {
+ return false;
+ }
return c <= 0x200b || c == 0x2028 || c == 0x2029 || c == 0x202f
|| c == 0x3000;
}
@@ -2718,12 +2793,14 @@
* otherwise
*/
public static boolean isTitleCase(char c) {
- if (c == '\u01c5' || c == '\u01c8' || c == '\u01cb' || c == '\u01f2')
- return true;
+ if (c == '\u01c5' || c == '\u01c8' || c == '\u01cb' || c == '\u01f2') {
+ return true;
+ }
if (c >= '\u1f88' && c <= '\u1ffc') {
// 0x1f88 - 0x1f8f, 0x1f98 - 0x1f9f, 0x1fa8 - 0x1faf
- if (c > '\u1faf')
- return c == '\u1fbc' || c == '\u1fcc' || c == '\u1ffc';
+ if (c > '\u1faf') {
+ return c == '\u1fbc' || c == '\u1fcc' || c == '\u1ffc';
+ }
int last = c & 0xf;
return last >= 8 && last <= 0xf;
}
@@ -2772,10 +2849,12 @@
*/
public static boolean isUpperCase(char c) {
// Optimized case for ASCII
- if ('A' <= c && c <= 'Z')
- return true;
- if (c < 128)
- return false;
+ if ('A' <= c && c <= 'Z') {
+ return true;
+ }
+ if (c < 128) {
+ return false;
+ }
return getType(c) == UPPERCASE_LETTER;
}
@@ -2790,12 +2869,15 @@
*/
public static boolean isWhitespace(char c) {
// Optimized case for ASCII
- if ((c >= 0x1c && c <= 0x20) || (c >= 0x9 && c <= 0xd))
- return true;
- if (c == 0x1680)
- return true;
- if (c < 0x2000 || c == 0x2007)
- return false;
+ if ((c >= 0x1c && c <= 0x20) || (c >= 0x9 && c <= 0xd)) {
+ return true;
+ }
+ if (c == 0x1680) {
+ return true;
+ }
+ if (c < 0x2000 || c == 0x2007) {
+ return false;
+ }
return c <= 0x200b || c == 0x2028 || c == 0x2029 || c == 0x3000;
}
@@ -2820,10 +2902,12 @@
*/
public static char toLowerCase(char c) {
// Optimized case for ASCII
- if ('A' <= c && c <= 'Z')
- return (char) (c + ('a' - 'A'));
- if (c < 128)
- return c;
+ if ('A' <= c && c <= 'Z') {
+ return (char) (c + ('a' - 'A'));
+ }
+ if (c < 128) {
+ return c;
+ }
int result = BinarySearch.binarySearchRange(lowercaseKeys, c);
if (result >= 0) {
@@ -2835,8 +2919,9 @@
by2 = true;
}
if (c <= end) {
- if (by2 && (c & 1) != (start & 1))
- return c;
+ if (by2 && (c & 1) != (start & 1)) {
+ return c;
+ }
char mapping = lowercaseValues[result * 2 + 1];
return (char) (c + mapping);
}
@@ -2874,11 +2959,13 @@
* @return the title case equivalent of the character
*/
public static char toTitleCase(char c) {
- if (isTitleCase(c))
- return c;
+ if (isTitleCase(c)) {
+ return c;
+ }
int result = BinarySearch.binarySearch(titlecaseKeys, c);
- if (result >= 0)
- return titlecaseValues[result];
+ if (result >= 0) {
+ return titlecaseValues[result];
+ }
return toUpperCase(c);
}
@@ -2893,10 +2980,12 @@
*/
public static char toUpperCase(char c) {
// Optimized case for ASCII
- if ('a' <= c && c <= 'z')
- return (char) (c - ('a' - 'A'));
- if (c < 128)
- return c;
+ if ('a' <= c && c <= 'z') {
+ return (char) (c - ('a' - 'A'));
+ }
+ if (c < 128) {
+ return c;
+ }
int result = BinarySearch.binarySearchRange(uppercaseKeys, c);
if (result >= 0) {
@@ -2908,8 +2997,9 @@
by2 = true;
}
if (c <= end) {
- if (by2 && (c & 1) != (start & 1))
- return c;
+ if (by2 && (c & 1) != (start & 1)) {
+ return c;
+ }
char mapping = uppercaseValues[result * 2 + 1];
return (char) (c + mapping);
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java?rev=430231&r1=430230&r2=430231&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java Wed Aug 9 20:41:40 2006
@@ -155,7 +155,8 @@
*
* @return byte the value of the receiver.
*/
- public byte byteValue() {
+ @Override
+ public byte byteValue() {
return (byte) value;
}
@@ -182,7 +183,8 @@
*
* @return the receiver's value
*/
- public double doubleValue() {
+ @Override
+ public double doubleValue() {
return value;
}
@@ -198,7 +200,8 @@
* <code>false</code> if it is different from this object
* @see #hashCode
*/
- public boolean equals(Object object) {
+ @Override
+ public boolean equals(Object object) {
return (object == this)
|| (object instanceof Double)
&& (doubleToLongBits(this.value) == doubleToLongBits(((Double) object).value));
@@ -209,7 +212,8 @@
*
* @return float the value of the receiver.
*/
- public float floatValue() {
+ @Override
+ public float floatValue() {
return (float) value;
}
@@ -222,7 +226,8 @@
*
* @see #equals
*/
- public int hashCode() {
+ @Override
+ public int hashCode() {
long v = doubleToLongBits(value);
return (int) (v ^ (v >>> 32));
}
@@ -232,7 +237,8 @@
*
* @return the receiver's value as an integer
*/
- public int intValue() {
+ @Override
+ public int intValue() {
return (int) value;
}
@@ -299,7 +305,8 @@
*
* @return long the value of the receiver.
*/
- public long longValue() {
+ @Override
+ public long longValue() {
return (long) value;
}
@@ -322,7 +329,8 @@
*
* @return short the value of the receiver.
*/
- public short shortValue() {
+ @Override
+ public short shortValue() {
return (short) value;
}
@@ -332,7 +340,8 @@
*
* @return a printable representation for the receiver.
*/
- public String toString() {
+ @Override
+ public String toString() {
return Double.toString(value);
}
@@ -423,12 +432,15 @@
/*
* Reference: http://en.wikipedia.org/wiki/IEEE_754
*/
- if (d != d) // isNaN
+ if (d != d) {
return "NaN";
- if (d == POSITIVE_INFINITY)
+ }
+ if (d == POSITIVE_INFINITY) {
return "Infinity";
- if (d == NEGATIVE_INFINITY)
+ }
+ if (d == NEGATIVE_INFINITY) {
return "-Infinity";
+ }
long bitValue = doubleToLongBits(d);
@@ -438,14 +450,16 @@
// mask significand bits and shift up
long significand = bitValue & 0x000FFFFFFFFFFFFFL;
- if (exponent == 0 && significand == 0)
+ if (exponent == 0 && significand == 0) {
return (negative ? "-0x0.0p0" : "0x0.0p0");
+ }
StringBuilder hexString = new StringBuilder(10);
- if (negative)
+ if (negative) {
hexString.append("-0x");
- else
+ } else {
hexString.append("0x");
+ }
if (exponent == 0) { // denormal (subnormal) value
hexString.append("0.");
@@ -463,8 +477,9 @@
// if there are digits left, then insert some '0' chars first
if (fractionDigits > hexSignificand.length()) {
int digitDiff = fractionDigits - hexSignificand.length();
- while (digitDiff-- != 0)
+ while (digitDiff-- != 0) {
hexString.append('0');
+ }
}
hexString.append(hexSignificand);
hexString.append("p-1022");
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java?rev=430231&r1=430230&r2=430231&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java Wed Aug 9 20:41:40 2006
@@ -164,7 +164,8 @@
*
* @return byte the value of the receiver.
*/
- public byte byteValue() {
+ @Override
+ public byte byteValue() {
return (byte) value;
}
@@ -173,7 +174,8 @@
*
* @return double the value of the receiver.
*/
- public double doubleValue() {
+ @Override
+ public double doubleValue() {
return value;
}
@@ -189,7 +191,8 @@
* <code>false</code> if it is different from this object
* @see #hashCode
*/
- public boolean equals(Object object) {
+ @Override
+ public boolean equals(Object object) {
return (object == this)
|| (object instanceof Float)
&& (floatToIntBits(this.value) == floatToIntBits(((Float) object).value));
@@ -218,7 +221,8 @@
*
* @return the receiver's value
*/
- public float floatValue() {
+ @Override
+ public float floatValue() {
return value;
}
@@ -231,7 +235,8 @@
*
* @see #equals
*/
- public int hashCode() {
+ @Override
+ public int hashCode() {
return floatToIntBits(value);
}
@@ -250,7 +255,8 @@
*
* @return int the value of the receiver.
*/
- public int intValue() {
+ @Override
+ public int intValue() {
return (int) value;
}
@@ -307,7 +313,8 @@
*
* @return long the value of the receiver.
*/
- public long longValue() {
+ @Override
+ public long longValue() {
return (long) value;
}
@@ -332,7 +339,8 @@
* @return short the value of the receiver.
* @since 1.1
*/
- public short shortValue() {
+ @Override
+ public short shortValue() {
return (short) value;
}
@@ -342,7 +350,8 @@
*
* @return a printable representation for the receiver.
*/
- public String toString() {
+ @Override
+ public String toString() {
return Float.toString(value);
}
@@ -434,12 +443,15 @@
/*
* Reference: http://en.wikipedia.org/wiki/IEEE_754
*/
- if (f != f) // isNaN
+ if (f != f) {
return "NaN";
- if (f == POSITIVE_INFINITY)
+ }
+ if (f == POSITIVE_INFINITY) {
return "Infinity";
- if (f == NEGATIVE_INFINITY)
+ }
+ if (f == NEGATIVE_INFINITY) {
return "-Infinity";
+ }
int bitValue = floatToIntBits(f);
@@ -450,14 +462,16 @@
// significand is 23-bits, so we shift to treat it like 24-bits
int significand = (bitValue & 0x007FFFFF) << 1;
- if (exponent == 0 && significand == 0)
+ if (exponent == 0 && significand == 0) {
return (negative ? "-0x0.0p0" : "0x0.0p0");
+ }
StringBuilder hexString = new StringBuilder(10);
- if (negative)
+ if (negative) {
hexString.append("-0x");
- else
+ } else {
hexString.append("0x");
+ }
if (exponent == 0) { // denormal (subnormal) value
hexString.append("0.");
@@ -475,8 +489,9 @@
// if there are digits left, then insert some '0' chars first
if (fractionDigits > hexSignificand.length()) {
int digitDiff = fractionDigits - hexSignificand.length();
- while (digitDiff-- != 0)
+ while (digitDiff-- != 0) {
hexString.append('0');
+ }
}
hexString.append(hexSignificand);
hexString.append("p-126");
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Integer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Integer.java?rev=430231&r1=430230&r2=430231&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Integer.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Integer.java Wed Aug 9 20:41:40 2006
@@ -108,7 +108,8 @@
*
* @return byte the value of the receiver.
*/
- public byte byteValue() {
+ @Override
+ public byte byteValue() {
return (byte) value;
}
@@ -145,31 +146,36 @@
*/
public static Integer decode(String string) throws NumberFormatException {
int length = string.length(), i = 0;
- if (length == 0)
- throw new NumberFormatException();
+ if (length == 0) {
+ throw new NumberFormatException();
+ }
char firstDigit = string.charAt(i);
boolean negative = firstDigit == '-';
if (negative) {
- if (length == 1)
- throw new NumberFormatException(string);
+ if (length == 1) {
+ throw new NumberFormatException(string);
+ }
firstDigit = string.charAt(++i);
}
int base = 10;
if (firstDigit == '0') {
- if (++i == length)
- return valueOf(0);
+ if (++i == length) {
+ return valueOf(0);
+ }
if ((firstDigit = string.charAt(i)) == 'x' || firstDigit == 'X') {
- if (i == length)
- throw new NumberFormatException(string);
+ if (i == length) {
+ throw new NumberFormatException(string);
+ }
i++;
base = 16;
} else {
base = 8;
}
} else if (firstDigit == '#') {
- if (i == length)
- throw new NumberFormatException(string);
+ if (i == length) {
+ throw new NumberFormatException(string);
+ }
i++;
base = 16;
}
@@ -183,7 +189,8 @@
*
* @return double the value of the receiver.
*/
- public double doubleValue() {
+ @Override
+ public double doubleValue() {
return value;
}
@@ -200,7 +207,8 @@
* <code>false</code> if it is different from this object
* @see #hashCode
*/
- public boolean equals(Object o) {
+ @Override
+ public boolean equals(Object o) {
return (o == this) || (o instanceof Integer)
&& (value == ((Integer) o).value);
}
@@ -210,7 +218,8 @@
*
* @return float the value of the receiver.
*/
- public float floatValue() {
+ @Override
+ public float floatValue() {
return value;
}
@@ -224,11 +233,13 @@
* @return Integer An Integer representing the value of the property.
*/
public static Integer getInteger(String string) {
- if (string == null || string.length() == 0)
- return null;
+ if (string == null || string.length() == 0) {
+ return null;
+ }
String prop = System.getProperty(string);
- if (prop == null)
- return null;
+ if (prop == null) {
+ return null;
+ }
try {
return decode(prop);
} catch (NumberFormatException ex) {
@@ -247,11 +258,13 @@
* @return Integer An Integer representing the value of the property.
*/
public static Integer getInteger(String string, int defaultValue) {
- if (string == null || string.length() == 0)
- return valueOf(defaultValue);
+ if (string == null || string.length() == 0) {
+ return valueOf(defaultValue);
+ }
String prop = System.getProperty(string);
- if (prop == null)
- return valueOf(defaultValue);
+ if (prop == null) {
+ return valueOf(defaultValue);
+ }
try {
return decode(prop);
} catch (NumberFormatException ex) {
@@ -269,11 +282,13 @@
* @return Integer An Integer representing the value of the property.
*/
public static Integer getInteger(String string, Integer defaultValue) {
- if (string == null || string.length() == 0)
- return defaultValue;
+ if (string == null || string.length() == 0) {
+ return defaultValue;
+ }
String prop = System.getProperty(string);
- if (prop == null)
- return defaultValue;
+ if (prop == null) {
+ return defaultValue;
+ }
try {
return decode(prop);
} catch (NumberFormatException ex) {
@@ -290,7 +305,8 @@
*
* @see #equals
*/
- public int hashCode() {
+ @Override
+ public int hashCode() {
return value;
}
@@ -299,7 +315,8 @@
*
* @return int the value of the receiver.
*/
- public int intValue() {
+ @Override
+ public int intValue() {
return value;
}
@@ -308,7 +325,8 @@
*
* @return long the value of the receiver.
*/
- public long longValue() {
+ @Override
+ public long longValue() {
return value;
}
@@ -344,14 +362,17 @@
public static int parseInt(String string, int radix)
throws NumberFormatException {
if (string == null || radix < Character.MIN_RADIX
- || radix > Character.MAX_RADIX)
- throw new NumberFormatException();
+ || radix > Character.MAX_RADIX) {
+ throw new NumberFormatException();
+ }
int length = string.length(), i = 0;
- if (length == 0)
- throw new NumberFormatException(string);
+ if (length == 0) {
+ throw new NumberFormatException(string);
+ }
boolean negative = string.charAt(i) == '-';
- if (negative && ++i == length)
- throw new NumberFormatException(string);
+ if (negative && ++i == length) {
+ throw new NumberFormatException(string);
+ }
return parse(string, i, radix, negative);
}
@@ -362,19 +383,23 @@
int result = 0, length = string.length();
while (offset < length) {
int digit = Character.digit(string.charAt(offset++), radix);
- if (digit == -1)
- throw new NumberFormatException(string);
- if (max > result)
- throw new NumberFormatException(string);
+ if (digit == -1) {
+ throw new NumberFormatException(string);
+ }
+ if (max > result) {
+ throw new NumberFormatException(string);
+ }
int next = result * radix - digit;
- if (next > result)
- throw new NumberFormatException(string);
+ if (next > result) {
+ throw new NumberFormatException(string);
+ }
result = next;
}
if (!negative) {
result = -result;
- if (result < 0)
- throw new NumberFormatException(string);
+ if (result < 0) {
+ throw new NumberFormatException(string);
+ }
}
return result;
}
@@ -384,7 +409,8 @@
*
* @return short the value of the receiver.
*/
- public short shortValue() {
+ @Override
+ public short shortValue() {
return (short) value;
}
@@ -399,11 +425,13 @@
public static String toBinaryString(int i) {
int count = 1, j = i;
- if (i < 0)
- count = 32;
- else
- while ((j >>>= 1) != 0)
- count++;
+ if (i < 0) {
+ count = 32;
+ } else {
+ while ((j >>>= 1) != 0) {
+ count++;
+ }
+ }
char[] buffer = new char[count];
do {
@@ -424,19 +452,22 @@
public static String toHexString(int i) {
int count = 1, j = i;
- if (i < 0)
- count = 8;
- else
- while ((j >>>= 4) != 0)
- count++;
+ if (i < 0) {
+ count = 8;
+ } else {
+ while ((j >>>= 4) != 0) {
+ count++;
+ }
+ }
char[] buffer = new char[count];
do {
int t = i & 15;
- if (t > 9)
- t = t - 10 + 'a';
- else
- t += '0';
+ if (t > 9) {
+ t = t - 10 + 'a';
+ } else {
+ t += '0';
+ }
buffer[--count] = (char) t;
i >>>= 4;
} while (count > 0);
@@ -454,11 +485,13 @@
public static String toOctalString(int i) {
int count = 1, j = i;
- if (i < 0)
- count = 11;
- else
- while ((j >>>= 3) != 0)
- count++;
+ if (i < 0) {
+ count = 11;
+ } else {
+ while ((j >>>= 3) != 0) {
+ count++;
+ }
+ }
char[] buffer = new char[count];
do {
@@ -474,7 +507,8 @@
*
* @return a printable representation for the receiver.
*/
- public String toString() {
+ @Override
+ public String toString() {
return Integer.toString(value);
}
@@ -502,10 +536,12 @@
* @return String the representation of the argument
*/
public static String toString(int i, int radix) {
- if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
- radix = 10;
- if (i == 0)
- return "0";
+ if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) {
+ radix = 10;
+ }
+ if (i == 0) {
+ return "0";
+ }
int count = 2, j = i;
boolean negative = i < 0;
@@ -513,20 +549,23 @@
count = 1;
j = -i;
}
- while ((i /= radix) != 0)
- count++;
+ while ((i /= radix) != 0) {
+ count++;
+ }
char[] buffer = new char[count];
do {
int ch = 0 - (j % radix);
- if (ch > 9)
- ch = ch - 10 + 'a';
- else
- ch += '0';
+ if (ch > 9) {
+ ch = ch - 10 + 'a';
+ } else {
+ ch += '0';
+ }
buffer[--count] = (char) ch;
} while ((j /= radix) != 0);
- if (negative)
- buffer[0] = '-';
+ if (negative) {
+ buffer[0] = '-';
+ }
return new String(0, buffer.length, buffer);
}
@@ -646,8 +685,9 @@
* @since 1.5
*/
public static int rotateLeft(int i, int distance) {
- if (distance == 0)
+ if (distance == 0) {
return i;
+ }
/*
* According to JLS3, 15.19, the right operand of a shift is always
* implicitly masked with 0x1F, which the negation of 'distance' is
@@ -665,8 +705,9 @@
* @since 1.5
*/
public static int rotateRight(int i, int distance) {
- if (distance == 0)
+ if (distance == 0) {
return i;
+ }
/*
* According to JLS3, 15.19, the right operand of a shift is always
* implicitly masked with 0x1F, which the negation of 'distance' is
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Long.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Long.java?rev=430231&r1=430230&r2=430231&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Long.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Long.java Wed Aug 9 20:41:40 2006
@@ -108,7 +108,8 @@
*
* @return byte the value of the receiver.
*/
- public byte byteValue() {
+ @Override
+ public byte byteValue() {
return (byte) value;
}
@@ -145,31 +146,36 @@
*/
public static Long decode(String string) throws NumberFormatException {
int length = string.length(), i = 0;
- if (length == 0)
- throw new NumberFormatException();
+ if (length == 0) {
+ throw new NumberFormatException();
+ }
char firstDigit = string.charAt(i);
boolean negative = firstDigit == '-';
if (negative) {
- if (length == 1)
- throw new NumberFormatException(string);
+ if (length == 1) {
+ throw new NumberFormatException(string);
+ }
firstDigit = string.charAt(++i);
}
int base = 10;
if (firstDigit == '0') {
- if (++i == length)
- return valueOf(0L);
+ if (++i == length) {
+ return valueOf(0L);
+ }
if ((firstDigit = string.charAt(i)) == 'x' || firstDigit == 'X') {
- if (i == length)
- throw new NumberFormatException(string);
+ if (i == length) {
+ throw new NumberFormatException(string);
+ }
i++;
base = 16;
} else {
base = 8;
}
} else if (firstDigit == '#') {
- if (i == length)
- throw new NumberFormatException(string);
+ if (i == length) {
+ throw new NumberFormatException(string);
+ }
i++;
base = 16;
}
@@ -183,7 +189,8 @@
*
* @return double the value of the receiver.
*/
- public double doubleValue() {
+ @Override
+ public double doubleValue() {
return value;
}
@@ -200,7 +207,8 @@
* <code>false</code> if it is different from this object
* @see #hashCode
*/
- public boolean equals(Object o) {
+ @Override
+ public boolean equals(Object o) {
return (o == this) || (o instanceof Long)
&& (value == ((Long) o).value);
}
@@ -210,7 +218,8 @@
*
* @return float the value of the receiver.
*/
- public float floatValue() {
+ @Override
+ public float floatValue() {
return value;
}
@@ -224,11 +233,13 @@
* @return Long A Long representing the value of the property.
*/
public static Long getLong(String string) {
- if (string == null || string.length() == 0)
- return null;
+ if (string == null || string.length() == 0) {
+ return null;
+ }
String prop = System.getProperty(string);
- if (prop == null)
- return null;
+ if (prop == null) {
+ return null;
+ }
try {
return decode(prop);
} catch (NumberFormatException ex) {
@@ -246,11 +257,13 @@
* @return Long An Long representing the value of the property.
*/
public static Long getLong(String string, long defaultValue) {
- if (string == null || string.length() == 0)
- return valueOf(defaultValue);
+ if (string == null || string.length() == 0) {
+ return valueOf(defaultValue);
+ }
String prop = System.getProperty(string);
- if (prop == null)
- return valueOf(defaultValue);
+ if (prop == null) {
+ return valueOf(defaultValue);
+ }
try {
return decode(prop);
} catch (NumberFormatException ex) {
@@ -268,11 +281,13 @@
* @return Long An Long representing the value of the property.
*/
public static Long getLong(String string, Long defaultValue) {
- if (string == null || string.length() == 0)
- return defaultValue;
+ if (string == null || string.length() == 0) {
+ return defaultValue;
+ }
String prop = System.getProperty(string);
- if (prop == null)
- return defaultValue;
+ if (prop == null) {
+ return defaultValue;
+ }
try {
return decode(prop);
} catch (NumberFormatException ex) {
@@ -289,7 +304,8 @@
*
* @see #equals
*/
- public int hashCode() {
+ @Override
+ public int hashCode() {
return (int) (value ^ (value >>> 32));
}
@@ -298,7 +314,8 @@
*
* @return int the value of the receiver.
*/
- public int intValue() {
+ @Override
+ public int intValue() {
return (int) value;
}
@@ -307,7 +324,8 @@
*
* @return long the value of the receiver.
*/
- public long longValue() {
+ @Override
+ public long longValue() {
return value;
}
@@ -343,14 +361,17 @@
public static long parseLong(String string, int radix)
throws NumberFormatException {
if (string == null || radix < Character.MIN_RADIX
- || radix > Character.MAX_RADIX)
- throw new NumberFormatException();
+ || radix > Character.MAX_RADIX) {
+ throw new NumberFormatException();
+ }
int length = string.length(), i = 0;
- if (length == 0)
- throw new NumberFormatException(string);
+ if (length == 0) {
+ throw new NumberFormatException(string);
+ }
boolean negative = string.charAt(i) == '-';
- if (negative && ++i == length)
- throw new NumberFormatException(string);
+ if (negative && ++i == length) {
+ throw new NumberFormatException(string);
+ }
return parse(string, i, radix, negative);
}
@@ -361,19 +382,23 @@
long result = 0, length = string.length();
while (offset < length) {
int digit = Character.digit(string.charAt(offset++), radix);
- if (digit == -1)
- throw new NumberFormatException(string);
- if (max > result)
- throw new NumberFormatException(string);
+ if (digit == -1) {
+ throw new NumberFormatException(string);
+ }
+ if (max > result) {
+ throw new NumberFormatException(string);
+ }
long next = result * radix - digit;
- if (next > result)
- throw new NumberFormatException(string);
+ if (next > result) {
+ throw new NumberFormatException(string);
+ }
result = next;
}
if (!negative) {
result = -result;
- if (result < 0)
- throw new NumberFormatException(string);
+ if (result < 0) {
+ throw new NumberFormatException(string);
+ }
}
return result;
}
@@ -383,7 +408,8 @@
*
* @return short the value of the receiver.
*/
- public short shortValue() {
+ @Override
+ public short shortValue() {
return (short) value;
}
@@ -399,11 +425,13 @@
int count = 1;
long j = l;
- if (l < 0)
- count = 64;
- else
- while ((j >>= 1) != 0)
- count++;
+ if (l < 0) {
+ count = 64;
+ } else {
+ while ((j >>= 1) != 0) {
+ count++;
+ }
+ }
char[] buffer = new char[count];
do {
@@ -425,19 +453,22 @@
int count = 1;
long j = l;
- if (l < 0)
- count = 16;
- else
- while ((j >>= 4) != 0)
- count++;
+ if (l < 0) {
+ count = 16;
+ } else {
+ while ((j >>= 4) != 0) {
+ count++;
+ }
+ }
char[] buffer = new char[count];
do {
int t = (int) (l & 15);
- if (t > 9)
- t = t - 10 + 'a';
- else
- t += '0';
+ if (t > 9) {
+ t = t - 10 + 'a';
+ } else {
+ t += '0';
+ }
buffer[--count] = (char) t;
l >>= 4;
} while (count > 0);
@@ -456,11 +487,13 @@
int count = 1;
long j = l;
- if (l < 0)
- count = 22;
- else
- while ((j >>>= 3) != 0)
- count++;
+ if (l < 0) {
+ count = 22;
+ } else {
+ while ((j >>>= 3) != 0) {
+ count++;
+ }
+ }
char[] buffer = new char[count];
do {
@@ -476,7 +509,8 @@
*
* @return a printable representation for the receiver.
*/
- public String toString() {
+ @Override
+ public String toString() {
return Long.toString(value);
}
@@ -504,10 +538,12 @@
* @return String the representation of the argument
*/
public static String toString(long l, int radix) {
- if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
- radix = 10;
- if (l == 0)
- return "0";
+ if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) {
+ radix = 10;
+ }
+ if (l == 0) {
+ return "0";
+ }
int count = 2;
long j = l;
@@ -516,20 +552,23 @@
count = 1;
j = -l;
}
- while ((l /= radix) != 0)
- count++;
+ while ((l /= radix) != 0) {
+ count++;
+ }
char[] buffer = new char[count];
do {
int ch = 0 - (int) (j % radix);
- if (ch > 9)
- ch = ch - 10 + 'a';
- else
- ch += '0';
+ if (ch > 9) {
+ ch = ch - 10 + 'a';
+ } else {
+ ch += '0';
+ }
buffer[--count] = (char) ch;
} while ((j /= radix) != 0);
- if (negative)
- buffer[0] = '-';
+ if (negative) {
+ buffer[0] = '-';
+ }
return new String(0, buffer.length, buffer);
}
@@ -670,8 +709,9 @@
* @since 1.5
*/
public static long rotateLeft(long lng, int distance) {
- if (distance == 0)
+ if (distance == 0) {
return lng;
+ }
/*
* According to JLS3, 15.19, the right operand of a shift is always
* implicitly masked with 0x3F, which the negation of 'distance' is
@@ -692,8 +732,9 @@
* @since 1.5
*/
public static long rotateRight(long lng, int distance) {
- if (distance == 0)
+ if (distance == 0) {
return lng;
+ }
/*
* According to JLS3, 15.19, the right operand of a shift is always
* implicitly masked with 0x3F, which the negation of 'distance' is
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Short.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Short.java?rev=430231&r1=430230&r2=430231&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Short.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Short.java Wed Aug 9 20:41:40 2006
@@ -101,7 +101,8 @@
*
* @return byte the value of the receiver.
*/
- public byte byteValue() {
+ @Override
+ public byte byteValue() {
return (byte) value;
}
@@ -139,8 +140,9 @@
public static Short decode(String string) throws NumberFormatException {
int intValue = Integer.decode(string).intValue();
short result = (short) intValue;
- if (result == intValue)
- return valueOf(result);
+ if (result == intValue) {
+ return valueOf(result);
+ }
throw new NumberFormatException();
}
@@ -149,7 +151,8 @@
*
* @return double the value of the receiver.
*/
- public double doubleValue() {
+ @Override
+ public double doubleValue() {
return value;
}
@@ -166,7 +169,8 @@
* <code>false</code> if it is different from this object
* @see #hashCode
*/
- public boolean equals(Object object) {
+ @Override
+ public boolean equals(Object object) {
return (object == this) || (object instanceof Short)
&& (value == ((Short) object).value);
}
@@ -176,7 +180,8 @@
*
* @return float the value of the receiver.
*/
- public float floatValue() {
+ @Override
+ public float floatValue() {
return value;
}
@@ -189,7 +194,8 @@
*
* @see #equals
*/
- public int hashCode() {
+ @Override
+ public int hashCode() {
return value;
}
@@ -198,7 +204,8 @@
*
* @return int the value of the receiver.
*/
- public int intValue() {
+ @Override
+ public int intValue() {
return value;
}
@@ -207,7 +214,8 @@
*
* @return long the value of the receiver.
*/
- public long longValue() {
+ @Override
+ public long longValue() {
return value;
}
@@ -244,8 +252,9 @@
throws NumberFormatException {
int intValue = Integer.parseInt(string, radix);
short result = (short) intValue;
- if (result == intValue)
- return result;
+ if (result == intValue) {
+ return result;
+ }
throw new NumberFormatException();
}
@@ -254,7 +263,8 @@
*
* @return short the value of the receiver.
*/
- public short shortValue() {
+ @Override
+ public short shortValue() {
return value;
}
@@ -264,7 +274,8 @@
*
* @return a printable representation for the receiver.
*/
- public String toString() {
+ @Override
+ public String toString() {
return Integer.toString(value);
}