|
JADE v6.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.units.Unit
javax.units.BaseUnit
This class represents the building blocks on top of which all others units are created.
By default, base units are mutually independent. Although, in specialized
context (e.g. relativistic context), conversions between base units
is possible (Ref. setDimension(javax.units.Unit, javax.units.Converter)
).
Examples of base units:
METER = BaseUnit.getInstance("m");
KILOGRAM = BaseUnit.getInstance("kg");
SECOND = BaseUnit.getInstance("s");
AMPERE = BaseUnit.getInstance("A");
Field Summary |
Fields inherited from class javax.units.Unit |
ONE |
Constructor Summary | |
protected |
BaseUnit(java.lang.String symbol)
Creates a base unit with the specified symbol. |
Method Summary | |
boolean |
equals(java.lang.Object that)
Indicates if this unit is equal to the object specified. |
static BaseUnit |
getInstance(java.lang.String symbol)
Returns the base unit with the specified symbol. |
java.lang.String |
getSymbol()
Returns the symbol for this base unit. |
Unit |
getSystemUnit()
Returns the system unit for this unit. |
void |
setDimension(Unit dimension,
Converter toDimension)
Sets the dimension of this base unit (context-local). |
Methods inherited from class javax.units.Unit |
add, alternate, appendTo, divide, getConverterTo, getDimension, getInstance, getInstances, hashCode, isCompatible, isSystemUnit, multiply, multiply, pow, readResolve, root, searchSymbol, toString, valueOf |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
protected BaseUnit(java.lang.String symbol)
symbol
- the symbol of this base unit.Method Detail |
public static BaseUnit getInstance(java.lang.String symbol)
symbol
- the base unit symbol.
java.lang.IllegalArgumentException
- if the specified symbol is currently
associated to a different type of unit.public final java.lang.String getSymbol()
public void setDimension(Unit dimension, Converter toDimension)
LocalContext.enter(); // Ensures that setting is local to current thread. try { SI.METER.setDimension(SI.NANO(SI.SECOND), new MultiplyConverter(1e9 / c)); SI.SECOND.setDimension(SI.NANO(SI.SECOND), new MultiplyConverter(1e9)); // In this high-energy context, length and time are compatible, // they have the same "ns" dimensional unit. } finally { LocalContext.exit(); }
dimension
- the unit identifying the new dimension of this
base unit.toDimension
- the converter to the specified dimensional unit.LocalContext
public Unit getSystemUnit()
Unit
Note: Having the same system units is not sufficient to ensure that a converter exists between the two units (e.g. °C/m and K/m).
getSystemUnit
in class Unit
Unit.isSystemUnit()
public boolean equals(java.lang.Object that)
Unit
==
to test for equality.
equals
in class Unit
that
- the object to compare for equality.
true
if this unit and the specified object are
considered equal; false
otherwise.
|
JADE v6.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |