bayard 2004/06/23 21:20:46 Modified: lang/src/java/org/apache/commons/lang/mutable MutableByte.java MutableDouble.java MutableFloat.java MutableInteger.java MutableLong.java MutableNumber.java MutableShort.java Log: rolled back the Mutable change. It doubled the size of a mutable instance, and as it wrapped another object, doubled the work for garbage collection Revision Changes Path 1.3 +27 -3 jakarta-commons/lang/src/java/org/apache/commons/lang/mutable/MutableByte.java Index: MutableByte.java =================================================================== RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/mutable/MutableByte.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MutableByte.java 13 Jun 2004 06:18:49 -0000 1.2 +++ MutableByte.java 24 Jun 2004 04:20:46 -0000 1.3 @@ -24,20 +24,44 @@ public class MutableByte extends MutableNumber { /** + * Internal value. + */ + private byte value; + + /** * Instantiates with the specified value * @param value a value. */ public MutableByte(byte value) { super(); - setValue(new Byte(value)); + this.value = value; } public void setValue(byte value) { - setValue(new Byte(value)); + this.value = value; + } + + public long longValue() { + return this.value; + } + + public double doubleValue() { + return this.value; + } + + public int intValue() { + return this.value; + } + + /** + * @return a <code>Byte</code> + */ + public Object getValue() { + return new Byte(this.value); } /** - * @param value a <code>Number</code> + * @param value a <code>Byte</code> */ public void setValue(Object value) { setValue(((Number)value).byteValue()); 1.3 +24 -6 jakarta-commons/lang/src/java/org/apache/commons/lang/mutable/MutableDouble.java Index: MutableDouble.java =================================================================== RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/mutable/MutableDouble.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MutableDouble.java 13 Jun 2004 06:18:49 -0000 1.2 +++ MutableDouble.java 24 Jun 2004 04:20:46 -0000 1.3 @@ -16,7 +16,7 @@ package org.apache.commons.lang.mutable; /** - * A mutable <code>Double</code>. + * A mutable <code>Double</code> * * @since 2.1 * @version $Id$ @@ -24,21 +24,39 @@ public class MutableDouble extends MutableNumber { /** + * Internal value. + */ + private double value; + + /** * Instantiates with the specified value * @param value a value. */ public MutableDouble(double value) { super(); - setValue(new Double(value)); + this.value = value; } public void setValue(double value) { - setValue(new Double(value)); + this.value = value; + } + + public double doubleValue() { + return this.value; + } + + public long longValue() { + return (long)this.value; + } + + public int intValue() { + return (int)this.value; + } + + public Object getValue() { + return new Double(this.value); } - /** - * @param value a <code>Number</code> - */ public void setValue(Object value) { setValue(((Number)value).doubleValue()); } 1.3 +25 -6 jakarta-commons/lang/src/java/org/apache/commons/lang/mutable/MutableFloat.java Index: MutableFloat.java =================================================================== RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/mutable/MutableFloat.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MutableFloat.java 13 Jun 2004 06:18:49 -0000 1.2 +++ MutableFloat.java 24 Jun 2004 04:20:46 -0000 1.3 @@ -16,7 +16,7 @@ package org.apache.commons.lang.mutable; /** - * A mutable <code>Float</code>. + * A mutable <code>Float</code> * * @since 2.1 * @version $Id$ @@ -24,21 +24,40 @@ public class MutableFloat extends MutableNumber { /** + * Internal value. + */ + private float value; + + /** * Instantiates with the specified value + * * @param value a value. */ public MutableFloat(float value) { super(); - setValue(new Float(value)); + this.value = value; } public void setValue(float value) { - setValue(new Float(value)); + this.value = value; + } + + public double doubleValue() { + return this.value; + } + + public int intValue() { + return (int)this.value; + } + + public long longValue() { + return (long)this.value; + } + + public Object getValue() { + return new Float(this.value); } - /** - * @param value a <code>Number</code> - */ public void setValue(Object value) { setValue(((Number)value).floatValue()); } 1.3 +24 -5 jakarta-commons/lang/src/java/org/apache/commons/lang/mutable/MutableInteger.java Index: MutableInteger.java =================================================================== RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/mutable/MutableInteger.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MutableInteger.java 13 Jun 2004 06:18:49 -0000 1.2 +++ MutableInteger.java 24 Jun 2004 04:20:46 -0000 1.3 @@ -24,21 +24,40 @@ public class MutableInteger extends MutableNumber { /** + * Internal value. + */ + private int value; + + /** * Instantiates with the specified value + * * @param value a value. */ public MutableInteger(int value) { super(); - setValue(new Integer(value)); + this.value = value; } public void setValue(int value) { - setValue(new Integer(value)); + this.value = value; + } + + public double doubleValue() { + return this.value; + } + + public long longValue() { + return this.value; + } + + public int intValue() { + return this.value; + } + + public Object getValue() { + return new Float(this.value); } - /** - * @param value a <code>Number</code> - */ public void setValue(Object value) { setValue(((Number)value).intValue()); } 1.3 +24 -6 jakarta-commons/lang/src/java/org/apache/commons/lang/mutable/MutableLong.java Index: MutableLong.java =================================================================== RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/mutable/MutableLong.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MutableLong.java 13 Jun 2004 06:18:49 -0000 1.2 +++ MutableLong.java 24 Jun 2004 04:20:46 -0000 1.3 @@ -16,7 +16,7 @@ package org.apache.commons.lang.mutable; /** - * A mutable <code>Long</code>. + * A mutable <code>Long</code> * * @since 2.1 * @version $Id$ @@ -24,21 +24,39 @@ public class MutableLong extends MutableNumber { /** + * Internal value. + */ + private long value; + + /** * Instantiates with the specified value * @param value a value. */ public MutableLong(long value) { super(); - setValue(new Long(value)); + setValue(value); } public void setValue(long value) { - setValue(new Long(value)); + this.value = value; + } + + public double doubleValue() { + return this.value; + } + + public long longValue() { + return this.value; + } + + public int intValue() { + return (int)this.value; + } + + public Object getValue() { + return new Long(this.value); } - /** - * @param value a <code>Number</code> - */ public void setValue(Object value) { setValue(((Number)value).longValue()); } 1.3 +4 -35 jakarta-commons/lang/src/java/org/apache/commons/lang/mutable/MutableNumber.java Index: MutableNumber.java =================================================================== RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/mutable/MutableNumber.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MutableNumber.java 13 Jun 2004 06:18:49 -0000 1.2 +++ MutableNumber.java 24 Jun 2004 04:20:46 -0000 1.3 @@ -28,49 +28,18 @@ extends Number implements Comparable, Mutable, Serializable { - private Number value; - - public MutableNumber() { + MutableNumber() { super(); } - /** - * @param a <code>Number</code> - */ - protected void setValue(Number value) { - this.value = value; - } - // ---------------------------------------------------------------- // Number overrides // ---------------------------------------------------------------- public float floatValue() { - return this.value.floatValue(); + return (float)doubleValue(); } - public long longValue() { - return this.value.longValue(); - } - - public double doubleValue() { - return this.value.doubleValue(); - } - - public int intValue() { - return this.value.intValue(); - } - - // ---------------------------------------------------------------- - // Mutable overrides - // ---------------------------------------------------------------- - - /** - * @return a <code>Number</code> - */ - public Object getValue() { - return this.value; - } // ---------------------------------------------------------------- // Object overrides // ---------------------------------------------------------------- @@ -80,7 +49,7 @@ } public int hashCode() { - return this.value.hashCode(); + return super.hashCode(); } /** @@ -92,7 +61,7 @@ * @see #compareTo(Object) */ public boolean equals(Object obj) { - return this.value.equals(obj); + return super.equals(obj); } // ---------------------------------------------------------------- 1.3 +24 -6 jakarta-commons/lang/src/java/org/apache/commons/lang/mutable/MutableShort.java Index: MutableShort.java =================================================================== RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/mutable/MutableShort.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MutableShort.java 13 Jun 2004 06:18:49 -0000 1.2 +++ MutableShort.java 24 Jun 2004 04:20:46 -0000 1.3 @@ -16,7 +16,7 @@ package org.apache.commons.lang.mutable; /** - * A mutable <code>Short</code>. + * A mutable <code>Short</code> * * @since 2.1 * @version $Id$ @@ -24,21 +24,39 @@ public class MutableShort extends MutableNumber { /** + * Internal value. + */ + private short value; + + /** * Instantiates with the specified value * @param value a value. */ public MutableShort(short value) { super(); - setValue(new Short(value)); + this.value = value; } public void setValue(short value) { - setValue(new Short(value)); + this.value = value; + } + + public double doubleValue() { + return this.value; + } + + public int intValue() { + return this.value; + } + + public long longValue() { + return this.value; + } + + public Object getValue() { + return new Short(this.value); } - /** - * @param value a <code>Number</code> - */ public void setValue(Object value) { setValue(((Number)value).shortValue()); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]