Package ucar.units
Class Prefix
- java.lang.Object
-
- ucar.units.Prefix
-
- All Implemented Interfaces:
Comparable<Object>
- Direct Known Subclasses:
PrefixName
,PrefixSymbol
@Immutable public abstract class Prefix extends Object implements Comparable<Object>
Provides support for unit prefixes (e.g. "centi", "c"). Instances of this class are immutable.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract int
compareTo(Object obj)
Compares this prefix to another.abstract int
compareTo(String string)
Compares this prefix to a string.String
getID()
Gets the prefix identifier.double
getValue()
Gets the prefix value.int
length()
Return the length of the prefix identifier.String
toString()
Returns the string representation of this prefix.
-
-
-
Constructor Detail
-
Prefix
protected Prefix(String id, double value)
Constructs from an identifier and a value.- Parameters:
id
- The prefix identifier (e.g. "milli" or "m").value
- The prefix value (e.g. 1e-3).
-
-
Method Detail
-
getID
public final String getID()
Gets the prefix identifier.- Returns:
- The prefix identifier.
-
toString
public final String toString()
Returns the string representation of this prefix.
-
getValue
public final double getValue()
Gets the prefix value.- Returns:
- The prefix value.
-
compareTo
public abstract int compareTo(Object obj)
Compares this prefix to another.- Specified by:
compareTo
in interfaceComparable<Object>
- Parameters:
obj
- The other prefix.- Returns:
- A negative value, zero, or a positive value depending on whether
this prefix is less than equal to, or greater than
obj
.
-
compareTo
public abstract int compareTo(String string)
Compares this prefix to a string.- Parameters:
string
- The string.- Returns:
- A negative value, zero, or a positive value depending on whether this prefix is less than equal to, or greater than the string.
-
length
public final int length()
Return the length of the prefix identifier.- Returns:
- The length of the prefix identifier.
-
-