Java Units API
Build 2004-02-06

javax.units
Class ProductUnit

Object
  extended byUnit
      extended byDerivedUnit
          extended byProductUnit
All Implemented Interfaces:
Serializable

public final class ProductUnit
extends DerivedUnit

This class represents a product unit. Product units are formed by the product of rational powers of existing units.

This class maintains the canonical form of this product (simplest form after factorization). For example: METER.pow(2).divide(METER) returns METER.

See Also:
Unit.multiply(Unit), Unit.divide(Unit), Unit.pow(int), Unit.root(int), Serialized Form

Nested Class Summary
static class ProductUnit.Element
          Inner product element represents a rational power of a single unit.
 
Field Summary
 
Fields inherited from class Unit
ONE
 
Method Summary
 boolean equals(Object that)
          Indicates if this unit is equal to the object specified.
 ProductUnit.Element get(int index)
          Returns the product element at the specified position.
 Unit getSystemUnit()
          Returns the system unit for this unit.
 int size()
          Returns the number of units in this product.
 
Methods inherited from class Unit
add, alternate, appendTo, divide, getConverterTo, getDimension, getInstance, getInstances, hashCode, isCompatible, isSystemUnit, multiply, multiply, pow, readResolve, root, searchSymbol, toString, valueOf
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

size

public int size()
Returns the number of units in this product.

Returns:
the number of units being multiplied.

get

public ProductUnit.Element get(int index)
Returns the product element at the specified position.

Parameters:
index - the index of the element to return.
Returns:
the element at the specified position.
Throws:
IndexOutOfBoundsException - if index is out of range (index < 0 || index >= size()).

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(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.

Java Units API
Build 2004-02-06

Symbols, terms and definitions
JSR-108 project