ucar.units
Class Factor

java.lang.Object
  extended by ucar.units.Factor
All Implemented Interfaces:
Serializable

public final class Factor
extends Object
implements Serializable

Provides support for a Base/exponent pair. Instances of this class are immutable.

Version:
$Id: Factor.java 64 2006-07-12 22:30:50Z edavis $
Author:
Steven R. Emmerson
See Also:
Serialized Form

Constructor Summary
Factor(Base base)
          Constructs from a Base.
Factor(Base base, int exponent)
          Constructs from a Base and an exponent.
Factor(Factor factor, int exponent)
          Constructs from a Factor and an exponent.
 
Method Summary
 boolean equals(Object object)
          Indicates if this Factor is semantically identical to another object.
 Base getBase()
          Returns the Base entity.
 int getExponent()
          Returns the exponent of the Base entity.
 String getID()
          Returns the identifier of the Base entity.
 int hashCode()
          Returns the hash code of this instance.
 boolean isDimensionless()
          Indicates if this factor is dimensionless.
 boolean isReciprocalOf(Factor that)
          Indicates if this Factor is the reciprocal of another Factor.
 Factor pow(int power)
          Raises this Factor to a power.
 String toString()
          Returns the string representation of this Factor.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Factor

public Factor(Base base)
Constructs from a Base. The exponent is set to unity.

Parameters:
base - The base entity.

Factor

public Factor(Factor factor,
              int exponent)
Constructs from a Factor and an exponent.

Parameters:
factor - The factor.
exponent - The exponent.

Factor

public Factor(Base base,
              int exponent)
Constructs from a Base and an exponent.

Parameters:
base - The base entity.
exponent - The exponent.
Method Detail

getBase

public Base getBase()
Returns the Base entity.

Returns:
The Base entity.

getID

public String getID()
Returns the identifier of the Base entity.

Returns:
The identifier of the Base entity (symbol or name).

getExponent

public int getExponent()
Returns the exponent of the Base entity.

Returns:
The exponent of the Base entity.

pow

public Factor pow(int power)
Raises this Factor to a power.

Parameters:
power - The power by which to raise this Factor.
Returns:
The Factor resulting from raising this Factor to the given power.

toString

public final String toString()
Returns the string representation of this Factor.

Overrides:
toString in class Object
Returns:
The string representation of this Factor.

equals

public boolean equals(Object object)
Indicates if this Factor is semantically identical to another object.

Overrides:
equals in class Object
Parameters:
object - The object.
Returns:
true if and only if this Factor is semantically identical to object< /code>.

hashCode

public int hashCode()
Returns the hash code of this instance.

Overrides:
hashCode in class Object
Returns:
The hash code of this instance.

isReciprocalOf

public boolean isReciprocalOf(Factor that)
Indicates if this Factor is the reciprocal of another Factor.

Parameters:
that - The other factor.
Returns:
true if and only if this Factor is the reciprocal of that.

isDimensionless

public boolean isDimensionless()
Indicates if this factor is dimensionless. A Factor is dimensionless if and only if the exponent is zero or the Base entity is dimensionless.

Returns:
true if and only if this Factor is dimensionless.


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.