Documentation of 'visad.data.units.UnitTable' Java class
UnitTable
visad.data.units

Class UnitTable

  • All Implemented Interfaces:
    java.io.Serializable, UnitsDB
    Direct Known Subclasses:
    DefaultUnitsDB


    public class UnitTable
    extends java.lang.Object
    implements UnitsDB, java.io.Serializable
    Provides support for a table of units.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      UnitTable(int numNames)
      Construct.
      UnitTable(int numNames, int numSymbols)
      Construct.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      Unit get(java.lang.String name)
      Get a unit.
      java.util.Enumeration getNameEnumeration()
      Get an enumeration of the unit names in the table.
      java.util.Enumeration getSymbolEnumeration()
      Get an enumeration of the unit symbols in the table.
      java.util.Enumeration getUnitEnumeration()
      Get an enumeration of the units in the table.
      void list()
      List the units in the database.
      static void main(java.lang.String[] args)
      Test this class.
      void put(BaseUnit unit)
      Adds a base unit.
      void putName(java.lang.String name, Unit unit)
      Adds a name and a unit to the name table.
      void putSymbol(java.lang.String symbol, Unit unit)
      Adds a symbol and a unit to the symbol table.
      java.lang.String toString()
      Return a string representation of this instance.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • UnitTable

        public UnitTable(int numNames)
                  throws java.lang.IllegalArgumentException
        Construct.
        Parameters:
        numNames - Anticipated minimum number of names in the database.
        Throws:
        java.lang.IllegalArgumentException - numNames < 0.
      • UnitTable

        public UnitTable(int numNames,
                         int numSymbols)
                  throws java.lang.IllegalArgumentException
        Construct.
        Parameters:
        numNames - Anticipated minimum number of names in the database.
        numSymbols - Anticipated minimum number of symbols in the database.
        Throws:
        java.lang.IllegalArgumentException - numNames < 0 || numSymbols < 0 .
    • Method Detail

      • get

        public Unit get(java.lang.String name)
        Get a unit.
        Specified by:
        get in interface UnitsDB
        Parameters:
        name - The exact name of the unit to be retrieved. If it is the empty string, then the dimensionless, unity unit will be returned.
        Returns:
        The unit of the matching entry or null if not found.
      • put

        public void put(BaseUnit unit)
                 throws java.lang.IllegalArgumentException
        Adds a base unit.
        Specified by:
        put in interface UnitsDB
        Parameters:
        unit - The base unit to be added.
        Throws:
        java.lang.IllegalArgumentException - The base unit argument is invalid.
      • putName

        public void putName(java.lang.String name,
                            Unit unit)
        Adds a name and a unit to the name table.
        Specified by:
        putName in interface UnitsDB
        Parameters:
        name - The name to be added.
        unit - The unit to be added.
        Throws:
        java.lang.IllegalArgumentException - Invalid argument.
      • putSymbol

        public void putSymbol(java.lang.String symbol,
                              Unit unit)
        Adds a symbol and a unit to the symbol table.
        Specified by:
        putSymbol in interface UnitsDB
        Parameters:
        symbol - The symbol to be added.
        unit - The unit to be added.
        Throws:
        java.lang.IllegalArgumentException - Invalid argument.
      • getNameEnumeration

        public java.util.Enumeration getNameEnumeration()
        Get an enumeration of the unit names in the table. The Object returned by nextElement() is a String.
        Specified by:
        getNameEnumeration in interface UnitsDB
      • getSymbolEnumeration

        public java.util.Enumeration getSymbolEnumeration()
        Get an enumeration of the unit symbols in the table. The Object returned by nextElement() is a String.
        Specified by:
        getSymbolEnumeration in interface UnitsDB
      • getUnitEnumeration

        public java.util.Enumeration getUnitEnumeration()
        Get an enumeration of the units in the table. The Object returned by nextElement() is a Unit.
        Specified by:
        getUnitEnumeration in interface UnitsDB
      • toString

        public java.lang.String toString()
        Return a string representation of this instance.
        Overrides:
        toString in class java.lang.Object
      • main

        public static void main(java.lang.String[] args)
                         throws java.lang.Exception
        Test this class.
        Throws:
        java.lang.Exception - A problem occurred.
      • list

        public void list()
        List the units in the database.
        Specified by:
        list in interface UnitsDB

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.