Update of /cvsroot/javaprofiler/jpiimpl/net/sourceforge/javaprofiler/jpiimpl/data
In directory usw-pr-cvs1:/tmp/cvs-serv17092/net/sourceforge/javaprofiler/jpiimpl/data
Added Files:
MutableInteger.java
Log Message:
class intended for speed-up purpose
--- NEW FILE: MutableInteger.java ---
/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License Version
* 1.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is available at http://www.sun.com/
*
* The Original Code is the Java Profiler module.
* The Initial Developers of the Original Code are Jan Stola, Pavel Vacha,
* Michal Pise, Petr Luner, Lukas Petru and Marek Przeczek.
* Portions created by Jan Stola are Copyright (C) 2000-2001. All Rights Reserved.
* Portions created by Pavel Vacha are Copyright (C) 2000-2001. All Rights Reserved.
* Portions created by Michal Pise are Copyright (C) 2000-2001. All Rights Reserved.
* Portions created by Petr Luner are Copyright (C) 2000-2001. All Rights Reserved.
* Portions created by Lukas Petru are Copyright (C) 2000-2001. All Rights Reserved.
* Portions created by Marek Przeczek are Copyright (C) 2000-2001. All Rights Reserved.
*
* Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner,
* Lukas Petru and Marek Przeczek.
*/
package net.sourceforge.javaprofiler.jpiimpl.data;
/** This class contains single field whose type is int. Compared to
* {@link java.lang.Integer java.lang.Integer}, this class allows changing of
* the value. When it has the same value as some Integer instance, this
* class' equals() method implementation returns true.
*
* @author Lukas Petru
*/
final class MutableInteger extends Number {
private int _value;
/** Constructs a newly allocated MutableInteger object initialized with
* value 0. */
public MutableInteger () {
}
/** Constructs a newly allocated MutableInteger object that represents the
* specified int value. */
public MutableInteger (int value) {
_value=value;
}
/** Constructs a newly allocated MutableInteger object that represents the
* int value indicated by the String parameter.
* @see java.lang.Integer#parseInt(java.lang.String) Integer.parseInt(java.lang.String)
*/
public MutableInteger (String s) {
_value=Integer.parseInt(s);
}
/** Set new value. */
public void set (int value) {
_value=value;
}
/** @return a hash code value for this object, equal to the primitive int
* value represented by this Integer object.
*/
public int hashCode() {
return _value;
}
/** Compares this object to the specified object. The result is true if and
* only if the argument is not null and is an Integer object or
* MutableIntegerthat object that contains the same int value as this
* object.
*/
public boolean equals(Object o) {
if (o instanceof Integer || o instanceof MutableInteger)
return _value == ((Number)o).intValue();
else
return false;
}
public int intValue () {
return _value;
}
public long longValue () {
return _value;
}
public float floatValue () {
return _value;
}
public double doubleValue () {
return _value;
}
public String toString () {
return Integer.toString(_value);
}
}
/*
* $Log: MutableInteger.java,v $
* Revision 1.1 2002/03/05 22:13:29 petrul
* class intended for speed-up purpose
*
*/
|