tauZaman
v0.1

tauzaman.temporaldatatypes
Interface DeterminateSemantics


public interface DeterminateSemantics

The DeterminateSemantics interface contains all the arithmetic and comparison operations that are available on determinate time values. In a determinate semantics, all granularity conversions must be casts instead of scales, and ExtendedBoolean values are not used. This is an interface because there are lots of different semantics for even standard operations such as precedes, such as left-operand semantics where the operation is performed at the granularity of the left operand. Below is an example of how one might use a semantics (assume that LeftOperandSemantics implements DeterminateSemantics).

     LeftOperandSemantics ops = new LeftOperandSemantics();
     Instant j = new Instant("July 3, 2003");
     Interval i = new Interval("1 month");
     Instant k = ops.add(i,j); // k is in the granularity of "days"
     Instant m = ops.add(j,i); // k is in the granularity of "months"
  
Just a few operations are currently represented to give an idea of the eventual interface. All the operations are on individual kinds of time values, e.g., Instant, Period, Interval. We need to expand this with a complete set of temporal operators implementing Allen's algebra.

See Also:
Instant, Period, Interval

Method Summary
 Instant add(Instant alpha, Interval beta)
          Displace (add) an Instant on the time-line by an Interval
 Interval add(Interval alpha, Interval beta)
          Add one Interval to another
 Period add(Period alpha, Interval beta)
          Displace (add) a Period on the time-line by an Interval
 boolean contains(Period alpha, Period beta)
          Does this Period contain another?
 Interval divide(Interval alpha, int n)
          Divide an Interval by an integer constant.
 int divide(Interval alpha, Interval beta)
          Divide an Interval by an Interval (integer division).
 boolean during(Period alpha, Period beta)
          Is this Period during another?
 boolean equalTo(Instant alpha, Instant beta)
          Does this Instant represent the same times as another?
 boolean equalTo(Period alpha, Period beta)
          Does this Period represent the same times as another?
 boolean finishes(Period alpha, Period beta)
          Does this Period finish at the same time as another, but start after it, that is, is alpha.end == beta.end but alpha.start < beta.start?
 Instant first(Instant alpha, Instant beta)
          Temporal constructor - Choose the first (earliest) from among a pair of instants
 Instant last(Instant alpha, Instant beta)
          Temporal constructor - Choose the last (latest) from among a pair of instants
 boolean meets(Period alpha, Period beta)
          Does the end of a Period meet the start of another Period, that is, is alpha.end == beta.start?
 boolean metBy(Period alpha, Period beta)
          Is the start of a Period metBy the start of another Period, that is, is beta.end == alpha.start?
 Interval multiply(Interval alpha, int n)
          Multiply an Interval by an integer constant.
 Interval negate(Interval alpha)
          Negate an Interval.
 boolean overlaps(Period alpha, Period beta)
          Does one Period overlap another?
 boolean precedes(Instant alpha, Instant beta)
          Does one Instant precede another, that is, is alpha < beta?
 boolean precedes(Instant alpha, Period beta)
          Does an Instant precede the start of a Period, that is, is alpha < beta.start?
 boolean precedes(Period alpha, Instant beta)
          Does the end of a Period precede the start of an Instant, that is, is alpha.end < beta?
 boolean precedes(Period alpha, Period beta)
          Does the end of a Period precede the start of another, that is, is alpha.end < beta.start?
 boolean starts(Period alpha, Period beta)
          Does this Period begin at the same time as another, but end before it, that is, is alpha.start == beta.start but alpha.end < beta.end?
 Instant subtract(Instant alpha, Interval beta)
          Displace (subtract) an Instant on the time-line by an Interval
 Interval subtract(Interval alpha, Interval beta)
          Subtract one Interval from another
 Period subtract(Period alpha, Interval beta)
          Displace (subtract) a Period on the time-line by an Interval
 

Method Detail

precedes

public boolean precedes(Instant alpha,
                        Instant beta)
Does one Instant precede another, that is, is alpha < beta?

Parameters:
alpha - - Instant to compare
beta - - Instant to compare
Returns:
alpha < beta

precedes

public boolean precedes(Instant alpha,
                        Period beta)
Does an Instant precede the start of a Period, that is, is alpha < beta.start?

Parameters:
alpha - - Instant to compare
beta - - Period to compare
Returns:
alpha < beta.start

precedes

public boolean precedes(Period alpha,
                        Instant beta)
Does the end of a Period precede the start of an Instant, that is, is alpha.end < beta?

Parameters:
alpha - - Period to compare
beta - - Instant to compare
Returns:
alpha.end < beta

precedes

public boolean precedes(Period alpha,
                        Period beta)
Does the end of a Period precede the start of another, that is, is alpha.end < beta.start?

Parameters:
alpha - - Period to compare
beta - - Period to compare
Returns:
alpha.end < beta.start

starts

public boolean starts(Period alpha,
                      Period beta)
Does this Period begin at the same time as another, but end before it, that is, is alpha.start == beta.start but alpha.end < beta.end?

