## visad
Class BaseUnit

    java.lang.Object
      visad.Unit
          visad.BaseUnit

All Implemented Interfaces:
  Serializable

public final class BaseUnit
extends Unit
implements Serializable

A class that represents the base units of a system of units.

See Also:
  Serialized Form

Field Summary
`(package private) DerivedUnit` `derivedUnit` Derived unit associated with base unit (for computational efficiency).
`(package private) boolean` `isDimless`

Fields inherited from class visad.Unit
`hashCode, hashCodeSet`

Method Summary
`static BaseUnit` `addBaseUnit(String quantityName, String unitName)` Create a new base unit from the name of a quantity and the name of a unit.
`static BaseUnit` `addBaseUnit(String quantityName, String unitName, String abbreviation)` Create a new base unit from from the name of a quantity, the name of a unit, and the unit's abbreviation.
`static BaseUnit` `addBaseUnit(String quantityName, String unitName, String abbreviation, boolean isDimless)` Create a new base unit from from the name of a quantity, the name of a unit, the unit's abbreviation, and whether or not the unit is dimensionless.
`Unit` `divide(Unit that)` Divide this unit by another unit.
`protected Unit` `divideInto(Unit that)` Divide this unit into another unit.
`boolean` `equals(Unit unit)` Indicates whether or not this instance equals a unit.
`String` `getDefinition()` Returns the definition of this unit.
`int` `hashCode()` Returns the hash code of this instance.
`boolean` `isConvertible(Unit unit)` Indicate whether this unit is convertible with another unit.
`boolean` `isDimensionless()` Indicates if this instance is dimensionless.
`static void` `main(String[] args)` Test this class.
`Unit` `multiply(Unit that)` Multiply this unit by another unit.
`Unit` `pow(double power)` Raise a unit to a power.
`Unit` `pow(int power)` Raise a base unit to a power.
`protected Unit` `protectedClone(String identifier)` Clones this unit, changing the identifier.
`String` `quantityName()` Return the name of the quantity associated with this unit.
`static BaseUnit` `quantityNameToUnit(String quantityName)` Find the base unit for the given quantity.
`Unit` `root(int root)` Returns the N-th root of this unit.
`(package private) double[]` `toThat(double[] values, BaseUnit that)` Convert values from this unit to a base unit.
`(package private) double[]` `toThat(double[] values, BaseUnit that, boolean copy)` Convert values from this unit to a base unit.
`double[]` `toThat(double[] values, Unit that)` Convert values from this unit to another unit.
`double[]` `toThat(double[] values, Unit that, boolean copy)` Convert values from this unit to another unit.
`(package private) float[]` `toThat(float[] values, BaseUnit that)` Convert values from this unit to a base unit.
`(package private) float[]` `toThat(float[] values, BaseUnit that, boolean copy)` Convert values from this unit to a base unit.
`float[]` `toThat(float[] values, Unit that)` Convert values from this unit to another unit.
`float[]` `toThat(float[] values, Unit that, boolean copy)` Convert values from this unit to another unit.
`(package private) double[]` `toThis(double[] values, BaseUnit that)` Convert values to this unit from another unit.
`(package private) double[]` `toThis(double[] values, BaseUnit that, boolean copy)` Convert values to this unit from a base unit.
`double[]` `toThis(double[] values, Unit that)` Convert values to this unit from another unit.
`double[]` `toThis(double[] values, Unit that, boolean copy)` Convert values to this unit from another unit.
`(package private) float[]` `toThis(float[] values, BaseUnit that)` Convert values to this unit from another unit.
`(package private) float[]` `toThis(float[] values, BaseUnit that, boolean copy)` Convert values to this unit from a base unit.
`float[]` `toThis(float[] values, Unit that)` Convert values to this unit from another unit.
`float[]` `toThis(float[] values, Unit that, boolean copy)` Convert values to this unit from another unit.
`String` `unitName()` Return the name of this unit.
`static BaseUnit` `unitNameToUnit(String unitName)` Find the base unit with the given name.
`String` `unitSymbol()` Return the symbol of this unit.

