Package com.ibm.icu.util
Class Measure
- java.lang.Object
-
- com.ibm.icu.util.Measure
-
- Direct Known Subclasses:
CurrencyAmount,TimeUnitAmount
public class Measure extends Object
An amount of a specified unit, consisting of a Number and a Unit. For example, a length measure consists of a Number and a length unit, such as feet or meters.Measure objects are parsed and formatted by subclasses of MeasureFormat.
Measure objects are immutable. All subclasses must guarantee that. (However, subclassing is discouraged.)
- See Also:
Number,MeasureUnit,MeasureFormat
-
-
Constructor Summary
Constructors Constructor Description Measure(Number number, MeasureUnit unit)Constructs a new object given a number and a unit.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)Returns true if the given object is equal to this object.NumbergetNumber()Returns the numeric value of this object.MeasureUnitgetUnit()Returns the unit of this object.inthashCode()Returns a hashcode for this object.StringtoString()Returns a string representation of this object.
-
-
-
Constructor Detail
-
Measure
public Measure(Number number, MeasureUnit unit)
Constructs a new object given a number and a unit.- Parameters:
number- the numberunit- the unit
-
-
Method Detail
-
equals
public boolean equals(Object obj)
Returns true if the given object is equal to this object.- Overrides:
equalsin classObject- Parameters:
obj- the object to compare this instance with.- Returns:
- true if this object is equal to the given object
- See Also:
Object.hashCode()
-
hashCode
public int hashCode()
Returns a hashcode for this object.- Overrides:
hashCodein classObject- Returns:
- a 32-bit hash
- See Also:
Object.equals(java.lang.Object)
-
toString
public String toString()
Returns a string representation of this object.
-
getNumber
public Number getNumber()
Returns the numeric value of this object.- Returns:
- this object's Number
-
getUnit
public MeasureUnit getUnit()
Returns the unit of this object.- Returns:
- this object's Unit
-
-