You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/12/29 23:36:59 UTC
svn commit: r491123 [1/3] - in
/harmony/enhanced/classlib/trunk/modules/luni/src/main/java: java/io/
java/lang/ org/apache/harmony/luni/internal/nls/
Author: tellison
Date: Fri Dec 29 14:36:58 2006
New Revision: 491123
URL: http://svn.apache.org/viewvc?view=rev&rev=491123
Log:
Fix more compiler warnings, externalize messages, etc.
No functional changes.
Modified:
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ArrayIndexOutOfBoundsException.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Boolean.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ClassCastException.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Enum.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/EnumConstantNotPresentException.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Integer.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Long.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ProcessBuilder.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/RuntimePermission.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/SecurityManager.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/String.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/StringIndexOutOfBoundsException.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Void.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/nls/messages.properties
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java?view=diff&rev=491123&r1=491122&r2=491123
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectOutputStream.java Fri Dec 29 14:36:58 2006
@@ -1846,7 +1846,7 @@
if (!(enableReplace && computeStreamReplacement)) {
// Is it a Class ?
if (objClass == ObjectStreamClass.CLASSCLASS) {
- return writeNewClass((Class) object, unshared);
+ return writeNewClass((Class<?>) object, unshared);
}
// Is it an ObjectStreamClass ?
if (objClass == ObjectStreamClass.OBJECTSTREAMCLASSCLASS) {
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java?view=diff&rev=491123&r1=491122&r2=491123
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java Fri Dec 29 14:36:58 2006
@@ -163,7 +163,7 @@
*/
private Class<?> getTypeInternal() {
if (type instanceof WeakReference) {
- return (Class<?>)((WeakReference) type).get();
+ return (Class<?>)((WeakReference<?>) type).get();
}
return (Class<?>) type;
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ArrayIndexOutOfBoundsException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ArrayIndexOutOfBoundsException.java?view=diff&rev=491123&r1=491122&r2=491123
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ArrayIndexOutOfBoundsException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ArrayIndexOutOfBoundsException.java Fri Dec 29 14:36:58 2006
@@ -17,7 +17,6 @@
package java.lang;
-
import org.apache.harmony.luni.util.Msg;
/**
@@ -29,32 +28,32 @@
private static final long serialVersionUID = -5116101128118950844L;
/**
- * Constructs a new instance of this class with its walkback filled in.
- */
- public ArrayIndexOutOfBoundsException() {
- super();
- }
+ * Constructs a new instance of this class with its walkback filled in.
+ */
+ public ArrayIndexOutOfBoundsException() {
+ super();
+ }
- /**
- * Constructs a new instance of this class with its walkback and message
- * (which is based on the argument which is the index which failed) filled
- * in.
- *
- * @param index
- * int the offending index.
- */
- public ArrayIndexOutOfBoundsException(int index) {
- super(Msg.getString("K0052", index));
- }
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * (which is based on the argument which is the index which failed) filled
+ * in.
+ *
+ * @param index
+ * int the offending index.
+ */
+ public ArrayIndexOutOfBoundsException(int index) {
+ super(Msg.getString("K0052", index)); //$NON-NLS-1$
+ }
- /**
- * Constructs a new instance of this class with its walkback and message
- * filled in.
- *
- * @param detailMessage
- * String The detail message for the exception.
- */
- public ArrayIndexOutOfBoundsException(String detailMessage) {
- super(detailMessage);
- }
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ * @param detailMessage
+ * String The detail message for the exception.
+ */
+ public ArrayIndexOutOfBoundsException(String detailMessage) {
+ super(detailMessage);
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Boolean.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Boolean.java?view=diff&rev=491123&r1=491122&r2=491123
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Boolean.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Boolean.java Fri Dec 29 14:36:58 2006
@@ -20,92 +20,95 @@
import java.io.Serializable;
/**
- * <p>Boolean is the wrapper for the primitive type <code>boolean</code>.</p>
+ * <p>
+ * Boolean is the wrapper for the primitive type <code>boolean</code>.
+ * </p>
+ *
* @since 1.0
*/
public final class Boolean implements Serializable, Comparable<Boolean> {
- private static final long serialVersionUID = -3665804199014368530L;
+ private static final long serialVersionUID = -3665804199014368530L;
- /**
- * The boolean value of the receiver.
- */
- private final boolean value;
+ /**
+ * The boolean value of the receiver.
+ */
+ private final boolean value;
- /**
+ /**
* The java.lang.Class that represents this class.
*/
@SuppressWarnings("unchecked")
public static final Class<Boolean> TYPE = (Class<Boolean>) new boolean[0]
.getClass().getComponentType();
- // Note: This can't be set to "boolean.class", since *that* is
- // defined to be "java.lang.Boolean.TYPE";
+ // Note: This can't be set to "boolean.class", since *that* is
+ // defined to be "java.lang.Boolean.TYPE";
+
+ /**
+ * The instance of the receiver which represents truth.
+ */
+ public static final Boolean TRUE = new Boolean(true);
- /**
- * The instance of the receiver which represents truth.
- */
- public static final Boolean TRUE = new Boolean(true);
-
- /**
- * The instance of the receiver which represents falsehood.
- */
- public static final Boolean FALSE = new Boolean(false);
-
- /**
- * Constructs a new instance of this class given a string. If the string is
- * equal to "true" using a non-case sensitive comparison, the result will be
- * a Boolean representing true, otherwise it will be a Boolean representing
- * false.
- *
- * @param string
- * The name of the desired boolean.
- */
- public Boolean(String string) {
- this(parseBoolean(string));
- }
-
- /**
- * Constructs a new instance of this class given true or false.
- *
- * @param value
- * true or false.
- */
- public Boolean(boolean value) {
- this.value = value;
- }
-
- /**
- * Answers true if the receiver represents true and false if the receiver
- * represents false.
- *
- * @return true or false.
- */
- public boolean booleanValue() {
- return value;
- }
-
- /**
- * Compares the argument to the receiver, and answers true if they represent
- * the <em>same</em> object using a class specific comparison.
- * <p>
- * In this case, the argument must also be a Boolean, and the receiver and
- * argument must represent the same boolean value (i.e. both true or both
- * false).
- *
- * @param o
- * the object to compare with this object
- * @return <code>true</code> if the object is the same as this object
- * <code>false</code> if it is different from this object
- *
- * @see #hashCode
- */
- @Override
+ /**
+ * The instance of the receiver which represents falsehood.
+ */
+ public static final Boolean FALSE = new Boolean(false);
+
+ /**
+ * Constructs a new instance of this class given a string. If the string is
+ * equal to "true" using a non-case sensitive comparison, the result will be
+ * a Boolean representing true, otherwise it will be a Boolean representing
+ * false.
+ *
+ * @param string
+ * The name of the desired boolean.
+ */
+ public Boolean(String string) {
+ this(parseBoolean(string));
+ }
+
+ /**
+ * Constructs a new instance of this class given true or false.
+ *
+ * @param value
+ * true or false.
+ */
+ public Boolean(boolean value) {
+ this.value = value;
+ }
+
+ /**
+ * Answers true if the receiver represents true and false if the receiver
+ * represents false.
+ *
+ * @return true or false.
+ */
+ public boolean booleanValue() {
+ return value;
+ }
+
+ /**
+ * Compares the argument to the receiver, and answers true if they represent
+ * the <em>same</em> object using a class specific comparison.
+ * <p>
+ * In this case, the argument must also be a Boolean, and the receiver and
+ * argument must represent the same boolean value (i.e. both true or both
+ * false).
+ *
+ * @param o
+ * the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object
+ * <code>false</code> if it is different from this object
+ *
+ * @see #hashCode
+ */
+ @Override
public boolean equals(Object o) {
- return (o == this)
- || ((o instanceof Boolean) && (value == ((Boolean) o).value));
- }
-
+ return (o == this)
+ || ((o instanceof Boolean) && (value == ((Boolean) o).value));
+ }
+
/**
* <p>
* Compares this <code>Boolean</code> to another <code>Boolean</code>.
@@ -116,9 +119,10 @@
* passed is <code>true</code>, then a negative value is returned.
* </p>
*
- * @param that The instance to compare to.
- * @throws java.lang.NullPointerException if <code>that</code> is
- * <code>null</code>.
+ * @param that
+ * The instance to compare to.
+ * @throws java.lang.NullPointerException
+ * if <code>that</code> is <code>null</code>.
* @since 1.5
* @see java.lang.Comparable
*/
@@ -126,28 +130,28 @@
if (that == null) {
throw new NullPointerException();
}
-
+
if (this.value == that.value) {
return 0;
}
-
+
return this.value ? 1 : -1;
}
- /**
- * Answers an integer hash code for the receiver. Any two objects which
- * answer <code>true</code> when passed to <code>equals</code> must
- * answer the same value for this method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
- @Override
+ /**
+ * Answers an integer hash code for the receiver. Any two objects which
+ * answer <code>true</code> when passed to <code>equals</code> must
+ * answer the same value for this method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+ @Override
public int hashCode() {
- return value ? 1231 : 1237;
- }
-
+ return value ? 1231 : 1237;
+ }
+
/**
* Answers a string containing a concise, human-readable description of the
* receiver.
@@ -158,12 +162,13 @@
public String toString() {
return String.valueOf(value);
}
-
+
/**
* Answers true if the system property described by the argument equal to
* "true" using case insensitive comparison, and false otherwise.
*
- * @param string The name of the desired boolean.
+ * @param string
+ * The name of the desired boolean.
* @return The boolean value.
*/
public static boolean getBoolean(String string) {
@@ -172,7 +177,7 @@
}
return (parseBoolean(System.getProperty(string)));
}
-
+
/**
* <p>
* Parses the string as a <code>boolean</code>. If the string is not
@@ -180,49 +185,50 @@
* case, then <code>true</code> is returned, otherwise <code>false</code>.
* </p>
*
- * @param s The string to parse.
+ * @param s
+ * The string to parse.
* @return A boolean value.
* @since 1.5
*/
public static boolean parseBoolean(String s) {
- return "true".equalsIgnoreCase(s);
+ return "true".equalsIgnoreCase(s); //$NON-NLS-1$
}
- /**
- * Converts the specified boolean to its string representation. When the
- * boolean is true answer <code>"true"</code>, otherwise answer
- * <code>"false"</code>.
- *
- * @param value
- * the boolean
- * @return the boolean converted to a string
- */
- public static String toString(boolean value) {
- return String.valueOf(value);
- }
-
- /**
- * Answers a Boolean representing true if the argument is equal to "true"
- * using case insensitive comparison, and a Boolean representing false
- * otherwise.
- *
- * @param string
- * The name of the desired boolean.
- * @return the boolean value.
- */
- public static Boolean valueOf(String string) {
- return parseBoolean(string) ? Boolean.TRUE : Boolean.FALSE;
- }
-
- /**
- * Answers Boolean.TRUE if the argument is equal to "true" using case
- * insensitive comparison, and Boolean.FALSE representing false otherwise.
- *
- * @param b
- * the boolean value.
- * @return Boolean.TRUE or Boolean.FALSE Global true/false objects.
- */
- public static Boolean valueOf(boolean b) {
- return b ? Boolean.TRUE : Boolean.FALSE;
- }
+ /**
+ * Converts the specified boolean to its string representation. When the
+ * boolean is true answer <code>"true"</code>, otherwise answer
+ * <code>"false"</code>.
+ *
+ * @param value
+ * the boolean
+ * @return the boolean converted to a string
+ */
+ public static String toString(boolean value) {
+ return String.valueOf(value);
+ }
+
+ /**
+ * Answers a Boolean representing true if the argument is equal to "true"
+ * using case insensitive comparison, and a Boolean representing false
+ * otherwise.
+ *
+ * @param string
+ * The name of the desired boolean.
+ * @return the boolean value.
+ */
+ public static Boolean valueOf(String string) {
+ return parseBoolean(string) ? Boolean.TRUE : Boolean.FALSE;
+ }
+
+ /**
+ * Answers Boolean.TRUE if the argument is equal to "true" using case
+ * insensitive comparison, and Boolean.FALSE representing false otherwise.
+ *
+ * @param b
+ * the boolean value.
+ * @return Boolean.TRUE or Boolean.FALSE Global true/false objects.
+ */
+ public static Boolean valueOf(boolean b) {
+ return b ? Boolean.TRUE : Boolean.FALSE;
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ClassCastException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ClassCastException.java?view=diff&rev=491123&r1=491122&r2=491123
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ClassCastException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ClassCastException.java Fri Dec 29 14:36:58 2006
@@ -25,39 +25,39 @@
*
*/
public class ClassCastException extends RuntimeException {
- private static final long serialVersionUID = -9223365651070458532L;
+ private static final long serialVersionUID = -9223365651070458532L;
- /**
- * Constructs a new instance of this class with its walkback filled in.
- *
- */
- public ClassCastException() {
- super();
- }
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ *
+ */
+ public ClassCastException() {
+ super();
+ }
- /**
- * Constructs a new instance of this class with its walkback and message
- * filled in.
- *
- * @param detailMessage
- * String The detail message for the exception.
- */
- public ClassCastException(String detailMessage) {
- super(detailMessage);
- }
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ * @param detailMessage
+ * String The detail message for the exception.
+ */
+ public ClassCastException(String detailMessage) {
+ super(detailMessage);
+ }
- /**
- * Constructs a new instance of this class with its walkback and message
- * filled in.
- *
- * @param instanceClass
- * Class The class being cast from.
- *
- * @param castClass
- * Class The class being cast to.
- */
- ClassCastException(Class<?> instanceClass, Class<?> castClass) {
- super(Msg.getString("K0340", instanceClass.getName(), castClass
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ * @param instanceClass
+ * Class The class being cast from.
+ *
+ * @param castClass
+ * Class The class being cast to.
+ */
+ ClassCastException(Class<?> instanceClass, Class<?> castClass) {
+ super(Msg.getString("K0340", instanceClass.getName(), castClass //$NON-NLS-1$
.getName()));
}
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java?view=diff&rev=491123&r1=491122&r2=491123
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Double.java Fri Dec 29 14:36:58 2006
@@ -27,60 +27,65 @@
*/
public final class Double extends Number implements Comparable<Double> {
- private static final long serialVersionUID = -9172774392245257468L;
+ private static final long serialVersionUID = -9172774392245257468L;
- /**
- * The value which the receiver represents.
- */
- private final double value;
+ /**
+ * The value which the receiver represents.
+ */
+ private final double value;
/**
* <p>
- * Constant for the maximum <code>double</code> value, (2 - 2<sup>-52/sup>) * 2<sup>1023</sup>.
+ * Constant for the maximum <code>double</code> value, (2 - 2<sup>-52/sup>) *
+ * 2<sup>1023</sup>.
* </p>
*/
- public static final double MAX_VALUE = 1.79769313486231570e+308;
+ public static final double MAX_VALUE = 1.79769313486231570e+308;
/**
* <p>
* Constant for the minimum <code>double</code> value, 2<sup>-1074</sup>.
* </p>
*/
- public static final double MIN_VALUE = 5e-324;
+ public static final double MIN_VALUE = 5e-324;
- /* 4.94065645841246544e-324 gets rounded to 9.88131e-324 */
+ /* 4.94065645841246544e-324 gets rounded to 9.88131e-324 */
/**
* <p>
- * Constant for the Not-a-Number (NaN) value of the <code>double</code> type.
+ * Constant for the Not-a-Number (NaN) value of the <code>double</code>
+ * type.
* </p>
*/
- public static final double NaN = 0.0 / 0.0;
+ public static final double NaN = 0.0 / 0.0;
/**
* <p>
- * Constant for the Positive Infinity value of the <code>double</code> type.
+ * Constant for the Positive Infinity value of the <code>double</code>
+ * type.
* </p>
*/
- public static final double POSITIVE_INFINITY = 1.0 / 0.0;
+ public static final double POSITIVE_INFINITY = 1.0 / 0.0;
/**
* <p>
- * Constant for the Negative Infinity value of the <code>double</code> type.
+ * Constant for the Negative Infinity value of the <code>double</code>
+ * type.
* </p>
*/
- public static final double NEGATIVE_INFINITY = -1.0 / 0.0;
+ public static final double NEGATIVE_INFINITY = -1.0 / 0.0;
- /**
- * The java.lang.Class that represents this class.
+ /**
+ * The java.lang.Class that represents this class.
+ *
* @since 1.1
- */
+ */
@SuppressWarnings("unchecked")
public static final Class<Double> TYPE = (Class<Double>) new double[0]
.getClass().getComponentType();
- // Note: This can't be set to "double.class", since *that* is
- // defined to be "java.lang.Double.TYPE";
+ // Note: This can't be set to "double.class", since *that* is
+ // defined to be "java.lang.Double.TYPE";
/**
* <p>
@@ -91,321 +96,323 @@
* @since 1.5
*/
public static final int SIZE = 64;
-
- /**
- * Constructs a new instance of the receiver which represents the double
- * valued argument.
- *
- * @param value
- * the double to store in the new instance.
- */
- public Double(double value) {
- this.value = value;
- }
-
- /**
- * Constructs a new instance of this class given a string.
- *
- * @param string
- * a string representation of a double quantity.
- * @exception NumberFormatException
- * if the argument could not be parsed as a double quantity.
- */
- public Double(String string) throws NumberFormatException {
- this(parseDouble(string));
- }
-
- /**
- * Compares the receiver with the Double parameter. NaN is equal to NaN, and
- * is greater than other double values. 0d is greater than -0d.
- *
- * @param object
- * the Double to compare to the receiver
- *
- * @return Returns greater than zero when this.doubleValue() is greater than
- * object.doubleValue(), zero when this.doubleValue() equals
- * object.doubleValue(), and less than zero when this.doubleValue()
- * is less than object.doubleValue()
- *
- * @throws NullPointerException if <code>object</code> is <code>null</code>.
+
+ /**
+ * Constructs a new instance of the receiver which represents the double
+ * valued argument.
+ *
+ * @param value
+ * the double to store in the new instance.
+ */
+ public Double(double value) {
+ this.value = value;
+ }
+
+ /**
+ * Constructs a new instance of this class given a string.
+ *
+ * @param string
+ * a string representation of a double quantity.
+ * @exception NumberFormatException
+ * if the argument could not be parsed as a double quantity.
+ */
+ public Double(String string) throws NumberFormatException {
+ this(parseDouble(string));
+ }
+
+ /**
+ * Compares the receiver with the Double parameter. NaN is equal to NaN, and
+ * is greater than other double values. 0d is greater than -0d.
+ *
+ * @param object
+ * the Double to compare to the receiver
+ *
+ * @return Returns greater than zero when this.doubleValue() is greater than
+ * object.doubleValue(), zero when this.doubleValue() equals
+ * object.doubleValue(), and less than zero when this.doubleValue()
+ * is less than object.doubleValue()
+ *
+ * @throws NullPointerException
+ * if <code>object</code> is <code>null</code>.
* @since 1.2
- */
- public int compareTo(Double object) {
- long d1, d2;
- long NaNbits = Double.doubleToLongBits(Double.NaN);
- if ((d1 = Double.doubleToLongBits(value)) == NaNbits) {
- if (Double.doubleToLongBits(object.value) == NaNbits) {
- return 0;
- }
- return 1;
- }
- if ((d2 = Double.doubleToLongBits(object.value)) == NaNbits) {
- return -1;
- }
- if (value == object.value) {
- if (d1 == d2) {
- return 0;
- }
- // check for -0
- return d1 > d2 ? 1 : -1;
- }
- return value > object.value ? 1 : -1;
- }
-
- /**
- * Answers the byte value which the receiver represents
- *
- * @return byte the value of the receiver.
- */
- @Override
+ */
+ public int compareTo(Double object) {
+ long d1, d2;
+ long NaNbits = Double.doubleToLongBits(Double.NaN);
+ if ((d1 = Double.doubleToLongBits(value)) == NaNbits) {
+ if (Double.doubleToLongBits(object.value) == NaNbits) {
+ return 0;
+ }
+ return 1;
+ }
+ if ((d2 = Double.doubleToLongBits(object.value)) == NaNbits) {
+ return -1;
+ }
+ if (value == object.value) {
+ if (d1 == d2) {
+ return 0;
+ }
+ // check for -0
+ return d1 > d2 ? 1 : -1;
+ }
+ return value > object.value ? 1 : -1;
+ }
+
+ /**
+ * Answers the byte value which the receiver represents
+ *
+ * @return byte the value of the receiver.
+ */
+ @Override
public byte byteValue() {
- return (byte) value;
- }
+ return (byte) value;
+ }
- /**
- * Answers the binary representation of the argument, as a long.
- *
- * @param value
- * The double value to convert
- * @return the bits of the double.
- */
- public static native long doubleToLongBits(double value);
-
- /**
- * Answers the binary representation of the argument, as a long.
- *
- * @param value
- * The double value to convert
- * @return the bits of the double.
- */
- public static native long doubleToRawLongBits(double value);
-
- /**
- * Answers the receiver's value as a double.
- *
- * @return the receiver's value
- */
- @Override
+ /**
+ * Answers the binary representation of the argument, as a long.
+ *
+ * @param value
+ * The double value to convert
+ * @return the bits of the double.
+ */
+ public static native long doubleToLongBits(double value);
+
+ /**
+ * Answers the binary representation of the argument, as a long.
+ *
+ * @param value
+ * The double value to convert
+ * @return the bits of the double.
+ */
+ public static native long doubleToRawLongBits(double value);
+
+ /**
+ * Answers the receiver's value as a double.
+ *
+ * @return the receiver's value
+ */
+ @Override
public double doubleValue() {
- return value;
- }
+ return value;
+ }
- /**
- * Compares the argument to the receiver, and answers true if they represent
- * the <em>same</em> object using a class specific comparison. For
- * Doubles, the check verifies that the receiver's value's bit pattern
- * matches the bit pattern of the argument, which must also be a Double.
- *
- * @param object
- * the object to compare with this object
- * @return <code>true</code> if the object is the same as this object
- * <code>false</code> if it is different from this object
- * @see #hashCode
- */
- @Override
+ /**
+ * Compares the argument to the receiver, and answers true if they represent
+ * the <em>same</em> object using a class specific comparison. For
+ * Doubles, the check verifies that the receiver's value's bit pattern
+ * matches the bit pattern of the argument, which must also be a Double.
+ *
+ * @param object
+ * the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object
+ * <code>false</code> if it is different from this object
+ * @see #hashCode
+ */
+ @Override
public boolean equals(Object object) {
- return (object == this)
- || (object instanceof Double)
- && (doubleToLongBits(this.value) == doubleToLongBits(((Double) object).value));
- }
-
- /**
- * Answers the float value which the receiver represents
- *
- * @return float the value of the receiver.
- */
- @Override
+ return (object == this)
+ || (object instanceof Double)
+ && (doubleToLongBits(this.value) == doubleToLongBits(((Double) object).value));
+ }
+
+ /**
+ * Answers the float value which the receiver represents
+ *
+ * @return float the value of the receiver.
+ */
+ @Override
public float floatValue() {
- return (float) value;
- }
+ return (float) value;
+ }
- /**
- * Answers an integer hash code for the receiver. Any two objects which
- * answer <code>true</code> when passed to <code>equals</code> must
- * answer the same value for this method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
- @Override
+ /**
+ * Answers an integer hash code for the receiver. Any two objects which
+ * answer <code>true</code> when passed to <code>equals</code> must
+ * answer the same value for this method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+ @Override
public int hashCode() {
- long v = doubleToLongBits(value);
- return (int) (v ^ (v >>> 32));
- }
-
- /**
- * Answers the receiver's value as an integer.
- *
- * @return the receiver's value as an integer
- */
- @Override
+ long v = doubleToLongBits(value);
+ return (int) (v ^ (v >>> 32));
+ }
+
+ /**
+ * Answers the receiver's value as an integer.
+ *
+ * @return the receiver's value as an integer
+ */
+ @Override
public int intValue() {
- return (int) value;
- }
+ return (int) value;
+ }
- /**
- * Answers true if the receiver represents an infinite quantity, and false
- * otherwise.
- *
- * @return <code>true</code> if the argument is positive or negative
- * infinity <code>false</code> if it is not an infinite value
- */
- public boolean isInfinite() {
- return isInfinite(value);
- }
-
- /**
- * Answers true if the argument represents an infinite quantity, and false
- * otherwise.
- *
- * @param d
- * value to check for infinitness.
- * @return <code>true</code> if the argument is positive or negative
- * infinity <code>false</code> if it is not an infinite value
- */
- public static boolean isInfinite(double d) {
- return (d == POSITIVE_INFINITY) || (d == NEGATIVE_INFINITY);
- }
-
- /**
- * Answers true if the receiver does not represent a valid float quantity.
- *
- * @return <code>true</code> if the argument is Not A Number
- * <code>false</code> if it is a (potentially infinite) float
- * number
- */
- public boolean isNaN() {
- return isNaN(value);
- }
-
- /**
- * Answers true if the argument does not represent a valid double quantity.
- *
- * @param d
- * value to check for numberness.
- * @return <code>true</code> if the argument is Not A Number
- * <code>false</code> if it is a (potentially infinite) double
- * number
- */
- public static boolean isNaN(double d) {
- return d != d;
- }
-
- /**
- * Answers a double built from the binary representation given in the
- * argument.
- *
- * @param bits
- * the bits of the double
- * @return the double which matches the bits
- */
- public static native double longBitsToDouble(long bits);
-
- /**
- * Answers the long value which the receiver represents
- *
- * @return long the value of the receiver.
- */
- @Override
+ /**
+ * Answers true if the receiver represents an infinite quantity, and false
+ * otherwise.
+ *
+ * @return <code>true</code> if the argument is positive or negative
+ * infinity <code>false</code> if it is not an infinite value
+ */
+ public boolean isInfinite() {
+ return isInfinite(value);
+ }
+
+ /**
+ * Answers true if the argument represents an infinite quantity, and false
+ * otherwise.
+ *
+ * @param d
+ * value to check for infinitness.
+ * @return <code>true</code> if the argument is positive or negative
+ * infinity <code>false</code> if it is not an infinite value
+ */
+ public static boolean isInfinite(double d) {
+ return (d == POSITIVE_INFINITY) || (d == NEGATIVE_INFINITY);
+ }
+
+ /**
+ * Answers true if the receiver does not represent a valid float quantity.
+ *
+ * @return <code>true</code> if the argument is Not A Number
+ * <code>false</code> if it is a (potentially infinite) float
+ * number
+ */
+ public boolean isNaN() {
+ return isNaN(value);
+ }
+
+ /**
+ * Answers true if the argument does not represent a valid double quantity.
+ *
+ * @param d
+ * value to check for numberness.
+ * @return <code>true</code> if the argument is Not A Number
+ * <code>false</code> if it is a (potentially infinite) double
+ * number
+ */
+ public static boolean isNaN(double d) {
+ return d != d;
+ }
+
+ /**
+ * Answers a double built from the binary representation given in the
+ * argument.
+ *
+ * @param bits
+ * the bits of the double
+ * @return the double which matches the bits
+ */
+ public static native double longBitsToDouble(long bits);
+
+ /**
+ * Answers the long value which the receiver represents
+ *
+ * @return long the value of the receiver.
+ */
+ @Override
public long longValue() {
- return (long) value;
- }
+ return (long) value;
+ }
- /**
- * Answers the double which matches the passed in string.
- * NumberFormatException is thrown if the string does not represent a valid
- * double.
- *
- * @param string
- * the value to convert
- * @return a double which would print as the argument
- */
- public static double parseDouble(String string)
- throws NumberFormatException {
- return org.apache.harmony.luni.util.FloatingPointParser.parseDouble(string);
- }
-
- /**
- * Answers the short value which the receiver represents
- *
- * @return short the value of the receiver.
- */
- @Override
+ /**
+ * Answers the double which matches the passed in string.
+ * NumberFormatException is thrown if the string does not represent a valid
+ * double.
+ *
+ * @param string
+ * the value to convert
+ * @return a double which would print as the argument
+ */
+ public static double parseDouble(String string)
+ throws NumberFormatException {
+ return org.apache.harmony.luni.util.FloatingPointParser
+ .parseDouble(string);
+ }
+
+ /**
+ * Answers the short value which the receiver represents
+ *
+ * @return short the value of the receiver.
+ */
+ @Override
public short shortValue() {
- return (short) value;
- }
+ return (short) value;
+ }
- /**
- * Answers a string containing a concise, human-readable description of the
- * receiver.
- *
- * @return a printable representation for the receiver.
- */
- @Override
+ /**
+ * Answers a string containing a concise, human-readable description of the
+ * receiver.
+ *
+ * @return a printable representation for the receiver.
+ */
+ @Override
public String toString() {
- return Double.toString(value);
- }
+ return Double.toString(value);
+ }
+
+ /**
+ * Answers a string containing a printable representation of the argument.
+ *
+ * @param d
+ * the double to print
+ * @return a printable representation of the argument.
+ */
+ public static String toString(double d) {
+ return org.apache.harmony.luni.util.NumberConverter.convert(d);
+ }
+
+ /**
+ * Answers the double which matches the passed in string.
+ * NumberFormatException is thrown if the string does not represent a valid
+ * double.
+ *
+ * @param string
+ * the value to convert
+ * @return a double which would print as the argument
+ */
+ public static Double valueOf(String string) throws NumberFormatException {
+ return new Double(parseDouble(string));
+ }
+
+ /**
+ * Compares the two doubles. NaN is equal to NaN, and is greater than other
+ * double values. 0d is greater than -0d.
+ *
+ * @param double1
+ * the first value to compare
+ * @param double2
+ * the second value to compare
+ *
+ * @return Returns greater than zero when double1 is greater than double2,
+ * zero when double1 equals double2, and less than zero when double1
+ * is less than double2
+ */
+ public static int compare(double double1, double double2) {
+ long d1, d2;
+ long NaNbits = Double.doubleToLongBits(Double.NaN);
+ if ((d1 = Double.doubleToLongBits(double1)) == NaNbits) {
+ if (Double.doubleToLongBits(double2) == NaNbits) {
+ return 0;
+ }
+ return 1;
+ }
+ if ((d2 = Double.doubleToLongBits(double2)) == NaNbits) {
+ return -1;
+ }
+ if (double1 == double2) {
+ if (d1 == d2) {
+ return 0;
+ }
+ // check for -0
+ return d1 > d2 ? 1 : -1;
+ }
+ return double1 > double2 ? 1 : -1;
+ }
- /**
- * Answers a string containing a printable representation of the argument.
- *
- * @param d
- * the double to print
- * @return a printable representation of the argument.
- */
- public static String toString(double d) {
- return org.apache.harmony.luni.util.NumberConverter.convert(d);
- }
-
- /**
- * Answers the double which matches the passed in string.
- * NumberFormatException is thrown if the string does not represent a valid
- * double.
- *
- * @param string
- * the value to convert
- * @return a double which would print as the argument
- */
- public static Double valueOf(String string) throws NumberFormatException {
- return new Double(parseDouble(string));
- }
-
- /**
- * Compares the two doubles. NaN is equal to NaN, and is greater than other
- * double values. 0d is greater than -0d.
- *
- * @param double1
- * the first value to compare
- * @param double2
- * the second value to compare
- *
- * @return Returns greater than zero when double1 is greater than double2,
- * zero when double1 equals double2, and less than zero when double1
- * is less than double2
- */
- public static int compare(double double1, double double2) {
- long d1, d2;
- long NaNbits = Double.doubleToLongBits(Double.NaN);
- if ((d1 = Double.doubleToLongBits(double1)) == NaNbits) {
- if (Double.doubleToLongBits(double2) == NaNbits) {
- return 0;
- }
- return 1;
- }
- if ((d2 = Double.doubleToLongBits(double2)) == NaNbits) {
- return -1;
- }
- if (double1 == double2) {
- if (d1 == d2) {
- return 0;
- }
- // check for -0
- return d1 > d2 ? 1 : -1;
- }
- return double1 > double2 ? 1 : -1;
- }
-
/**
* <p>
* Returns a <code>Double</code> instance for the <code>double</code>
@@ -413,7 +420,8 @@
* method may maintain a cache of instances.
* </p>
*
- * @param d The double value.
+ * @param d
+ * The double value.
* @return A <code>Double</code> instance.
* @since 1.5
*/
@@ -423,10 +431,12 @@
/**
* <p>
- * Converts a <code>double</code> into a hexadecimal string representation.
+ * Converts a <code>double</code> into a hexadecimal string
+ * representation.
* </p>
*
- * @param d The <code>double</code> to convert.
+ * @param d
+ * The <code>double</code> to convert.
* @return The hexadecimal string representation of <code>f</code>.
* @since 1.5
*/
@@ -435,13 +445,13 @@
* Reference: http://en.wikipedia.org/wiki/IEEE_754
*/
if (d != d) {
- return "NaN";
+ return "NaN"; //$NON-NLS-1$
}
if (d == POSITIVE_INFINITY) {
- return "Infinity";
+ return "Infinity"; //$NON-NLS-1$
}
if (d == NEGATIVE_INFINITY) {
- return "-Infinity";
+ return "-Infinity"; //$NON-NLS-1$
}
long bitValue = doubleToLongBits(d);
@@ -453,18 +463,18 @@
long significand = bitValue & 0x000FFFFFFFFFFFFFL;
if (exponent == 0 && significand == 0) {
- return (negative ? "-0x0.0p0" : "0x0.0p0");
+ return (negative ? "-0x0.0p0" : "0x0.0p0"); //$NON-NLS-1$ //$NON-NLS-2$
}
StringBuilder hexString = new StringBuilder(10);
if (negative) {
- hexString.append("-0x");
+ hexString.append("-0x"); //$NON-NLS-1$
} else {
- hexString.append("0x");
+ hexString.append("0x"); //$NON-NLS-1$
}
if (exponent == 0) { // denormal (subnormal) value
- hexString.append("0.");
+ hexString.append("0."); //$NON-NLS-1$
// significand is 52-bits, so there can be 13 hex digits
int fractionDigits = 13;
// remove trailing hex zeros, so Integer.toHexString() won't print
@@ -484,9 +494,9 @@
}
}
hexString.append(hexSignificand);
- hexString.append("p-1022");
+ hexString.append("p-1022"); //$NON-NLS-1$
} else { // normal value
- hexString.append("1.");
+ hexString.append("1."); //$NON-NLS-1$
// significand is 52-bits, so there can be 13 hex digits
int fractionDigits = 13;
// remove trailing hex zeros, so Integer.toHexString() won't print
@@ -497,7 +507,7 @@
}
// this assumes Integer.toHexString() returns lowercase characters
String hexSignificand = Long.toHexString(significand);
-
+
// if there are digits left, then insert some '0' chars first
if (significand != 0 && fractionDigits > hexSignificand.length()) {
int digitDiff = fractionDigits - hexSignificand.length();
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Enum.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Enum.java?view=diff&rev=491123&r1=491122&r2=491123
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Enum.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Enum.java Fri Dec 29 14:36:58 2006
@@ -111,7 +111,7 @@
@Override
protected final Object clone() throws CloneNotSupportedException {
// KA004=Enums may not be cloned
- throw new CloneNotSupportedException(Msg.getString("KA004"));
+ throw new CloneNotSupportedException(Msg.getString("KA004")); //$NON-NLS-1$
}
/**
@@ -164,12 +164,12 @@
public static <T extends Enum<T>> T valueOf(Class<T> enumType, String name) {
if ((enumType == null) || (name == null)) {
// KA001=Argument must not be null
- throw new NullPointerException(Msg.getString("KA001"));
+ throw new NullPointerException(Msg.getString("KA001")); //$NON-NLS-1$
}
T[] values = getValues(enumType);
if (values == null) {
// KA005={0} is not an enum type
- throw new IllegalArgumentException(Msg.getString("KA005", enumType));
+ throw new IllegalArgumentException(Msg.getString("KA005", enumType)); //$NON-NLS-1$
}
for (T enumConst : values) {
if (enumConst.name.equals(name)) {
@@ -177,7 +177,7 @@
}
}
// KA006={0} is not a constant in the enum type {1}
- throw new IllegalArgumentException(Msg.getString("KA006", name,
+ throw new IllegalArgumentException(Msg.getString("KA006", name, //$NON-NLS-1$
enumType));
}
@@ -191,7 +191,7 @@
Method values = AccessController
.doPrivileged(new PrivilegedExceptionAction<Method>() {
public Method run() throws Exception {
- Method valsMethod = enumType.getMethod("values",
+ Method valsMethod = enumType.getMethod("values", //$NON-NLS-1$
(Class[]) null);
valsMethod.setAccessible(true);
return valsMethod;
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/EnumConstantNotPresentException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/EnumConstantNotPresentException.java?view=diff&rev=491123&r1=491122&r2=491123
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/EnumConstantNotPresentException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/EnumConstantNotPresentException.java Fri Dec 29 14:36:58 2006
@@ -16,6 +16,8 @@
package java.lang;
+import org.apache.harmony.luni.util.Msg;
+
/**
* <p>
* Indicates that an <code>enum</code> constant does not exist for a
@@ -45,8 +47,8 @@
@SuppressWarnings("unchecked")
public EnumConstantNotPresentException(Class<? extends Enum> enumType,
String constantName) {
- super("The enum constant " + enumType.getName() + "." + constantName
- + " is missing.");
+ // luni.03=The enum constant {0}.{1} is missing
+ super(Msg.getString("luni.03", enumType.getName(), constantName)); //$NON-NLS-1$
this.enumType = enumType;
this.constantName = constantName;
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java?view=diff&rev=491123&r1=491122&r2=491123
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Float.java Fri Dec 29 14:36:58 2006
@@ -17,7 +17,6 @@
package java.lang;
-
/**
* <p>
* Float is the wrapper for the primitive type <code>float</code>.
@@ -28,60 +27,65 @@
*/
public final class Float extends Number implements Comparable<Float> {
- private static final long serialVersionUID = -2671257302660747028L;
+ private static final long serialVersionUID = -2671257302660747028L;
- /**
- * The value which the receiver represents.
- */
- private final float value;
+ /**
+ * The value which the receiver represents.
+ */
+ private final float value;
- /**
+ /**
* <p>
- * Constant for the maximum <code>float</code> value, (2 - 2<sup>-23</sup>) * 2<sup>127</sup>.
+ * Constant for the maximum <code>float</code> value, (2 - 2<sup>-23</sup>) *
+ * 2<sup>127</sup>.
* </p>
- */
- public static final float MAX_VALUE = 3.40282346638528860e+38f;
+ */
+ public static final float MAX_VALUE = 3.40282346638528860e+38f;
/**
* <p>
* Constant for the minimum <code>float</code> value, 2<sup>-149</sup>.
* </p>
*/
- public static final float MIN_VALUE = 1.40129846432481707e-45f;
+ public static final float MIN_VALUE = 1.40129846432481707e-45f;
- /**
+ /**
* <p>
- * Constant for the Not-a-Number (NaN) value of the <code>float</code> type.
+ * Constant for the Not-a-Number (NaN) value of the <code>float</code>
+ * type.
* </p>
- */
- public static final float NaN = 0.0f / 0.0f;
+ */
+ public static final float NaN = 0.0f / 0.0f;
- /**
+ /**
* <p>
- * Constant for the Positive Infinity value of the <code>float</code> type.
+ * Constant for the Positive Infinity value of the <code>float</code>
+ * type.
* </p>
- */
- public static final float POSITIVE_INFINITY = 1.0f / 0.0f;
+ */
+ public static final float POSITIVE_INFINITY = 1.0f / 0.0f;
/**
* <p>
- * Constant for the Negative Infinity value of the <code>float</code> type.
+ * Constant for the Negative Infinity value of the <code>float</code>
+ * type.
* </p>
*/
- public static final float NEGATIVE_INFINITY = -1.0f / 0.0f;
+ public static final float NEGATIVE_INFINITY = -1.0f / 0.0f;
- /**
- * The java.lang.Class that represents this class.
+ /**
+ * The java.lang.Class that represents this class.
+ *
* @since 1.1
- */
+ */
@SuppressWarnings("unchecked")
public static final Class<Float> TYPE = (Class<Float>) new float[0]
.getClass().getComponentType();
- // Note: This can't be set to "float.class", since *that* is
- // defined to be "java.lang.Float.TYPE";
+ // Note: This can't be set to "float.class", since *that* is
+ // defined to be "java.lang.Float.TYPE";
- /**
+ /**
* <p>
* Constant for the number of bits to represent a <code>float</code> in
* two's compliment form.
@@ -91,332 +95,334 @@
*/
public static final int SIZE = 32;
- /**
- * Constructs a new instance of the receiver which represents the float
- * valued argument.
- *
- * @param value
- * the float to store in the new instance.
- */
- public Float(float value) {
- this.value = value;
- }
-
- /**
- * Constructs a new instance of the receiver which represents the double
- * valued argument.
- *
- * @param value
- * the double to store in the new instance.
- */
- public Float(double value) {
- this.value = (float) value;
- }
-
- /**
- * Constructs a new instance of this class given a string.
- *
- * @param string
- * a string representation of a float quantity.
- * @exception NumberFormatException
- * if the argument could not be parsed as a float quantity.
- */
- public Float(String string) throws NumberFormatException {
- this(parseFloat(string));
- }
-
- /**
- * Compares the receiver with the Float parameter. NaN is equal to NaN, and
- * is greater than other float values. 0f is greater than -0f.
- *
- * @param object
- * the Float to compare to the receiver
- *
- * @return Returns greater than zero when this.floatValue() is greater than
- * object.floatValue(), zero when this.floatValue() equals
- * object.floatValue(), and less than zero when this.floatValue() is
- * less than object.floatValue()
- * @throws NullPointerException if <code>object</code> is <code>null</code>.
+ /**
+ * Constructs a new instance of the receiver which represents the float
+ * valued argument.
+ *
+ * @param value
+ * the float to store in the new instance.
+ */
+ public Float(float value) {
+ this.value = value;
+ }
+
+ /**
+ * Constructs a new instance of the receiver which represents the double
+ * valued argument.
+ *
+ * @param value
+ * the double to store in the new instance.
+ */
+ public Float(double value) {
+ this.value = (float) value;
+ }
+
+ /**
+ * Constructs a new instance of this class given a string.
+ *
+ * @param string
+ * a string representation of a float quantity.
+ * @exception NumberFormatException
+ * if the argument could not be parsed as a float quantity.
+ */
+ public Float(String string) throws NumberFormatException {
+ this(parseFloat(string));
+ }
+
+ /**
+ * Compares the receiver with the Float parameter. NaN is equal to NaN, and
+ * is greater than other float values. 0f is greater than -0f.
+ *
+ * @param object
+ * the Float to compare to the receiver
+ *
+ * @return Returns greater than zero when this.floatValue() is greater than
+ * object.floatValue(), zero when this.floatValue() equals
+ * object.floatValue(), and less than zero when this.floatValue() is
+ * less than object.floatValue()
+ * @throws NullPointerException
+ * if <code>object</code> is <code>null</code>.
* @since 1.2
- */
- public int compareTo(Float object) {
- int f1, f2;
- int NaNbits = Float.floatToIntBits(Float.NaN);
- if ((f1 = Float.floatToIntBits(value)) == NaNbits) {
- if (Float.floatToIntBits(object.value) == NaNbits) {
- return 0;
- }
- return 1;
- }
- if ((f2 = Float.floatToIntBits(object.value)) == NaNbits) {
- return -1;
- }
- if (value == object.value) {
- if (f1 == f2) {
- return 0;
- }
- // check for -0
- return f1 > f2 ? 1 : -1;
- }
- return value > object.value ? 1 : -1;
- }
-
- /**
- * Answers the byte value which the receiver represents
- *
- * @return byte the value of the receiver.
- */
- @Override
+ */
+ public int compareTo(Float object) {
+ int f1, f2;
+ int NaNbits = Float.floatToIntBits(Float.NaN);
+ if ((f1 = Float.floatToIntBits(value)) == NaNbits) {
+ if (Float.floatToIntBits(object.value) == NaNbits) {
+ return 0;
+ }
+ return 1;
+ }
+ if ((f2 = Float.floatToIntBits(object.value)) == NaNbits) {
+ return -1;
+ }
+ if (value == object.value) {
+ if (f1 == f2) {
+ return 0;
+ }
+ // check for -0
+ return f1 > f2 ? 1 : -1;
+ }
+ return value > object.value ? 1 : -1;
+ }
+
+ /**
+ * Answers the byte value which the receiver represents
+ *
+ * @return byte the value of the receiver.
+ */
+ @Override
public byte byteValue() {
- return (byte) value;
- }
+ return (byte) value;
+ }
- /**
- * Answers the double value which the receiver represents
- *
- * @return double the value of the receiver.
- */
- @Override
+ /**
+ * Answers the double value which the receiver represents
+ *
+ * @return double the value of the receiver.
+ */
+ @Override
public double doubleValue() {
- return value;
- }
+ return value;
+ }
- /**
- * Compares the argument to the receiver, and answers true if they represent
- * the <em>same</em> object using a class specific comparison. For Floats,
- * the check verifies that the receiver's value's bit pattern matches the
- * bit pattern of the argument, which must also be a Float.
- *
- * @param object
- * the object to compare with this object
- * @return <code>true</code> if the object is the same as this object
- * <code>false</code> if it is different from this object
- * @see #hashCode
- */
- @Override
+ /**
+ * Compares the argument to the receiver, and answers true if they represent
+ * the <em>same</em> object using a class specific comparison. For Floats,
+ * the check verifies that the receiver's value's bit pattern matches the
+ * bit pattern of the argument, which must also be a Float.
+ *
+ * @param object
+ * the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object
+ * <code>false</code> if it is different from this object
+ * @see #hashCode
+ */
+ @Override
public boolean equals(Object object) {
- return (object == this)
- || (object instanceof Float)
- && (floatToIntBits(this.value) == floatToIntBits(((Float) object).value));
- }
-
- /**
- * Answers the binary representation of the argument, as an int.
- *
- * @param value
- * The float value to convert
- * @return the bits of the float.
- */
- public static native int floatToIntBits(float value);
-
- /**
- * Answers the binary representation of the argument, as an int.
- *
- * @param value
- * The float value to convert
- * @return the bits of the float.
- */
- public static native int floatToRawIntBits(float value);
-
- /**
- * Answers the receiver's value as a float.
- *
- * @return the receiver's value
- */
- @Override
+ return (object == this)
+ || (object instanceof Float)
+ && (floatToIntBits(this.value) == floatToIntBits(((Float) object).value));
+ }
+
+ /**
+ * Answers the binary representation of the argument, as an int.
+ *
+ * @param value
+ * The float value to convert
+ * @return the bits of the float.
+ */
+ public static native int floatToIntBits(float value);
+
+ /**
+ * Answers the binary representation of the argument, as an int.
+ *
+ * @param value
+ * The float value to convert
+ * @return the bits of the float.
+ */
+ public static native int floatToRawIntBits(float value);
+
+ /**
+ * Answers the receiver's value as a float.
+ *
+ * @return the receiver's value
+ */
+ @Override
public float floatValue() {
- return value;
- }
+ return value;
+ }
- /**
- * Answers an integer hash code for the receiver. Any two objects which
- * answer <code>true</code> when passed to <code>equals</code> must
- * answer the same value for this method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
- @Override
+ /**
+ * Answers an integer hash code for the receiver. Any two objects which
+ * answer <code>true</code> when passed to <code>equals</code> must
+ * answer the same value for this method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+ @Override
public int hashCode() {
- return floatToIntBits(value);
- }
+ return floatToIntBits(value);
+ }
+
+ /**
+ * Answers a float built from the binary representation given in the
+ * argument.
+ *
+ * @param bits
+ * the bits of the float
+ * @return the float which matches the bits
+ */
+ public static native float intBitsToFloat(int bits);
- /**
- * Answers a float built from the binary representation given in the
- * argument.
- *
- * @param bits
- * the bits of the float
- * @return the float which matches the bits
- */
- public static native float intBitsToFloat(int bits);
-
- /**
- * Answers the int value which the receiver represents
- *
- * @return int the value of the receiver.
- */
- @Override
+ /**
+ * Answers the int value which the receiver represents
+ *
+ * @return int the value of the receiver.
+ */
+ @Override
public int intValue() {
- return (int) value;
- }
+ return (int) value;
+ }
- /**
- * Answers true if the receiver represents an infinite quantity, and false
- * otherwise.
- *
- * @return <code>true</code> if the argument is positive or negative
- * infinity <code>false</code> if it is not an infinite value
- */
- public boolean isInfinite() {
- return isInfinite(value);
- }
-
- /**
- * Answers true if the argument represents an infinite quantity, and false
- * otherwise.
- *
- * @param f
- * value to check for infinitness.
- * @return <code>true</code> if the argument is positive or negative
- * infinity <code>false</code> if it is not an infinite value
- */
- public static boolean isInfinite(float f) {
- return (f == POSITIVE_INFINITY) || (f == NEGATIVE_INFINITY);
- }
-
- /**
- * Answers true if the receiver does not represent a valid float quantity.
- *
- * @return <code>true</code> if the argument is Not A Number
- * <code>false</code> if it is a (potentially infinite) float
- * number
- */
- public boolean isNaN() {
- return isNaN(value);
- }
-
- /**
- * Answers true if the argument does not represent a valid float quantity.
- *
- * @param f
- * value to check for numberness.
- * @return <code>true</code> if the argument is Not A Number
- * <code>false</code> if it is a (potentially infinite) float
- * number
- */
- public static boolean isNaN(float f) {
- return f != f;
- }
-
- /**
- * Answers the long value which the receiver represents
- *
- * @return long the value of the receiver.
- */
- @Override
+ /**
+ * Answers true if the receiver represents an infinite quantity, and false
+ * otherwise.
+ *
+ * @return <code>true</code> if the argument is positive or negative
+ * infinity <code>false</code> if it is not an infinite value
+ */
+ public boolean isInfinite() {
+ return isInfinite(value);
+ }
+
+ /**
+ * Answers true if the argument represents an infinite quantity, and false
+ * otherwise.
+ *
+ * @param f
+ * value to check for infinitness.
+ * @return <code>true</code> if the argument is positive or negative
+ * infinity <code>false</code> if it is not an infinite value
+ */
+ public static boolean isInfinite(float f) {
+ return (f == POSITIVE_INFINITY) || (f == NEGATIVE_INFINITY);
+ }
+
+ /**
+ * Answers true if the receiver does not represent a valid float quantity.
+ *
+ * @return <code>true</code> if the argument is Not A Number
+ * <code>false</code> if it is a (potentially infinite) float
+ * number
+ */
+ public boolean isNaN() {
+ return isNaN(value);
+ }
+
+ /**
+ * Answers true if the argument does not represent a valid float quantity.
+ *
+ * @param f
+ * value to check for numberness.
+ * @return <code>true</code> if the argument is Not A Number
+ * <code>false</code> if it is a (potentially infinite) float
+ * number
+ */
+ public static boolean isNaN(float f) {
+ return f != f;
+ }
+
+ /**
+ * Answers the long value which the receiver represents
+ *
+ * @return long the value of the receiver.
+ */
+ @Override
public long longValue() {
- return (long) value;
- }
+ return (long) value;
+ }
- /**
- * Answers the float which matches the passed in string.
- * NumberFormatException is thrown if the string does not represent a valid
- * float.
- *
- * @param string
- * the value to convert
- * @return a float which would print as the argument
+ /**
+ * Answers the float which matches the passed in string.
+ * NumberFormatException is thrown if the string does not represent a valid
+ * float.
+ *
+ * @param string
+ * the value to convert
+ * @return a float which would print as the argument
* @see #valueOf(String)
* @since 1.2
- */
- public static float parseFloat(String string) throws NumberFormatException {
- return org.apache.harmony.luni.util.FloatingPointParser.parseFloat(string);
- }
-
- /**
- * Answers the short value which the receiver represents
- *
- * @return short the value of the receiver.
+ */
+ public static float parseFloat(String string) throws NumberFormatException {
+ return org.apache.harmony.luni.util.FloatingPointParser
+ .parseFloat(string);
+ }
+
+ /**
+ * Answers the short value which the receiver represents
+ *
+ * @return short the value of the receiver.
* @since 1.1
- */
- @Override
+ */
+ @Override
public short shortValue() {
- return (short) value;
- }
+ return (short) value;
+ }
- /**
- * Answers a string containing a concise, human-readable description of the
- * receiver.
- *
- * @return a printable representation for the receiver.
- */
- @Override
+ /**
+ * Answers a string containing a concise, human-readable description of the
+ * receiver.
+ *
+ * @return a printable representation for the receiver.
+ */
+ @Override
public String toString() {
- return Float.toString(value);
- }
+ return Float.toString(value);
+ }
- /**
- * Answers a string containing a printable representation of the argument.
- *
- * @param f
- * the float to print
- * @return a printable representation of the argument.
- */
- public static String toString(float f) {
- return org.apache.harmony.luni.util.NumberConverter.convert(f);
- }
-
- /**
- * Answers the float which matches the passed in string.
- * NumberFormatException is thrown if the string does not represent a valid
- * float.
- *
- * @param string
- * the value to convert
- * @return a float which would print as the argument
- */
- public static Float valueOf(String string) throws NumberFormatException {
- return valueOf(parseFloat(string));
- }
-
- /**
- * Compares the two floats. NaN is equal to NaN, and is greater than other
- * float values. 0f is greater than -0f.
- *
- * @param float1
- * the first value to compare
- * @param float2
- * the second value to compare
- *
- * @return Returns greater than zero when float1 is greater than float2,
- * zero when float1 equals float2, and less than zero when float1 is
- * less than float2
+ /**
+ * Answers a string containing a printable representation of the argument.
+ *
+ * @param f
+ * the float to print
+ * @return a printable representation of the argument.
+ */
+ public static String toString(float f) {
+ return org.apache.harmony.luni.util.NumberConverter.convert(f);
+ }
+
+ /**
+ * Answers the float which matches the passed in string.
+ * NumberFormatException is thrown if the string does not represent a valid
+ * float.
+ *
+ * @param string
+ * the value to convert
+ * @return a float which would print as the argument
+ */
+ public static Float valueOf(String string) throws NumberFormatException {
+ return valueOf(parseFloat(string));
+ }
+
+ /**
+ * Compares the two floats. NaN is equal to NaN, and is greater than other
+ * float values. 0f is greater than -0f.
+ *
+ * @param float1
+ * the first value to compare
+ * @param float2
+ * the second value to compare
+ *
+ * @return Returns greater than zero when float1 is greater than float2,
+ * zero when float1 equals float2, and less than zero when float1 is
+ * less than float2
* @since 1.4
- */
- public static int compare(float float1, float float2) {
- int f1, f2;
- int NaNbits = Float.floatToIntBits(Float.NaN);
- if ((f1 = Float.floatToIntBits(float1)) == NaNbits) {
- if (Float.floatToIntBits(float2) == NaNbits) {
- return 0;
- }
- return 1;
- }
- if ((f2 = Float.floatToIntBits(float2)) == NaNbits) {
- return -1;
- }
- if (float1 == float2) {
- if (f1 == f2) {
- return 0;
- }
- // check for -0
- return f1 > f2 ? 1 : -1;
- }
- return float1 > float2 ? 1 : -1;
- }
-
+ */
+ public static int compare(float float1, float float2) {
+ int f1, f2;
+ int NaNbits = Float.floatToIntBits(Float.NaN);
+ if ((f1 = Float.floatToIntBits(float1)) == NaNbits) {
+ if (Float.floatToIntBits(float2) == NaNbits) {
+ return 0;
+ }
+ return 1;
+ }
+ if ((f2 = Float.floatToIntBits(float2)) == NaNbits) {
+ return -1;
+ }
+ if (float1 == float2) {
+ if (f1 == f2) {
+ return 0;
+ }
+ // check for -0
+ return f1 > f2 ? 1 : -1;
+ }
+ return float1 > float2 ? 1 : -1;
+ }
+
/**
* <p>
* Returns a <code>Float</code> instance for the <code>float</code>
@@ -424,20 +430,22 @@
* method may maintain a cache of instances.
* </p>
*
- * @param f The float value.
+ * @param f
+ * The float value.
* @return A <code>Float</code> instance.
* @since 1.5
*/
public static Float valueOf(float f) {
return new Float(f);
- }
-
+ }
+
/**
* <p>
* Converts a <code>float</code> into a hexadecimal string representation.
* </p>
*
- * @param f The <code>float</code> to convert.
+ * @param f
+ * The <code>float</code> to convert.
* @return The hexadecimal string representation of <code>f</code>.
* @since 1.5
*/
@@ -446,17 +454,17 @@
* Reference: http://en.wikipedia.org/wiki/IEEE_754
*/
if (f != f) {
- return "NaN";
+ return "NaN"; //$NON-NLS-1$
}
if (f == POSITIVE_INFINITY) {
- return "Infinity";
+ return "Infinity"; //$NON-NLS-1$
}
if (f == NEGATIVE_INFINITY) {
- return "-Infinity";
+ return "-Infinity"; //$NON-NLS-1$
}
int bitValue = floatToIntBits(f);
-
+
boolean negative = (bitValue & 0x80000000) != 0;
// mask exponent bits and shift down
int exponent = (bitValue & 0x7f800000) >>> 23;
@@ -465,18 +473,18 @@
int significand = (bitValue & 0x007FFFFF) << 1;
if (exponent == 0 && significand == 0) {
- return (negative ? "-0x0.0p0" : "0x0.0p0");
+ return (negative ? "-0x0.0p0" : "0x0.0p0"); //$NON-NLS-1$ //$NON-NLS-2$
}
StringBuilder hexString = new StringBuilder(10);
if (negative) {
- hexString.append("-0x");
+ hexString.append("-0x"); //$NON-NLS-1$
} else {
- hexString.append("0x");
+ hexString.append("0x"); //$NON-NLS-1$
}
if (exponent == 0) { // denormal (subnormal) value
- hexString.append("0.");
+ hexString.append("0."); //$NON-NLS-1$
// significand is 23-bits, so there can be 6 hex digits
int fractionDigits = 6;
// remove trailing hex zeros, so Integer.toHexString() won't print
@@ -496,9 +504,9 @@
}
}
hexString.append(hexSignificand);
- hexString.append("p-126");
+ hexString.append("p-126"); //$NON-NLS-1$
} else { // normal value
- hexString.append("1.");
+ hexString.append("1."); //$NON-NLS-1$
// significand is 23-bits, so there can be 6 hex digits
int fractionDigits = 6;
// remove trailing hex zeros, so Integer.toHexString() won't print