jasi.sim.basic.value
Class Time

java.lang.Object
  extended by jasi.sim.basic.value.AbstractSimValueType
      extended by jasi.sim.basic.value.AbstractComparableObject<Time>
          extended by jasi.sim.basic.value.Time
All Implemented Interfaces:
ExtendedComparable<Time>, SimValue, java.io.Serializable, java.lang.Comparable<Time>

public class Time
extends AbstractComparableObject<Time>

Simulation time. This class represents an immutable simulation time.

See Also:
Serialized Form

Field Summary
static java.util.Comparator<Time> COMPARATOR
          The time comparator.
static Time D
          Time constant for a day.
static Time H
          Time constant for an hour.
static Time M
          Time constant for a minute.
static Time MS
          Time constant for a millisecond.
static Time NEVER
          Time constant for infinite time.
static Time S
          Time constant for a second.
static Time ZERO
          Time constant for zero time.
 
Constructor Summary
Time(java.lang.String time)
          Constructor.
Time(Time time)
          Constructor.
 
Method Summary
 Time add(Time t)
          Add that time to this time.
 double amount(Time time)
          Retrieve the amount of this time in units of that time.
 int compareTo(Time t)
          Compares this object with the specified object for order.
static Time create(java.lang.String time)
          Factory for a time object.
 boolean equals(java.lang.Object o)
          Indicates, whether some other object is "equal to" this one.
 int hashCode()
          Returns a hash code value for the object.
 Time minus(Time t)
          Subtract that time from this time.
 Time times(double f)
          Multiply this time object by a factor.
 Time times(long f)
          Multiply this time object by a factor.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class jasi.sim.basic.value.AbstractComparableObject
isEQ, isGE, isGT, isLE, isLT, isNE
 
Methods inherited from class jasi.sim.basic.value.AbstractSimValueType
getContent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

COMPARATOR

public static final java.util.Comparator<Time> COMPARATOR
The time comparator. A comparison function, which imposes a total ordering.


ZERO

public static final Time ZERO
Time constant for zero time.


MS

public static final Time MS
Time constant for a millisecond.


S

public static final Time S
Time constant for a second.


M

public static final Time M
Time constant for a minute.


H

public static final Time H
Time constant for an hour.


D

public static final Time D
Time constant for a day.


NEVER

public static final Time NEVER
Time constant for infinite time. It uses Long.MAX_VALUE.

Constructor Detail

Time

public Time(Time time)
Constructor.

Parameters:
time - A time object.

Time

public Time(java.lang.String time)
Constructor.

Parameters:
time - The string representation of a time object.
Method Detail

create

public static Time create(java.lang.String time)
Factory for a time object.

Parameters:
time - The string representation of a time object.
Returns:
The created time.

amount

public double amount(Time time)
Retrieve the amount of this time in units of that time.

Parameters:
time - That time object.
Returns:
The amount.

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
The string.

add

public Time add(Time t)
Add that time to this time.

Parameters:
t - That time.
Returns:
The new time.

minus

public Time minus(Time t)
Subtract that time from this time.

Parameters:
t - That time.
Returns:
The new time.

times

public Time times(double f)
Multiply this time object by a factor.

Parameters:
f - The multiplication factor.
Returns:
The new Time.

times

public Time times(long f)
Multiply this time object by a factor.

Parameters:
f - The multiplication factor.
Returns:
The new Time.

hashCode

public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hash tables.

Overrides:
hashCode in class java.lang.Object
Returns:
A hash code value for this object.

equals

public boolean equals(java.lang.Object o)
Indicates, whether some other object is "equal to" this one.

Overrides:
equals in class java.lang.Object
Parameters:
o - That object which is compared with this object.
Returns:
True, if this object is the same as that object.

compareTo

public int compareTo(Time t)
Compares this object with the specified object for order.

Specified by:
compareTo in interface java.lang.Comparable<Time>
Specified by:
compareTo in class AbstractComparableObject<Time>
Parameters:
t - That time which is compared with this object.
Returns:
A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than that object.
See Also:
Comparable.compareTo(Object)