tauZaman
v0.1

tauzaman.temporaldatatypes
Class Interval

java.lang.Object
  |
  +--tauzaman.temporaldatatypes.Interval
All Implemented Interfaces:
java.lang.Cloneable

public class Interval
extends java.lang.Object
implements java.lang.Cloneable

The Interval class provides a set of constructor and accessor operations for intervals. (Arithmetic and comparison operations are implemented in a @see Semantics.) An interval is a length of time, unanchonred to any specific point or region on the time-line. For example, the interval "1 day" represents a length. It can be used, for example, to displace values anchored to the time-line, e.g., "July 3, 2002", by a distance of "1 day", moving the instant to "July 4, 2002". This class implements intervals that have a known, fixed length as well as intervals that are indeterminately known. To perform comparisons and arithmetic operations on Intervals, it is first necessary to create a @see Semantics interface. A Semantics implements common comparison and arithmetic operations on temporal entities. For example a user would write code like the following

     // Left operand semantics casts operands in binary operations 
     // to the granularity of the left operand, and then performs
     // the desired operation. 
     Ops = new LeftOperandSemantics();
     // Create an Instant and an Interval.
     // In this example, both are at the granularity of days.
     Instant i = new Instant("July 3, 2002");
     Interval j = new Interval("1 day");
     // Displace i by length j, k will represent the day "July 4, 2002" 
     Instant k = Ops.add(i,j);
  
We employ this strategy so that interval operations can be performed under varying Semantics.

See Also:
DeterminateSemantics, IndeterminateSemantics
Status:
design complete, NOT IMPLEMENTED

Field Summary
(package private)  TauZamanService cachedTauZamanService
          TauZamanService that this Instant is created under
private  Granule granule
           
 
Constructor Summary
Interval(Granularity g, Granule granule)
          Construct an Interval from a count of granules.
Interval(Granule granule)
          Construct an Interval from a count of granules.
Interval(Period p)
          Construct an Interval as the distance between a period's endpoints
Interval(java.lang.String literal)
          Construct a Interval given a String literal.
 
Method Summary
 Interval cast()
          Cast this Interval to the default granularity.
 Interval cast(Granularity g)
          Cast this Interval to the indicated granularity.
 Granularity getGranularity()
          Retrieve the Granularity from this Interval
 Granule granule()
          Accessor - retrieve the Granule from this Interval.
 java.lang.String image()
          Build a nice string image of an Interval, for debugging mostly.
 Granule largest()
          Get the largest (only!)
 java.lang.String output()
          Returns string representation of this Interval.
 Interval scale()
          Scale this Interval to the default granularity.
 Interval scale(Granularity g)
          Scale this Interval to the indicated granularity.
 Granule smallest()
          Get the smallest (only!)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

granule

private Granule granule

cachedTauZamanService

TauZamanService cachedTauZamanService
TauZamanService that this Instant is created under

Constructor Detail

Interval

public Interval(Granularity g,
                Granule granule)
Construct an Interval from a count of granules. Convert the resulting interval to the specified granularity using the default conversion semantics.

Parameters:
g - - granularity
granule - - length in granules
Status:
NOT IMPLMENTED

Interval

public Interval(Granule granule)
Construct an Interval from a count of granules.

Parameters:
granule - - length in granules

Interval

public Interval(java.lang.String literal)
         throws TemporalDataTypeFormationException
Construct a Interval given a String literal.

Parameters:
literal - String representing temporal constant
Throws:
TemporalDataTypeFormationException - if any abnormal condition occurs during parsing of string temporal constant to Instant timestamp

Interval

public Interval(Period p)
Construct an Interval as the distance between a period's endpoints

Status:
NOT IMPLEMENTED
Method Detail

output

public java.lang.String output()
                        throws TemporalDataTypeFormationException
Returns string representation of this Interval.

Returns:
String temporal constant that corresponds to this Interval
Throws:
TemporalDataTypeFormationException - if any abnormal condition occurs when forming string temporal constant from timestamp

image

public java.lang.String image()
Build a nice string image of an Interval, for debugging mostly. Provides an alternative to toString().

Returns:
String image of Interval

cast

public Interval cast(Granularity g)
Cast this Interval to the indicated granularity. It will create a new Interval.

Parameters:
g - - Granularity
Status:
NOT IMPLEMENTED

cast

public Interval cast()
Cast this Interval to the default granularity. It will create a new Interval.

Status:
NOT IMPLEMENTED

scale

public Interval scale(Granularity g)
Scale this Interval to the indicated granularity. It will create a new Interval.

Parameters:
g - - Granularity
Status:
NOT IMPLEMENTED

scale

public Interval scale()
Scale this Interval to the default granularity. It will create a new Interval.

Status:
NOT IMPLEMENTED

smallest

public Granule smallest()
Get the smallest (only!) Granule from this Interval.

Returns:
the Interval's granule
Status:
Is this used?

largest

public Granule largest()
Get the largest (only!) Granule in this Interval.

Returns:
the Interval's granule
Status:
Is this used?

granule

public Granule granule()
Accessor - retrieve the Granule from this Interval.

Returns:
the Interval's granule

getGranularity

public Granularity getGranularity()
Retrieve the Granularity from this Interval

Returns:
Granularity

tauZaman
v0.1

Submit a bug or feature

tauZaman is an open-source, publicly avaliable project