|
tauZaman v0.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--tauzaman.timestamp.TimeValue
TimeValue
class implements the arithmetic and
comparison operations for an underlying domain of times
times that are bounded by "MIN" and "MAX" values.
MIN (MAX) are before (after) the smallest (largest) times.
Operations on TimeValues usually construct a new TimeValue, they
never mutate a TimeValue.
For example, assuming a discrete domain of times implemented
using longs.
TimeValue min = TimeValue.BEGINNING_OF_TIME; TimeValue max = TimeValue.END_OF_TIME; TimeValue one = new TimeValue(1); TimeValue three = new TimeValue(3); TimeValue result = max.add(min); System.out.println(max.image()); // Prints [TimeValue MAX] System.out.println(min.image()); // Prints [TimeValue MIN] System.out.println(result.image()); // prints [TimeValue NORMAL 0] result = one.add(three); System.out.println(one.image()); // Prints [TimeValue NORMAL 1] System.out.println(three.image()); // Prints [TimeValue NORMAL 3] System.out.println(result.image()); //Prints [TimeValue NORMAL 4]
Granule
,
Serialized FormField Summary | |
static TimeValue |
ALL_OF_TIME
|
static TimeValue |
BEGINNING_OF_TIME
|
static TimeValue |
END_OF_TIME
|
private int |
kind
|
private static int |
MAX
|
private static int |
MIN
|
static TimeValue |
MINUS_ONE_TIMEVALUE
|
static TimeValue |
NEGATIVE_ALL_OF_TIME
|
private static int |
NORMAL
|
static TimeValue |
ONE_TIMEVALUE
|
private long |
value
|
static TimeValue |
ZERO_TIMEVALUE
|
Constructor Summary | |
TimeValue(int count)
Construct a NORMAL time value. |
|
TimeValue(int kind,
int count)
Construct a NORMAL, MAX or MIN time value. |
|
TimeValue(int kind,
long count)
Construct a NORMAL, MAX or MIN time value. |
|
TimeValue(long granules)
Creates a NORMAL TimeValue. |
Method Summary | |
TimeValue |
add(TimeValue other)
Construct the result of "this plus other". |
int |
compareTo(java.lang.Object otherTimeValue)
Compare this TimeValue with another. |
TimeValue |
decrement()
Construct this TimeValue - 1 |
TimeValue |
divide(int n)
Construct the result of "this div N". |
int |
getKind()
Accessor function to get the kind represented by this TimeValue. |
long |
getValue()
Accessor function to get the value represented by this TimeValue. |
java.lang.String |
image()
Create a nice string image of a time value |
TimeValue |
increment()
Construct this TimeValue + 1 |
static void |
main(java.lang.String[] argv)
A simple test for the class. |
TimeValue |
multiply(int n)
Construct the result of "this times N". |
TimeValue |
negate()
Construct the result of "minus this". |
TimeValue |
subtract(TimeValue other)
Construct the result of "this minus other". |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final int MAX
private static final int MIN
private static final int NORMAL
public static final TimeValue END_OF_TIME
public static final TimeValue ALL_OF_TIME
public static final TimeValue BEGINNING_OF_TIME
public static final TimeValue NEGATIVE_ALL_OF_TIME
public static final TimeValue ZERO_TIMEVALUE
public static final TimeValue ONE_TIMEVALUE
public static final TimeValue MINUS_ONE_TIMEVALUE
private int kind
private long value
Constructor Detail |
public TimeValue(int kind, long count)
kind
- - NORMAL, MAX, or MINcount
- - granule countpublic TimeValue(int kind, int count)
kind
- - NORMAL, MAX, or MINcount
- - granule countpublic TimeValue(int count)
count
- - granule countpublic TimeValue(long granules)
granules
- - count in granules of this TimeValueMethod Detail |
public java.lang.String image()
public int getKind()
public long getValue()
public int compareTo(java.lang.Object otherTimeValue)
compareTo
in interface java.lang.Comparable
Comparable
public TimeValue subtract(TimeValue other)
other
- - The TimeValue to subtract
public TimeValue add(TimeValue other)
other
- - The TimeValue to add
public TimeValue negate()
public TimeValue increment()
public TimeValue decrement()
public TimeValue multiply(int n)
public TimeValue divide(int n)
public static void main(java.lang.String[] argv)
|
tauZaman v0.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |