tauZaman
v0.1

tauzaman.temporaldatatypes
Class Instant

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

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

The Instant class provides a set of constructor and accessor operations on Instants. (Arithmetic and comparison operations are implemented in a Semantics.) An instant is a point on the time-line, e.g., 'July 3, 2002'. An instant could also be indeterminately known, e.g., "July 3, 2002 ~ July 4, 2002". To perform comparisons and arithmetic operations on Instants, it is first necessary to create a 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 two Instants, in this case, both are at the granularity of days
     Instant i = new Instant("July 3, 2002");
     Instant j = new Instant("July 4, 2002");
     // Is i earlier on the time-line than j?
     if (Ops.precedes(i,j)) ...
  
We employ this strategy so that all the instant operations can be performed under varying Semantics.

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

Field Summary
static Instant BEGINNING_OF_TIME
           
(package private)  TauZamanService cachedTauZamanService
          TauZamanService that this Instant is created under
static Instant END_OF_TIME
           
private  Granule granule
           
static Instant ZERO_TIME
           
 
Constructor Summary
Instant()
          Construct a zero Instant in the default granularity.
Instant(Granularity g)
          Construct a zero Instant in the desired granularity.
Instant(Granularity g, Granule granule)
          Construct an Instant from a granule representing the distance from the granularity anchor point Convert the Instant to the desired granularity.
Instant(Granule granule)
          Construct an Instant from a granule representing the distance from the granularity anchor point
Instant(java.lang.String literal)
          Construct an Instant by parsing a string, using the default granularity.
Instant(java.lang.String literal, Granularity g)
          Construct an Instant by parsing a string.
 
Method Summary
 Instant cast(Granularity g)
          Cast this Instant to the indicated granularity.
 Granule earliest()
          Returns the earliest (only!)
 Granularity getGranularity()
          Retrieve the Granularity from this Instant
 Granule getGranule()
          Retrieve the granule from this Instant
 java.lang.String image()
          Build a nice string image of an Instant, for debugging mostly.
 Granule latest()
          Returns the latest (only!)
 java.lang.String output()
          Returns string representation of this Instant.
 Instant scale(Granularity g)
          Scale this Instant to the indicated granularity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEGINNING_OF_TIME

public static final Instant BEGINNING_OF_TIME

END_OF_TIME

public static final Instant END_OF_TIME

ZERO_TIME

public static final Instant ZERO_TIME

granule

private Granule granule

cachedTauZamanService

TauZamanService cachedTauZamanService
TauZamanService that this Instant is created under

Constructor Detail

Instant

public Instant(Granule granule)
Construct an Instant from a granule representing the distance from the granularity anchor point

Parameters:
granule - - distance in granules from the anchor
Status:
NOT IMPLEMENTED

Instant

public Instant(Granularity g,
               Granule granule)
Construct an Instant from a granule representing the distance from the granularity anchor point Convert the Instant to the desired granularity.

Parameters:
g - - granularity
granule - - distance in granules from the anchor
Status:
NOT IMPLEMENTED

Instant

public Instant(java.lang.String literal)
        throws TemporalDataTypeFormationException
Construct an Instant by parsing a string, using the default granularity.

Parameters:
literal - - a string representation of the instant
Throws:
TemporalDataTypeFormationException - if any abnormal condition occurs during parsing of string temporal constant to Instant timestamp

Instant

public Instant(java.lang.String literal,
               Granularity g)
Construct an Instant by parsing a string. The resulting Instant will be converted to the desired Granularity using the default conversion semantics (cast or scale).

Parameters:
literal - - a string representation of the instant
g - - granularity
Status:
NOT IMPLMENTED

Instant

public Instant(Granularity g)
Construct a zero Instant in the desired granularity. The Granule in the Instant defaults to the zeroth @see Granule.

Parameters:
g - - Granularity
Status:
NOT IMPLEMENTED.

Instant

public Instant()
Construct a zero Instant in the default granularity. The Granule in the Instant defaults to the zeroth @see Granule.

Status:
NOT IMPLEMENTED.
Method Detail

output

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

Returns:
String temporal constant that corresponds to this Instant
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 Instant, for debugging mostly. Provides an alternative to toString().

Returns:
String image of Instant

earliest

public Granule earliest()
Returns the earliest (only!) Granule in the Instant.

Returns:
Granule - the Granule for this Instant

latest

public Granule latest()
Returns the latest (only!) Granule in the Instant.

Returns:
Granule - the latest Granule

cast

public Instant cast(Granularity g)
Cast this Instant to the indicated granularity. Note that it is not a mutator, it will create a new Instant.

Parameters:
g - - desired Granularity
Status:
NOT IMPLEMENTED

scale

public Instant scale(Granularity g)
Scale this Instant to the indicated granularity. Note that it is not a mutator, it will create a new Instant.

Parameters:
g - - desired Granularity
Status:
NOT IMPLEMENTED

getGranularity

public Granularity getGranularity()
Retrieve the Granularity from this Instant

Returns:
Granularity object

getGranule

public Granule getGranule()
Retrieve the granule from this Instant

Returns:
Granule

tauZaman
v0.1

Submit a bug or feature

tauZaman is an open-source, publicly avaliable project