Parameters:
alpha - - Period to compare
beta - - Period to compare
Returns:
alpha.start == beta.start AND alpha.end < beta.end

finishes

public boolean finishes(Period alpha,
                        Period beta)
Does this Period finish at the same time as another, but start after it, that is, is alpha.end == beta.end but alpha.start < beta.start?

Parameters:
alpha - - Period to compare
beta - - Period to compare
Returns:
alpha.end == beta.end AND alpha.start < beta.start

meets

public boolean meets(Period alpha,
                     Period beta)
Does the end of a Period meet the start of another Period, that is, is alpha.end == beta.start? This is the inverse of metBy().

Parameters:
alpha - - Period to compare
beta - - Period to compare
Returns:
alpha.end == beta.start

metBy

public boolean metBy(Period alpha,
                     Period beta)
Is the start of a Period metBy the start of another Period, that is, is beta.end == alpha.start? This is the inverse of meets().

Parameters:
alpha - - Period to compare
beta - - Period to compare
Returns:
alpha.start == beta.end

overlaps

public boolean overlaps(Period alpha,
                        Period beta)
Does one Period overlap another? Two Periods overlap if they intersect in time. This operation is symmetric.

Parameters:
alpha - - Period to compare
beta - - Period to compare
Returns:
alpha overlaps beta

contains

public boolean contains(Period alpha,
                        Period beta)
Does this Period contain another? A periods contains another if it starts before it and ends after it. The containment need not be strict.

Parameters:
alpha - - Period to compare
beta - - Period to compare
Returns:
alpha.start <= beta.start AND alpha.end >= beta.end

during

public boolean during(Period alpha,
                      Period beta)
Is this Period during another? A periods is during another if it starts after it and ends before it. The containment need not be strict.

Parameters:
alpha - - Period to compare
beta - - Period to compare
Returns:
alpha.start >= beta.start AND alpha.end <= beta.end

equalTo

public boolean equalTo(Period alpha,
                       Period beta)
Does this Period represent the same times as another? A period is equalTo another if it both starts and finishes it. This operation is symmetric.

Parameters:
alpha - - Period to compare
beta - - Period to compare
Returns:
alpha.start == beta.start AND alpha.end == beta.end

equalTo

public boolean equalTo(Instant alpha,
                       Instant beta)
Does this Instant represent the same times as another? An instant is equalTo another if it is at the same time. This operation is symmetric.

Parameters:
alpha - - Instant to compare
beta - - Instant to compare
Returns:
alpha == beta

add

public Period add(Period alpha,
                  Interval beta)
Displace (add) a Period on the time-line by an Interval

Parameters:
alpha - - displacee
beta - - displacor
Returns:
- [alpha.start + beta, alpha.end + beta]

add

public Instant add(Instant alpha,
                   Interval beta)
Displace (add) an Instant on the time-line by an Interval

Parameters:
alpha - - displacee
beta - - displacor
Returns:
- alpha + beta

add

public Interval add(Interval alpha,
                    Interval beta)
Add one Interval to another

Parameters:
alpha - - displacee
beta - - displacor
Returns:
- alpha + beta

subtract

public Period subtract(Period alpha,
                       Interval beta)
Displace (subtract) a Period on the time-line by an Interval

Parameters:
alpha - - displacee
beta - - displacor
Returns:
- [alpha.start - beta, alpha.end - beta]

subtract

public Instant subtract(Instant alpha,
                        Interval beta)
Displace (subtract) an Instant on the time-line by an Interval

Parameters:
alpha - - displacee
beta - - displacor
Returns:
- alpha - beta

subtract

public Interval subtract(Interval alpha,
                         Interval beta)
Subtract one Interval from another

Parameters:
alpha - - displacee
beta - - displacor
Returns:
- alpha - beta

negate

public Interval negate(Interval alpha)
Negate an Interval.

Parameters:
alpha - - Interval to negate
Returns:
- -alpha

multiply

public Interval multiply(Interval alpha,
                         int n)
Multiply an Interval by an integer constant.

Parameters:
alpha - - Interval to multiply
n - - by how many
Returns:
result - (alpha * n)

divide

public Interval divide(Interval alpha,
                       int n)
Divide an Interval by an integer constant.

Parameters:
alpha - - Interval to divide
n - - by how many
Returns:
result - (alpha div n)

divide

public int divide(Interval alpha,
                  Interval beta)
Divide an Interval by an Interval (integer division).

Parameters:
alpha - - divisee
beta - - divisor

first

public Instant first(Instant alpha,
                     Instant beta)
Temporal constructor - Choose the first (earliest) from among a pair of instants

Parameters:
alpha - - Instant
beta - - Instant
Returns:
first Instant on the time-line from among alpha and beta

last

public Instant last(Instant alpha,
                    Instant beta)
Temporal constructor - Choose the last (latest) from among a pair of instants

Parameters:
alpha - - Instant
beta - - Instant
Returns:
last Instant on the time-line from among alpha and beta

tauZaman
v0.1

Submit a bug or feature

tauZaman is an open-source, publicly avaliable project