Package llnl.gnem.core.util
Class Epoch
java.lang.Object
llnl.gnem.core.util.Epoch
- All Implemented Interfaces:
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:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
For some actions on epochs it is useful to use a time resolution appropriate for the type of epoch. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
boolean
ContainsTime
(TimeT aTime) Determine whether an instant in time falls within this Epochdouble
duration()
Determines the duration in seconds of this Epoch.boolean
Return true if the input Object is an Epoch object and if its Start and End fields match those from this Object.Gets the start of the Epoch as a TimeT objectstatic Epoch
getBoundingEpoch
(Epoch epoch1, Epoch epoch2) double
getEnd()
Gets the end of the Epoch as a TimeT objectGets the endtime attribute of the Epoch objectgetIntersection
(Epoch other) Return an Epoch that is the intersection of this Epoch with the input Epochdouble
Return the length of this Epoch in daysdouble
Return the length of this Epoch in secondsGets the offdate attribute of the Epoch objectint
Gets the offJdate attribute of the Epoch objectGets the ondate attribute of the Epoch objectint
Gets the onJdate attribute of the Epoch objectdouble
getStart()
getTime()
Gets the time attribute of the Epoch objectint
hashCode()
Returns a hash code based on the Start and End fields of the object.boolean
intersects
(Epoch e) Determine whether the input epoch intersects this Epochboolean
isEmpty()
Return true if the Epoch is empty ( start GTEQ end )boolean
Return true if this Epoch is a subset of the input Epochboolean
isSuperset
(Epoch E) Return true if this Epoch is a superset of the input Epochdouble
Determines the length in seconds of the overlap between the input Epoch and this Epoch.void
print
(PrintStream ps) Use the object's toString method to print into a PrintStreamdouble
projection
(Epoch other) void
RoundEpochBoundaries
(Epoch.TimeResolution timeResolution) Round the Epoch boundaries to the time resolution specified in the input argument.void
setEndtime
(TimeT end) Sets the end time of this Epoch objectvoid
Sets the start time of this Epoch objectvoid
setTimeResolution
(Epoch.TimeResolution resolution) Sets the timeResolution attribute of the Epoch objecttoString()
Return a string describing the state of the object
-
Field Details
-
MAX_POSSIBLE_TIME
-
MIN_POSSIBLE_TIME
-
-
Constructor Details
-
Epoch
public Epoch()Constructor for the Epoch object -
Epoch
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 Epocht2
- 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
Copy constructor for the Epoch object- Parameters:
that
- input Epoch to be copied into new object
-
-
Method Details
-
getBoundingEpoch
-
ContainsTime
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
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
- Specified by:
compareTo
in interfaceComparable
-
duration
public double duration()Determines the duration in seconds of this Epoch.- Returns:
- Duration of the Epoch in seconds
-
equals
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. -
getEnd
public double getEnd()Gets the end of the Epoch as a TimeT object- Returns:
- The end value as a TimeT object
-
getEndtime
Gets the endtime attribute of the Epoch object- Returns:
- The endtime value
-
setEndtime
Sets the end time of this Epoch object- Parameters:
end
- The new (TimeT) end value
-
getIntersection
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
-
projection
-
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
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
Gets the ondate attribute of the Epoch object- Returns:
- The ondate value
-
getStart
public double getStart() -
getTime
Gets the time attribute of the Epoch object- Returns:
- The time value
-
setTime
Sets the start time of this Epoch object- Parameters:
start
- The new (TimeT) start value
-
setTimeResolution
Sets the timeResolution attribute of the Epoch object- Parameters:
resolution
- The new timeResolution value
-
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. -
intersection
- Parameters:
e
- Description of the Parameter- Returns:
- Description of the Return Value
-
intersects
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
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
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
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
Use the object's toString method to print into a PrintStream- Parameters:
ps
- The input PrintStream
-
toString
Return a string describing the state of the object
-