Jeospace API

org.jeospace.measure
Class Time

java.lang.Object
  extended byorg.jeospace.measure.Time
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable

public class Time
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable

An object that represents a unit of time.

For reference see: http://ts.nist.gov/ts/htdocs/230/235/h4402/appenc.pdf

Version:
$Revision: 1.1.1.1 $
Author:
Rex Melton
See Also:
Mult, TimeUnit

Field Summary
protected  double magnitude
          The magnitude
protected  Mult multiplier
          The multiplier
protected  TimeUnit units
          The units
 
Constructor Summary
Time()
          Construct a Time object initialized to the default value (1 second).
Time(double magnitude, Mult multiplier, TimeUnit units)
          Construct a Time object.
Time(double magnitude, TimeUnit units)
          Construct a Time object.
Time(Time time)
          Construct a Time object.
 
Method Summary
 void add(Time time)
          Add to this object the argument Time object.
 void clear()
          Set the value of this Time object to 0 seconds.
 java.lang.Object clone()
          Return a copy of this Time object.
 int compareTo(java.lang.Object obj)
          Compare this object with the argument for order.
 int compareTo(Time that)
          Compare this object with the argument for order.
 boolean equals(java.lang.Object obj)
          Compare two Times for equality.
 double getMagnitude()
          Return the value of the magnitude of this Time object.
 double getMagnitude(Mult inMultiplier, TimeUnit inUnits)
          Return the double value of the magnitude of this Time object in the specified multiplier and units.
 double getMagnitude(TimeUnit inUnits)
          Return the double value of the magnitude of this Time object in the specified units.
 Mult getMultiplier()
          Return the Mult component of this Time object.
 TimeUnit getUnits()
          Return the TimeUnit component of this Time object.
 int hashcode()
          Return the hash code
 void set(double magnitude, Mult inMultiplier, TimeUnit inUnits)
          Set this Time object to the specified value.
 void set(double magnitude, TimeUnit units)
          Set this Time object to the specified value.
 void set(Time time)
          Set this Time object to the specified value.
 void setMagnitude(double value)
          Set the value of the magnitude of this Time object.
 void subtract(Time time)
          Subtract from this object the argument Time object.
 java.lang.String toString()
          Return a String representation of this Time object.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

magnitude

protected double magnitude
The magnitude


multiplier

protected Mult multiplier
The multiplier


units

protected TimeUnit units
The units

Constructor Detail

Time

public Time()
Construct a Time object initialized to the default value (1 second).


Time

public Time(double magnitude,
            TimeUnit units)
Construct a Time object.

Parameters:
magnitude - the magnitude value.
units - the units identifier.

Time

public Time(double magnitude,
            Mult multiplier,
            TimeUnit units)
Construct a Time object.

Parameters:
magnitude - the magnitude value.
multiplier - the multiplier identifier.
units - the units identifier.

Time

public Time(Time time)
Construct a Time object.

Parameters:
time - the Time object to duplicate.
Method Detail

set

public void set(Time time)
Set this Time object to the specified value.

Parameters:
time - the Time object to duplicate

set

public void set(double magnitude,
                TimeUnit units)
Set this Time object to the specified value.

Parameters:
magnitude - the magnitude value.
units - the units identifier.

set

public void set(double magnitude,
                Mult inMultiplier,
                TimeUnit inUnits)
Set this Time object to the specified value.

Parameters:
magnitude - the magnitude value.
inMultiplier - the multiplier identifier.
inUnits - the units identifier.

add

public void add(Time time)
Add to this object the argument Time object.

Parameters:
time - a Time object.

subtract

public void subtract(Time time)
Subtract from this object the argument Time object.

Parameters:
time - a Time object.

setMagnitude

public void setMagnitude(double value)
Set the value of the magnitude of this Time object.


getMagnitude

public double getMagnitude()
Return the value of the magnitude of this Time object.

Returns:
the double value of the magnitude

getMagnitude

public double getMagnitude(TimeUnit inUnits)
Return the double value of the magnitude of this Time object in the specified units.

Parameters:
inUnits - the units identifier.
Returns:
the double value of the magnitude

getMagnitude

public double getMagnitude(Mult inMultiplier,
                           TimeUnit inUnits)
Return the double value of the magnitude of this Time object in the specified multiplier and units.

Parameters:
inMultiplier - the multiplier identifier.
inUnits - the units identifier.
Returns:
the double value of the magnitude

getMultiplier

public Mult getMultiplier()
Return the Mult component of this Time object.

Returns:
the Mult component of this Time object.

getUnits

public TimeUnit getUnits()
Return the TimeUnit component of this Time object.

Returns:
the TimeUnit component of this Time object.

clear

public void clear()
Set the value of this Time object to 0 seconds.


clone

public java.lang.Object clone()
Return a copy of this Time object. Overrides Cloneable.

Returns:
a copy of this Time object.

hashcode

public int hashcode()
Return the hash code

Returns:
the hash code

equals

public boolean equals(java.lang.Object obj)
Compare two Times for equality. The result is true if and only if the argument object is not null, is a Time object and represents a time of the same magnitude as this Time.

Two Time objects are equal only if the getMagnitude method returns the same value for both with identical multiplier and unit identifiers.

Parameters:
obj - the object to compare with
Returns:
true if the Times are equivalent; false otherwise.

toString

public java.lang.String toString()
Return a String representation of this Time object.

Returns:
a String representation of this Time object

compareTo

public int compareTo(Time that)
Compare this object with the argument for order.

Parameters:
that - The Time to compare
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

compareTo

public int compareTo(java.lang.Object obj)
Compare this object with the argument for order.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - The Object to compare
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
ClassCastException - if the argument is not a Time.

Jeospace API

Copyright © 2006 - jeospace.org