Class pmr.molecule.Unit
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class pmr.molecule.Unit

java.lang.Object
   |
   +----pmr.molecule.Unit

public class Unit
extends Object

Constructor Index

 o Unit(String, String, UnitDimension)
this constructor should be used for SI units only
 o Unit(String, String, UnitDimension, double, double)
make unit including conversion factors

to get to SI: siVal = (val - addToSI) * multiplyToSI;

to get from SI: val = siVal / multiplyToSI + addToSI;

This constructor should be used for NON SI units

Method Index

 o addSynonym(String)
add a synonym (might be an abbreviation) for a Unit.
 o convertFromOtherUnit(double, Unit)
 o convertFromSI(double)
 o convertFromTo(double, String, String)
 o convertToSI(double)
 o getName()
 o getNames(String)
get the name of all the units of a given type (e.g.
 o getSIUnit(String)
get the SI unit for a given type
 o getType()
 o getUnit(String)
gets a unit by name (e.g.
 o getUnitDimension()
 o getUnits()
get an array of all the Units
 o main(String[])
 o toString()

Constructors

 o Unit
  public Unit(String nam,
              String typ,
              UnitDimension d) throws DuplicateUnitException
this constructor should be used for SI units only
Throws: DuplicateUnitException
This Unit has already been defined
 o Unit
  public Unit(String nam,
              String typ,
              UnitDimension d,
              double mult,
              double add) throws DuplicateUnitException
make unit including conversion factors

to get to SI: siVal = (val - addToSI) * multiplyToSI;

to get from SI: val = siVal / multiplyToSI + addToSI;

This constructor should be used for NON SI units

Throws: DuplicateUnitException
This Unit has already been defined

Methods

 o addSynonym
  public void addSynonym(String s) throws DuplicateUnitException
add a synonym (might be an abbreviation) for a Unit. Name MUST be unique through the whole unit space. Duplicate throws an exception
Throws: DuplicateUnitException
This Unit has already been defined
 o getUnits
  public static Unit[] getUnits()
get an array of all the Units
 o getUnit
  public static Unit getUnit(String name)
gets a unit by name (e.g. "Celsius");
 o getName
  public String getName()
 o getType
  public String getType()
 o getUnitDimension
  public UnitDimension getUnitDimension()
 o getNames
  public static StringList getNames(String type)
get the name of all the units of a given type (e.g. energy)
 o getSIUnit
  public static Unit getSIUnit(String type)
get the SI unit for a given type
 o toString
  public String toString()
Overrides:
toString in class Object
 o convertToSI
  public double convertToSI(double val)
 o convertFromSI
  public double convertFromSI(double val)
 o convertFromOtherUnit
  public double convertFromOtherUnit(double val,
                                     Unit otherUnit) throws IncompatibleUnitException
 o convertFromTo
  public static double convertFromTo(double val,
                                     String fromUnit,
                                     String toUnit) throws IncompatibleUnitException
 o main
  public static void main(String args[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index