|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbb.science.Unit
public class Unit
Models a unit of measurement. It has name, symbol, and description properties.
This class also offers static constants which are Unit instances that model the SI base units.
(Exception: we take the gram (instead of the kilogram) to be our base unit of mass,
as this works much better with the Prefix
class.)
This class is multithread safe: it is immutable (both its immediate state, as well as the deep state of its fields).
Nested Class Summary | |
---|---|
static class |
Unit.UnitTest
See the Overview page of the project's javadocs for a general description of this unit test class. |
Field Summary | |
---|---|
static Unit |
ampere
Models the SI base unit of electric current, the ampere. |
static Unit |
candela
Models the SI base unit of luminous intensity, the candela. |
protected String |
description
A description of the underlying quantity associated with the unit (e.g. length, mass, etc). |
static Unit |
gram
Models the SI unit of mass, the gram. |
static Unit |
kelvin
Models the SI base unit of thermodynamic temperature, the kelvin. |
static Unit |
meter
Models the SI base unit of length, the meter. |
static Unit |
mole
Models the SI base unit of amount of substance, the mole. |
protected String |
name
The full name of the unit (e.g. meter, gram). |
static Unit |
second
Models the SI base unit of time, the second. |
protected String |
symbol
The symbol for the unit (e.g. m, g, etc). |
Constructor Summary | |
---|---|
Unit(String name,
String symbol,
String description)
Constructs a new Unit instance for the supplied name, symbol, and description. |
Method Summary | |
---|---|
String |
getDescription()
Returns a description of the underlying quantity associated with the unit (e.g. length, mass, etc). |
String |
getName()
Returns the full name of the unit (e.g. meter, gram). |
static Unit[] |
getSiBaseUnits()
Returns an array of all the SI base units. |
String |
getSymbol()
Returns the symbol for the unit (e.g. m, g, etc). |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Unit meter
public static final Unit gram
public static final Unit second
public static final Unit ampere
public static final Unit kelvin
public static final Unit mole
public static final Unit candela
protected final String name
protected final String symbol
protected final String description
Constructor Detail |
---|
public Unit(String name, String symbol, String description) throws IllegalArgumentException
IllegalArgumentException
- if any arg is either null or all whitespaceMethod Detail |
---|
public static final Unit[] getSiBaseUnits()
public String getName()
public String getSymbol()
public String getDescription()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |