All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class tadt.standard.Period

java.lang.Object
   |
   +----tadt.standard.Period

public class Period
extends Object
implements Anchorable
The Period class implements the Anchorable interface for Periods. A Period consists of two Instants. Each Instant may have a different granularity. There is no constraint that the Instants must be Temporally ordered, although this is possible to enforce in future.


Constructor Index

 o Period(Granularity, Instant, Instant)
Construct a Period from a pair of Instants.
 o Period(Granularity, Instant[])
Construct a Period from an array of Instants and a Granularity.
 o Period(Instant, Instant)
Construct a Period from a pair of Instants.
 o Period(Instant[])
Construct a Period from an array of Instants.

Method Index

 o add(Interval)
Add an Interval to this Period
 o asInstantArray()
Retrieve the array of Instants (containing the starting and terminating Instants) from this Period.
 o asPeriodArray()
Retrieve the array of Periods (containing only this) from this Period.
 o cast(Granularity)
Cast this Period to the indicated granularity.
 o earliestInstant()
Returns the starting Instant in the Period.
 o earliestPeriod()
Returns the earliest Period in the Period.
 o enumerateInstants()
Create an Enumeration of Instants in the Anchorable.
 o enumeratePeriods()
Create an Enumeration of Periods in the Anchorable.
 o equals(Anchorable)
Test for equality, needed only for supporting Hashtables, use equalTo for comparing Periods directly.
 o equals(Period)
Test for equality, needed only for supporting Hashtables, use equalTo for comparing Periods directly.
 o equalTo(Anchorable)
Is this Period equalTo another Anchorable? Always false since the other thing is not an Period.
 o equalTo(Period)
Is this Period equalTo another?
 o greaterThan(Anchorable)
Is this Period greaterThan another Anchorable?
 o greaterThan(Period)
Is this Period greaterThan another?
 o greaterThanOrEqualTo(Anchorable)
Is this Period greaterThanOrEqualTo another Anchorable?
 o greaterThanOrEqualTo(Period)
Is this Period greaterThanOrEqualTo another?
 o hashCode()
Generate the hash code value, needed for supporting Hashtables.
 o image()
Build a nice string image of an Period, for debugging mostly
 o intersection(Period)
Determine the intersection of two Periods.
 o kind()
Return the name of this class.
 o latestInstant()
Returns the terminating Instant in the Period.
 o latestPeriod()
Returns the latest Period in the Period.
 o lessThan(Anchorable)
Is this Period lessThan another Anchorable?
 o lessThan(Period)
Is this Period lessThan another Period?
 o lessThanOrEqualTo(Anchorable)
Is this Period lessThanOrEqualTo another Anchorable?
 o lessThanOrEqualTo(Period)
Is this Period lessThanOrEqualTo another?
 o newInstance(String, Instant[])
Construct a new instance of a Period, Interval combination
 o newInstance(String, Period[])
Construct a new instance of a Period, Interval combination
 o overlaps(Period)
Does this Period overlap another?
 o scale(Granularity)
Scale this Period to the indicated granularity.
 o subtract(Interval)
Subtract an Interval from this Period
 o union(Period)
Determine the union of two Periods.

Constructors

 o Period
  public Period(Granularity g,
                Instant start,
                Instant terminate)
Construct a Period from a pair of Instants. It will scale the Instants to the desired granularity and check to make sure that the starting Instant is before the ending Instant. This is not really needed since the Instants should be allowed to be at different granularities. A scale is used to preserve all the information in the bounding Instants.

Parameters:
g - - Granularity of desired period
start - - first Instant
terminate - - second Instant
Throws: badPeriod
- possibly terminates before it starts, currently it will print a warning and set the starting and terminating Instants as the same Instant, but in future it should throw the exception.
 o Period
  public Period(Instant start,
                Instant terminate)
Construct a Period from a pair of Instants. Note that this will not cast the instants to the desired granularity, this is the real constructor.

Parameters:
start - - First instant
terminate - - Second instant
Throws: badPeriod
- possibly terminates before it starts, currently it will print a warning and set the starting and terminating Instants as the same Instant, but in future it should throw the exception.
 o Period
  public Period(Instant instants[])
Construct a Period from an array of Instants.

Parameters:
instants - - array of Instants
Throws: tooManyInstants
- too many Instants in the array, too few instants will cause an internal error. For now, we give a warning rather than throwing the exception.
Throws: badPeriod
- possibly terminates before it starts, currently it will print a warning and set the starting and terminating Instants as the same Instant, but in future it should throw the exception.
 o Period
  public Period(Granularity g,
                Instant instants[])
Construct a Period from an array of Instants and a Granularity. It will scale the Instants to the supplied Granularity.

Parameters:
g - - granularity of Period
instants - - array of Instants
Throws: tooManyInstants
- too many Instants in the array, too few instants will cause an internal error. For now, we give a warning rather than throwing the exception.
Throws: badPeriod
- possibly terminates before it starts, currently it will print a warning and set the starting and terminating Instants as the same Instant, but in future it should throw the exception.

Methods

 o image
  public String image()
Build a nice string image of an Period, for debugging mostly