Methods inherited from class visad.Unit
`adjustCheckAndCache, canConvert, canConvertArray, clone, convertTuple, convertTuple, convertTuple, convertTuple, copyUnitsArray, equals, getAbsoluteUnit, getIdentifier, scale, scale, shift, sqrt, toString, toThat, toThis, transformUnits, transformUnits, transformUnits, transformUnits`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### derivedUnit

    final DerivedUnit derivedUnit

  Derived unit associated with base unit (for computational efficiency).

### isDimless

    final boolean isDimless

Method Detail

### isDimensionless

    public boolean isDimensionless()

  Indicates if this instance is dimensionless. A unit is dimensionless if it is a measure of a dimensionless quantity like angle or concentration. Examples of dimensionless base units include radian, degree, and steradian.

  Specified by:
    `isDimensionless` in class `Unit`
  Returns:
    True if an only if this unit is dimensionless.

### pow

    public Unit pow(int power)

  Raise a base unit to a power.

  Specified by:
    `pow` in class `Unit`
  Parameters:
    `power` - The power to raise this unit by.
  Returns:
    The unit resulting from raising this unit to `power`.

### root

    public Unit root(int root)
              throws IllegalArgumentException

  Returns the N-th root of this unit.

  Specified by:
    `root` in class `Unit`
  Parameters:
    `root` - The root to take (e.g. 2 means square root). May not be zero.
  Returns:
    The unit corresponding to the `root`-th root of this unit.
  Throws:
    `IllegalArgumentException` - The root value is zero or the resulting unit would have a non-integral unit dimension.

### pow

    public Unit pow(double power)
             throws IllegalArgumentException

  Raise a unit to a power.

  Specified by:
    `pow` in class `Unit`
  Parameters:
    `power` - The power to raise this unit by. The value must be integral or reciprocal integral.
  Returns:
    The unit resulting from raising this unit to `power`.
  Throws:
    `IllegalArgumentException` - `power` has a non-integral or non-reciprocal integral value.

### unitName

    public String unitName()

  Return the name of this unit.

  Returns:
    The name of this unit (e.g. "meter").

### unitSymbol

    public String unitSymbol()

  Return the symbol of this unit. This is the same as the identifier.

  Returns:
    The symbol of this unit (e.g. "m").

### quantityName

    public String quantityName()

  Return the name of the quantity associated with this unit.

  Returns:
    The name this units quantity (e.g. "Length").

### addBaseUnit

    public static BaseUnit addBaseUnit(String quantityName,
                                       String unitName)
                                throws UnitException

  Create a new base unit from the name of a quantity and the name of a unit. The unit abbreviation will be the same as the unit name. The unit will not be dimensionless.

  Parameters:
    `quantityName` - The name of the associated quantity (e.g. "Length").
    `unitName` - The name for the unit (e.g. "meter").
  Returns:
    A new base unit or the previously created one with the same names.
  Throws:
    `UnitException` - Name, abbreviation, or quantity name is `null` or attempt to redefine the base unit associated with `quantityName`.

### addBaseUnit

    public static BaseUnit addBaseUnit(String quantityName,
                                       String unitName,
                                       String abbreviation)
                                throws UnitException

  Create a new base unit from from the name of a quantity, the name of a unit, and the unit's abbreviation. The unit will not be dimensionless.

  Parameters:
    `quantityName` - The name of the associated quantity (e.g. "Length").
    `unitName` - The name for the unit (e.g. "meter").
    `abbreviation` - The abbreviation for the unit (e.g. "m").
  Returns:
    A new base unit or the previously created one with the same names.
  Throws:
    `UnitException` - Name, abbreviation, or quantity name is `null` or attempt to redefine the base unit associated with `quantityName`.

