JADE v6.1

javax.units
Class BaseUnit

java.lang.Object
  extended byjavax.units.Unit
      extended byjavax.units.BaseUnit
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Currency

public class BaseUnit
extends Unit

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");
     

Version:
4.0, January 30, 2003
Author:
Jean-Marie Dautelle
See Also:
Serialized Form

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

BaseUnit

protected BaseUnit(java.lang.String symbol)
Creates a base unit with the specified symbol.

Parameters:
symbol - the symbol of this base unit.
Method Detail

getInstance

public static BaseUnit getInstance(java.lang.String symbol)
Returns the base unit with the specified symbol. If the base unit does not already exist, then it is created.

Parameters:
symbol - the base unit symbol.
Returns:
the corresponding base unit.
Throws:
java.lang.IllegalArgumentException - if the specified symbol is currently associated to a different type of unit.

getSymbol

public final java.lang.String getSymbol()
Returns the symbol for this base unit.

Returns:
this base unit's symbol.

setDimension

public void setDimension(Unit dimension,
                         Converter toDimension)
Sets the dimension of this base unit (context-local). By default a base unit's dimension is itself. It is possible to set the dimension to any other unit. The only constraint being that distinct dimensional units should be independent from each other (e.g. if the dimensional unit for meter is "ns", then the dimensional unit for second should be "ns" as well). For example:
 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();
 }

Parameters:
dimension - the unit identifying the new dimension of this base unit.
toDimension - the converter to the specified dimensional unit.
See Also:
LocalContext

getSystemUnit

public Unit getSystemUnit()
Description copied from class: Unit
Returns the system unit for this unit. The system unit identifies the nature of the quantity being measured using this 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).

Specified by:
getSystemUnit in class Unit
Returns:
the system unit for this unit.
See Also:
Unit.isSystemUnit()

equals

public boolean equals(java.lang.Object that)
Description copied from class: Unit
Indicates if this unit is equal to the object specified. Units are unique and immutable, therefore users might want to use == to test for equality.

Specified by:
equals in class Unit
Parameters:
that - the object to compare for equality.
Returns:
true if this unit and the specified object are considered equal; false otherwise.

JADE v6.1

Copyright © 2004 Jean-Marie Dautelle.