Class Timeline

  • All Implemented Interfaces:
    java.io.Serializable

    public class Timeline
    extends TimelineList<java.lang.Object>
    A timeline is a simple list of time segments. It is used to determine coverage, and its segments do not contain values. If values should be associated with time, use TimelineList.

    Note: this also overrides some functions to provide correct support for TimeOfDay style values (ie, times, not full dates). Specifically, that means that functions like getClosest, nextEvent, getSegment, will roll over to the earliest time if necessary. As a consequence, anyone calling these should note whether the return is earlier than the requested time, and accordingly adjust their calculations by 1 day.

    See Also:
    Serialized Form
    • Constructor Detail

      • Timeline

        public Timeline()
      • Timeline

        public Timeline​(Timeline.TimelineStyle style)
        Specifies the style of timeline that this is (in other words, what the times represent).
    • Method Detail

      • addSegment

        public void addSegment​(long start,
                               long end)
        Adds a segment for the specified start and end times.
      • getSegment

        public TimelineList.TimeSegment getSegment​(long time,
                                                   boolean allowClosest)
        Description copied from class: TimelineList
        Returns the segment that contains the time. If allowClosest is true, will return the next possible time, if a time segment doesn't cover the current time.
        Overrides:
        getSegment in class TimelineList<java.lang.Object>
      • getClosest

        public java.lang.Object getClosest​(long time)
        Description copied from class: TimelineList
        Returns the value for the given time, or the next defined value. Returns null if there is no value specified at, or beyond, the given time.
        Overrides:
        getClosest in class TimelineList<java.lang.Object>
      • nextEvent

        public long nextEvent​(long time)
        Description copied from class: TimelineList
        Returns the next time that something interesting happens after the given time. That is, the current segment ends, the next one starts, etc. If nothing else happens, Long.Max is returned.
        Overrides:
        nextEvent in class TimelineList<java.lang.Object>
      • invert

        public Timeline invert()
        Returns a timeline whose elements cover the inverse of the source timeline.