Class Epoch

java.lang.Object
llnl.gnem.core.util.Epoch
All Implemented Interfaces:
Serializable, Comparable

public class Epoch extends Object implements Serializable, Comparable
The Epoch class encapsulates the concept of a time interval such as an operational epoch of a site. Epochs can be compared for equality, intersection, and sub/super set relation. Epoch bounds and extents can be accessed and modified.
Author:
Doug Dodge
See Also:
  • Field Details

    • MAX_POSSIBLE_TIME

      public static final TimeT MAX_POSSIBLE_TIME
    • MIN_POSSIBLE_TIME

      public static final TimeT MIN_POSSIBLE_TIME
  • Constructor Details

    • Epoch

      public Epoch()
      Constructor for the Epoch object
    • Epoch

      public Epoch(TimeT t1, TimeT t2)
      Constructor for the Epoch object
      Parameters:
      t1 -
      t2 - The end of the Epoch Note: if T2 is less than T1 their order will be reversed in the constructor so that the epoch duration is GTEQ 0.
    • Epoch

      public Epoch(double t1, double t2)
      Constructor for the Epoch object
      Parameters:
      t1 - The start of the Epoch
      t2 - The end of the Epoch Note: if T2 is less than T1 their order will be reversed in the constructor so that the epoch duration is GTEQ 0.
    • Epoch

      public Epoch(Epoch that)
      Copy constructor for the Epoch object
      Parameters:
      that - input Epoch to be copied into new object
  • Method Details

    • getBoundingEpoch

      public static Epoch getBoundingEpoch(Epoch epoch1, Epoch epoch2)
    • ContainsTime

      public boolean ContainsTime(TimeT aTime)
      Determine whether an instant in time falls within this Epoch
      Parameters:
      aTime - The instant in time to be checked (a TimeT)
      Returns:
      true if the instant is within this Epoch, false otherwise.
    • RoundEpochBoundaries

      public void RoundEpochBoundaries(Epoch.TimeResolution timeResolution)
      Round the Epoch boundaries to the time resolution specified in the input argument. If timeResolution is not one of the values in Epoch.TimeResolution, then no rounding will occur. Note: Rounding may cause the Epoch to become empty if both Start and End round to the same values.
      Parameters:
      timeResolution - An input value that should be one of the values from Epoch.TimeResolution.
    • compareTo

      public int compareTo(Object aThat)
      Specified by:
      compareTo in interface Comparable
    • duration

      public double duration()
      Determines the duration in seconds of this Epoch.
      Returns:
      Duration of the Epoch in seconds
    • equals

      public boolean equals(Object o)
      Return true if the input Object is an Epoch object and if its Start and End fields match those from this Object. Note that equals does not compare the timeResolution field, so two Epoch objects can compare true even when their timeResolutions differ.
      Overrides:
      equals in class Object
      Parameters:
      o - Input Object putatively a Epoch
      Returns:
      true if o is a Epoch with matching fields.
    • getEnd

      public double getEnd()
      Gets the end of the Epoch as a TimeT object
      Returns:
      The end value as a TimeT object
    • getEndtime

      public TimeT getEndtime()
      Gets the endtime attribute of the Epoch object
      Returns:
      The endtime value
    • setEndtime

      public void setEndtime(TimeT end)
      Sets the end time of this Epoch object
      Parameters:
      end - The new (TimeT) end value
    • getIntersection

      public Epoch getIntersection(Epoch other)
      Return an Epoch that is the intersection of this Epoch with the input Epoch
      Parameters:
      other - The input Epoch to be intersected with this Epoch
      Returns:
      The result Epoch which is the intersection result.. The Epoch will be empty if the intersection is empty.
    • union

      public Epoch union(Epoch other)
    • projection

      public double projection(Epoch other)
    • getLengthInDays

      public double getLengthInDays()
      Return the length of this Epoch in days
      Returns:
      A double value which is the length of this Epoch in days ( including fractional parts of a day).
    • getLengthInSeconds

      public double getLengthInSeconds()
      Return the length of this Epoch in seconds
      Returns:
      A double value which is the length of the Epoch in seconds
    • getOffJdate

      public int getOffJdate()
      Gets the offJdate attribute of the Epoch object
      Returns:
      The offJdate value
    • getOffdate

      public TimeT getOffdate()
      Gets the offdate attribute of the Epoch object
      Returns:
      The offdate value
    • getOnJdate

      public int getOnJdate()
      Gets the onJdate attribute of the Epoch object
      Returns:
      The onJdate value
    • getOndate

      public TimeT getOndate()
      Gets the ondate attribute of the Epoch object
      Returns:
      The ondate value
    • getStart

      public double getStart()
    • getTime

      public TimeT getTime()
      Gets the time attribute of the Epoch object
      Returns:
      The time value
    • setTime

      public void setTime(TimeT start)
      Sets the start time of this Epoch object
      Parameters:
      start - The new (TimeT) start value
    • setTimeResolution

      public void setTimeResolution(Epoch.TimeResolution resolution)
      Sets the timeResolution attribute of the Epoch object
      Parameters:
      resolution - The new timeResolution value
    • getbeginning

      public TimeT getbeginning()
      Gets the start of the Epoch as a TimeT object
      Returns:
      The start value as a TimeT object
    • hashCode

      public int hashCode()
      Returns a hash code based on the Start and End fields of the object.
      Overrides:
      hashCode in class Object
      Returns:
      An int hash code value.
    • intersection

      public Epoch intersection(Epoch e)
      Parameters:
      e - Description of the Parameter
      Returns:
      Description of the Return Value
    • intersects

      public boolean intersects(Epoch e)
      Determine whether the input epoch intersects this Epoch
      Parameters:
      e - Input Epoch to be tested
      Returns:
      true if the input Epoch intersects this Epoch, false otherwise
    • isEmpty

      public boolean isEmpty()
      Return true if the Epoch is empty ( start GTEQ end )
      Returns:
      true if the Epoch is empty, false otherwise.
    • isSubset

      public boolean isSubset(Epoch E)
      Return true if this Epoch is a subset of the input Epoch
      Parameters:
      E - The input Epoch
      Returns:
      true if this Epoch is a subset of the input Epoch, false otherwise.
    • isSuperset

      public boolean isSuperset(Epoch E)
      Return true if this Epoch is a superset of the input Epoch
      Parameters:
      E - The input Epoch
      Returns:
      true if this Epoch is a superset of the input Epoch, false otherwise.
    • overlapAmount

      public double overlapAmount(Epoch I)
      Determines the length in seconds of the overlap between the input Epoch and this Epoch.
      Parameters:
      I - The input Epoch to be compared with this Epoch
      Returns:
      The overlap length in seconds. If there is no overlap, the return value is 0.0.
    • print

      public void print(PrintStream ps)
      Use the object's toString method to print into a PrintStream
      Parameters:
      ps - The input PrintStream
    • toString

      public String toString()
      Return a string describing the state of the object
      Overrides:
      toString in class Object
      Returns:
      A String showing the Epoch start and end times, formatted according to the time resolution.