Returns:
String image of Period
 o hashCode
  public int hashCode()
Generate the hash code value, needed for supporting Hashtables.

Returns:
int
Overrides:
hashCode in class Object
 o equals
  public boolean equals(Anchorable other)
Test for equality, needed only for supporting Hashtables, use equalTo for comparing Periods directly. This will always return false since the other thing is not a Period.

Parameters:
other - - Anchorable to compare
Returns:
false
 o equals
  public boolean equals(Period other)
Test for equality, needed only for supporting Hashtables, use equalTo for comparing Periods directly.

Parameters:
other - - Period to compare
Returns:
true or false
 o earliestInstant
  public Instant earliestInstant()
Returns the starting Instant in the Period.

Returns:
Instant - the starting Instant
 o latestInstant
  public Instant latestInstant()
Returns the terminating Instant in the Period.

Returns:
Instant - the terminating Instant
 o earliestPeriod
  public Period earliestPeriod()
Returns the earliest Period in the Period.

Returns:
this
 o latestPeriod
  public Period latestPeriod()
Returns the latest Period in the Period.

Returns:
this
 o enumeratePeriods
  public Enumeration enumeratePeriods()
Create an Enumeration of Periods in the Anchorable.

 o enumerateInstants
  public Enumeration enumerateInstants()
Create an Enumeration of Instants in the Anchorable.

 o asInstantArray
  public Instant[] asInstantArray()
Retrieve the array of Instants (containing the starting and terminating Instants) from this Period.

Returns:
array of Instants
 o asPeriodArray
  public Period[] asPeriodArray()
Retrieve the array of Periods (containing only this) from this Period.

Returns:
array of Periods with one Period in it.
 o overlaps
  public ExtendedBoolean overlaps(Period other)
Does this Period overlap another?

Returns:
well does it?
 o union
  public Period[] union(Period other)
Determine the union of two Periods. This is just a helper function it is not needed really.

Returns:
Array of Periods that is the union of the two Periods, it will have one element if they overlap, two if they do not.
 o intersection
  public Period intersection(Period other)
Determine the intersection of two Periods.

Returns:
Period that is the Interesection, or null if they do not.
 o kind
  public String kind()
Return the name of this class.

Returns:
String
 o newInstance
  public Anchorable newInstance(String beta,
                                Instant i[])
Construct a new instance of a Period, Interval combination

Returns:
- new Anchorable
 o newInstance
  public Anchorable newInstance(String beta,
                                Period i[])
Construct a new instance of a Period, Interval combination

Returns:
- new Anchorable
 o cast
  public Period cast(Granularity g)
Cast this Period to the indicated granularity. Note that it is not a mutator, it will create a new Period.

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

 o lessThan
  public ExtendedBoolean lessThan(Anchorable beta)
Is this Period lessThan another Anchorable?

Parameters:
beta - - Anchorable to compare
Returns:
this < beta
 o lessThan
  public ExtendedBoolean lessThan(Period beta)
Is this Period lessThan another Period?

Parameters:
beta - - Period to compare
Returns:
this < beta
 o lessThanOrEqualTo
  public ExtendedBoolean lessThanOrEqualTo(Anchorable beta)
Is this Period lessThanOrEqualTo another Anchorable?

Parameters:
beta - - Anchorable to compare
Returns:
this < beta
 o lessThanOrEqualTo
  public ExtendedBoolean lessThanOrEqualTo(Period beta)
Is this Period lessThanOrEqualTo another?

Parameters:
beta - - Period to compare
Returns:
this <= beta
 o greaterThan
  public ExtendedBoolean greaterThan(Anchorable beta)
Is this Period greaterThan another Anchorable?

Parameters:
beta - - Anchorable to compare
Returns:
this < beta
 o greaterThan
  public ExtendedBoolean greaterThan(Period beta)
Is this Period greaterThan another?

Parameters:
beta - - Period to compare
Returns:
this > beta
 o equalTo
  public ExtendedBoolean equalTo(Anchorable beta)
Is this Period equalTo another Anchorable? Always false since the other thing is not an Period.

Parameters:
beta - - Anchorable to compare
Returns:
false
 o equalTo
  public ExtendedBoolean equalTo(Period beta)
Is this Period equalTo another?

Parameters:
beta - - Period to compare
Returns:
this == beta
 o greaterThanOrEqualTo
  public ExtendedBoolean greaterThanOrEqualTo(Anchorable beta)
Is this Period greaterThanOrEqualTo another Anchorable?

Parameters:
beta - - Anchorable to compare
Returns:
this < beta
 o greaterThanOrEqualTo
  public ExtendedBoolean greaterThanOrEqualTo(Period beta)
Is this Period greaterThanOrEqualTo another?

Parameters:
beta - - Period to compare
Returns:
this >= beta
 o add
  public Period add(Interval beta)
Add an Interval to this Period

Parameters:
beta - - Interval to add
Returns:
Period - new Period
 o subtract
  public Period subtract(Interval beta)
Subtract an Interval from this Period

Parameters:
beta - - Interval to subtract
Returns:
Period - new Period

All Packages  Class Hierarchy  This Package  Previous  Next  Index