### addBaseUnit

    public static BaseUnit addBaseUnit(String quantityName,
                                       String unitName,
                                       String abbreviation,
                                       boolean isDimless)
                                throws UnitException

  Create a new base unit from from the name of a quantity, the name of a unit, the unit's abbreviation, and whether or not the unit is dimensionless.

  Parameters:
    `quantityName` - The name of the associated quantity (e.g. "Length").
    `unitName` - The name for the unit (e.g. "meter").
    `abbreviation` - The abbreviation for the unit (e.g. "m").
    `isDimless` - Whether or not the unit is dimensionless.
  Returns:
    A new base unit or the previously created one with the same names.
  Throws:
    `UnitException` - Name, abbreviation, or quantity name is `null` or attempt to redefine the base unit associated with `quantityName`.

### unitNameToUnit

    public static BaseUnit unitNameToUnit(String unitName)

  Find the base unit with the given name.

  Parameters:
    `unitName` - The name of the unit (e.g. "meter").
  Returns:
    The existing base unit with the given name or `null` if no such units exists.

### quantityNameToUnit

    public static BaseUnit quantityNameToUnit(String quantityName)

  Find the base unit for the given quantity.

  Parameters:
    `quantityName` - The name of the quantity (e.g. "Length").
  Returns:
    The existing base unit for the given quantity or `null` if no such unit exists.

### main

    public static void main(String[] args)
                     throws UnitException

  Test this class.

  Parameters:
    `args` - Arguments (ignored).
  Throws:
    `UnitException` - A problem occurred.

### toThis

    double[] toThis(double[] values,
                    BaseUnit that)
              throws UnitException

  Convert values to this unit from another unit.

  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThis

    float[] toThis(float[] values,
                   BaseUnit that)
             throws UnitException

  Convert values to this unit from another unit.

  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThis

    double[] toThis(double[] values,
                    BaseUnit that,
                    boolean copy)
              throws UnitException

  Convert values to this unit from a base unit.

  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
    `copy` - if false and `that` equals this, return `values`, else return a new array
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThis

    float[] toThis(float[] values,
                   BaseUnit that,
                   boolean copy)
             throws UnitException

  Convert values to this unit from a base unit.

  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
    `copy` - if false and `that` equals this, return `values`, else return a new array
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThis

    public double[] toThis(double[] values,
                           Unit that)
                    throws UnitException

  Convert values to this unit from another unit.

  Specified by:
    `toThis` in class `Unit`
  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThis

    public float[] toThis(float[] values,
                          Unit that)
                   throws UnitException

  Convert values to this unit from another unit.

  Specified by:
    `toThis` in class `Unit`
  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThis

    public double[] toThis(double[] values,
                           Unit that,
                           boolean copy)
                    throws UnitException

  Convert values to this unit from another unit.

  Overrides:
    `toThis` in class `Unit`
  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
    `copy` - if false and `that` equals this, return `values`, else return a new array
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThis

    public float[] toThis(float[] values,
                          Unit that,
                          boolean copy)
                   throws UnitException

  Convert values to this unit from another unit.

  Overrides:
    `toThis` in class `Unit`
  Parameters:
    `values` - The values to be converted.
    `that` - The unit of `values`.
    `copy` - if false and `that` equals this, return `values`, else return a new array
  Returns:
    The converted values in units of this unit.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    double[] toThat(double[] values,
                    BaseUnit that)
              throws UnitException

  Convert values from this unit to a base unit.

  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    float[] toThat(float[] values,
                   BaseUnit that)
             throws UnitException

  Convert values from this unit to a base unit.

  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    double[] toThat(double[] values,
                    BaseUnit that,
                    boolean copy)
              throws UnitException

  Convert values from this unit to a base unit.

  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
    `copy` - if false and `that` equals this, return `values`, else return a new array
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    float[] toThat(float[] values,
                   BaseUnit that,
                   boolean copy)
             throws UnitException

  Convert values from this unit to a base unit.

  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
    `copy` - if false and `that` equals this, return `values`, else return a new array
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    public double[] toThat(double[] values,
                           Unit that)
                    throws UnitException

  Convert values from this unit to another unit.

  Specified by:
    `toThat` in class `Unit`
  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    public float[] toThat(float[] values,
                          Unit that)
                   throws UnitException

  Convert values from this unit to another unit.

  Specified by:
    `toThat` in class `Unit`
  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    public double[] toThat(double[] values,
                           Unit that,
                           boolean copy)
                    throws UnitException

  Convert values from this unit to another unit.

  Overrides:
    `toThat` in class `Unit`
  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
    `copy` - if false and `that` equals this, return `values`, else return a new array
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### toThat

    public float[] toThat(float[] values,
                          Unit that,
                          boolean copy)
                   throws UnitException

  Convert values from this unit to another unit.

  Overrides:
    `toThat` in class `Unit`
  Parameters:
    `values` - The values to be converted in units of this unit.
    `that` - The unit to which to convert the values.
    `copy` - if false and `that` equals this, return `values`, else return a new array
  Returns:
    The converted values.
  Throws:
    `UnitException` - The units are not convertible.

