com.rubecula.jquantity
Class UnitsAll

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.HashMap
          extended bycom.rubecula.jquantity.UnitsTable
              extended bycom.rubecula.jquantity.UnitsSI
                  extended bycom.rubecula.jquantity.UnitsAll
All Implemented Interfaces:
Cloneable, com.rubecula.util.Identifiable, Map, Serializable

public class UnitsAll
extends UnitsSI

Class to model all units.

Since:
V_0_0
Version:
$Revision: 1.11 $
Author:
Robin Hillyard
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.HashMap
 
Nested classes inherited from class java.util.AbstractMap
 
Field Summary
private  Vector _Tables
          The table of other units systems.
static UnitsAll $
           
 
Fields inherited from class com.rubecula.jquantity.UnitsTable
 
Fields inherited from class java.util.HashMap
 
Fields inherited from class java.util.AbstractMap
 
Constructor Summary
UnitsAll()
          Constructor to create a table of just the SI units.
 
Method Summary
 void add(UnitsTable table)
          Add a table to the UnitsAll instance.
 void audit(PrintStream stream)
           
 boolean contains(String name)
           
 Measurable findParallel(Measurable units, SystemFlag system)
          Method to find a parallel units in the same system as units, failing that a parallel units in the SI system, failing that return units.
 Measurable lookup(String name)
          Method to lookup a Measurable by key.
 Measurable lookup(String name, boolean matchOK)
          Method to lookup a Measurable by key (or by matching the name if matchOK is true) in this UnitsTable.
static void main(String[] args)
           
(package private)  Measurable put(Measurable unit)
          Method to insert a unit in this table.
 
Methods inherited from class com.rubecula.jquantity.UnitsTable
findParallel, getIdentifier, getName, getSystem, match, toString
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

$

public static final UnitsAll $

_Tables

private final Vector _Tables
The table of other units systems.

Constructor Detail

UnitsAll

public UnitsAll()
Constructor to create a table of just the SI units.

Method Detail

add

public void add(UnitsTable table)
Add a table to the UnitsAll instance.

Parameters:
table - a table of units such as a UnitsCGSor UnitsImperial.

contains

public boolean contains(String name)
Parameters:
name - the name of the Units to be found.
Returns:
true if the units was found.

put

Measurable put(Measurable unit)
Description copied from class: UnitsTable
Method to insert a unit in this table. Successful insertion depends on the value of the unit's identifier. If it's not null, then an insertion will be made provided that there is no existing entry of the same name (else an exception will be thrown). If it's null, then no insertion will be ever be made. However, if the unit itself matches an existing unit in the table, then that (matching unit) will be returned. Otherwise, the given unit will be returned.

Overrides:
put in class UnitsSI

main

public static void main(String[] args)

audit

public void audit(PrintStream stream)
Overrides:
audit in class UnitsTable

lookup

public Measurable lookup(String name,
                         boolean matchOK)
Description copied from class: UnitsTable
Method to lookup a Measurable by key (or by matching the name if matchOK is true) in this UnitsTable.

Overrides:
lookup in class UnitsTable
Parameters:
name - the key of the desired Measurable, or (if matchOK true) a string which will match one of the elements in the table (the first to be found).
matchOK - true if it is OK to accept a Measurable whose name matches when the name does not match a key.
Returns:
the (unique) Measurable whose key is name else any Measurable in the table which "matches" the name.

lookup

public Measurable lookup(String name)
Description copied from class: UnitsTable
Method to lookup a Measurable by key.

Overrides:
lookup in class UnitsTable
Parameters:
name - the key of the desired Measurable
Returns:
the (unique) Measurable whose key is name.

findParallel

public Measurable findParallel(Measurable units,
                               SystemFlag system)
Method to find a parallel units in the same system as units, failing that a parallel units in the SI system, failing that return units.

Overrides:
findParallel in class UnitsTable
Parameters:
units - the units to match with one in this table.
system - the system to which result must belong (or null if don't care).
Returns:
the first Measurable which was found in this table that is also parallel to units.
See Also:
UnitsTable.findParallel(com.rubecula.jquantity.Measurable)