Class TimelineList<T>

java.lang.Object
com.inductiveautomation.ignition.common.util.TimelineList<T>
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Timeline

public class TimelineList<T> extends Object implements Serializable
A timeline list is a list of values that cover a span of time. There is only one timeline, and so values cannot overlap. Items can be added with a start time, in which the end will be "forever", or a fixed range. In either case, the start and end may be adjusted (or the value overwritten) by new values that get added.
See Also:
  • Constructor Details

    • TimelineList

      public TimelineList()
  • Method Details

    • size

      public int size()
    • sort

      public void sort()
    • indexOf

      protected int indexOf(long time, boolean allowRollover)
      Returns the index of the segment that covers the time, or comes next after the time.
      Parameters:
      allowRollover - if the time is beyond the last segment, and this parameter is true, the first index will be returned. Otherwise the last index of the list will be returned.
      Returns:
      the index of the segment that covers the time, or comes next after the time.
    • getSegment

      protected TimelineList<T>.TimeSegment getSegment(int pos)
    • add

      public void add(long start, T value)
      Add the value at the given time, with a duration of forever. Some care should be taken when using this function, because if values do not arrive in ascending time, previous entries will be overwritten. Because of this behavior, this function can also check the equality of values and avoid making extra segments, improving performance.
    • add

      public void add(long start, long end, T value)
    • add

      public void add(TimelineList<T>.TimeSegment timeSegment)
    • add

      public void add(TimelineList timelineList)
    • covered

      public boolean covered(long time)
      Returns whether the timeline contains a segment that covers the specified time.
    • get

      public T get(long time)
      Returns the value for the specified time, or null if a value isn't defined.
    • getClosest

      public T getClosest(long time)
      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.
    • get

      protected T get(long time, boolean allowClosest, boolean allowRollover)
    • getSegment

      public TimelineList<T>.TimeSegment getSegment(long time, boolean allowClosest)
      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.
    • getSegment

      public TimelineList<T>.TimeSegment getSegment(long time, boolean allowClosest, boolean allowRollover)
      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.
    • nextEvent

      public long nextEvent(long time)
      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.
    • nextEvent

      public long nextEvent(long time, boolean allowRollover)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getSegments

      public List<TimelineList<T>.TimeSegment> getSegments()
    • mergeSegments

      public void mergeSegments()
      Merges together contiguous segments with the same value. Used for composite user schedules.