### getDefinition

    public String getDefinition()

  Returns the definition of this unit. The definition of a BaseUnit is the same as the BaseUnit's identifier.

  Specified by:
    `getDefinition` in class `Unit`
  Returns:
    The definition of this unit. Won't be `null` but may be empty.

### protectedClone

    protected Unit protectedClone(String identifier)
                           throws UnitException

  Clones this unit, changing the identifier. This method always throws an exception because base units may not be cloned.

  Specified by:
    `protectedClone` in class `Unit`
  Parameters:
    `identifier` - The name or abbreviation for the cloned unit. May be `null` or empty.
  Returns:
    A unit equal this this instance but with the given identifier.
  Throws:
    `UnitException` - Base units may not be cloned. Always thrown.

### equals

    public boolean equals(Unit unit)

  Indicates whether or not this instance equals a unit.

  Specified by:
    `equals` in class `Unit`
  Parameters:
    `unit` - A unit.
  Returns:
    `true` if and only if this instance is equal to the unit.

### hashCode

    public int hashCode()

  Returns the hash code of this instance. `Object.hashCode()` should be overridden whenever `Object.equals(Object)` is.

  Specified by:
    `hashCode` in class `Unit`
  Returns:
    The hash code of this instance (includes the values).

### multiply

    public Unit multiply(Unit that)
                  throws UnitException

  Multiply this unit by another unit.

  Specified by:
    `multiply` in class `Unit`
  Parameters:
    `that` - The unit with which to multiply this unit.
  Returns:
    The product of the two units.
  Throws:
    `UnitException` - Meaningless operation.

### divide

    public Unit divide(Unit that)
                throws UnitException

  Divide this unit by another unit.

  Specified by:
    `divide` in class `Unit`
  Parameters:
    `that` - The unit to divide into this unit.
  Returns:
    The quotient of the two units.
  Throws:
    `UnitException` - Meaningless operation.

### divideInto

    protected Unit divideInto(Unit that)
                       throws UnitException

  Divide this unit into another unit.

  Specified by:
    `divideInto` in class `Unit`
  Parameters:
    `that` - The unit to divided this unit.
  Returns:
    The quotient of the two units.
  Throws:
    `UnitException` - Meaningless operation.

### isConvertible

    public boolean isConvertible(Unit unit)

  Indicate whether this unit is convertible with another unit. If one unit is convertible with another, then the `toThis(...)`/ and `toThat(...)` methods will not throw a UnitException. Unit A is convertible with unit B if and only if unit B is convertible with unit A; hence, calling-order is irrelevant.

  Specified by:
    `isConvertible` in class `Unit`
  Parameters:
    `unit` - The other unit.
  Returns:
    True if and only if this unit is convertible with the other unit.