Class ReusableInteger
java.lang.Object
java.lang.Number
org.web3d.vrml.scripting.ecmascript.builtin.ReusableInteger
- All Implemented Interfaces:
Serializable
An integer (non-floating point) extension of the
Number
abstract base class that allows the user to reset the internal value.
A typical issue with the Javascript runtime is that everywhere it uses object values rather than primitives. With a lot of method calling, that leads to a large amount of garbage being generated. As the runtime only really looks for Number instances rather than specific values, whenever we can, we use this class. That allows us to re use the instances rather than creating them and then throwing them away.
- Version:
- $Revision: 1.2 $
- Author:
- Justin Couch
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
Get the current value as a double.float
Get the current value as a float.int
intValue()
Get the current value as an integer.long
Get the current value as a long.void
setValue
(long val) Set the class to represent the new value.toString()
Convert to String.Methods inherited from class java.lang.Number
byteValue, shortValue
-
Constructor Details
-
ReusableInteger
public ReusableInteger(long val) Create a new value based on the given value- Parameters:
val
- The first value to use
-
-
Method Details
-
doubleValue
public double doubleValue()Get the current value as a double.- Specified by:
doubleValue
in classNumber
- Returns:
- The value as a double
-
floatValue
public float floatValue()Get the current value as a float.- Specified by:
floatValue
in classNumber
- Returns:
- The value as a float
-
intValue
-
longValue
-
toString
-
setValue
public void setValue(long val) Set the class to represent the new value.- Parameters:
val
- The new value to use
-