com.dlsc.flexgantt.model

## Interface ITimeSpan

- All Superinterfaces:
    Comparable<ITimeSpan>, Serializable
  All Known Implementing Classes:
    TimeSpan

      public interface ITimeSpan
      extends Comparable<ITimeSpan>, Serializable

  A time span encapsulates a start and an end time, making it easier to handle objects that are placed on a timeline. Time spans implement the `Comparable` interface, which allows for easy sorting based on the start time.
  Since:
    1.0
  Version:
    $Revision: 1.11 $
  Author:
    Dirk Lemmermann
  See Also:
    `TimeSpanIterator`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `contains(ITimeSpan span)` Checks whether the time span contains the given time span.
    `boolean` | `contains(long time)` Checks whether the time span contains the given time point.
    `boolean` | `endsAfter(ITimeSpan span)` Checks whether the given time span ends after this time span.
    `boolean` | `endsBefore(ITimeSpan span)` Checks whether the given time span ends before this time span.
    `boolean` | `equalDuration(ITimeSpan span)` Checks whether the given time span has exactly the same duration as this time span.
    `boolean` | `equals(ITimeSpan span)` Two time spans are considered equal if their start times and their end times are identical.
    `long` | `getDuration()` Calculates the total duration of this time span.
    `long` | `getEndTime()` Returns the time span's end time.
    `long` | `getStartTime()` Returns the time span's start time.
    `ITimeSpan` | `intersection(ITimeSpan span)` Returns the intersection between the time span and the given time span.
    `boolean` | `intersects(ITimeSpan span)` Checks whether the given time span intersects with this time span.
    `boolean` | `isActivity()` Determines whether this time span represents an activity.
    `boolean` | `isEvent()` Determines whether this time span represents an event.
    `boolean` | `isUndefined()` Checks whether this time span is undefined.
    `ITimeSpan` | `move(long delta)` Constructs a new time span based on this span where the given (delta) milliseconds are added to (or subtracted from if negative) the start and end time of this time span.
    `boolean` | `startsAfter(ITimeSpan span)` Checks whether the given time span starts after this time span.
    `boolean` | `startsBefore(ITimeSpan span)` Checks whether the given time span starts before this time span.
    `String` | `toString(DateFormat format)` Returns a compact string representation of the time span.
    `ITimeSpan` | `union(ITimeSpan span)` The union of two time spans is a new time span, where the start time of the new span is the minimum start time and the end time is the maximum end time of the two spans.

    - ### Methods inherited from interface java.lang.Comparable

      `compareTo`

- - ### Method Detail

    - #### getStartTime

          long getStartTime()

      Returns the time span's start time. In order for a time span to be valid the end time has to be larger or equal to the end time.
      Returns:
        the start time
      Since:
        1.0
      See Also:
        `getEndTime()`

    - #### getEndTime

          long getEndTime()

      Returns the time span's end time. The end time is guaranteed to be larger or equal to the start time.
      Returns:
        the end time
      Since:
        1.0
      See Also:
        `getStartTime()`

    - #### contains

          boolean contains(ITimeSpan span)

      Checks whether the time span contains the given time span. One time span A contains time span B if A.start <= B.start and A.end >= B.end.
      Parameters:
        `span` - the time span to test for containment
      Returns:
        TRUE if the given time span is completely contained
      Since:
        1.0
      See Also:
        `intersects(ITimeSpan)`

    - #### contains

          boolean contains(long time)

      Checks whether the time span contains the given time point. One time span A contains time point TP if A.start <= TP and A.end >= TP.
      Parameters:
        `time` - the time point to test for containment
      Returns:
        TRUE if the given time point is contained
      Since:
        1.1
      See Also:
        `contains(ITimeSpan)`, `intersects(ITimeSpan)`

    - #### endsAfter

          boolean endsAfter(ITimeSpan span)

      Checks whether the given time span ends after this time span. One time span A ends after time span B if A.end > B.end.
      Parameters:
        `span` - the time span to test
      Returns:
        TRUE if the given time span ends after this time span
      Since:
        1.0
      See Also:
        `endsBefore(ITimeSpan)`

    - #### endsBefore

          boolean endsBefore(ITimeSpan span)

      Checks whether the given time span ends before this time span. One time span A ends before time span B if A.end < B.end.
      Parameters:
        `span` - the time span to test
      Returns:
        TRUE if the given time span ends before this time span
      Since:
        1.0
      See Also:
        `endsAfter(ITimeSpan)`

    - #### equalDuration

          boolean equalDuration(ITimeSpan span)

      Checks whether the given time span has exactly the same duration as this time span.
      Parameters:
        `span` - the time span to test
      Returns:
        TRUE if the given time span has the same duration as this span
      Since:
        1.0
      See Also:
        `getDuration()`

    - #### getDuration

          long getDuration()

      Calculates the total duration of this time span. The duration is the difference between the end time and the start time.
      Returns:
        the duration of this span in milliseconds
      Since:
        1.0
      See Also:
        `equalDuration(ITimeSpan)`

    - #### intersects

          boolean intersects(ITimeSpan span)

      Checks whether the given time span intersects with this time span. One time span A intersects with time span B if B.start < A.end <= B.end.
      Parameters:
        `span` - the time span to test for intersection
      Returns:
        TRUE if the given time span intersects with this time span
      Since:
        1.0
      See Also:
        `contains(ITimeSpan)`

    - #### intersection

          ITimeSpan intersection(ITimeSpan span)

      Returns the intersection between the time span and the given time span. The intersection of two time spans A and B is defined as the maximum of the two start times and the minimum of the two end times. This method has to return an undefined time span (see `isUndefined()`) if the two time spans do not intersect at all.
      Parameters:
        `span` - the time span for which to calculate the intersection
      Returns:
        the intersection (the time span in common) of the time span and the given time span
      Since:
        1.1

    - #### isActivity

          boolean isActivity()

      Determines whether this time span represents an activity. An activity has a duration (as opposed to an event). Implementors of this interface are free to choose other criteria for events.
      Returns:
        TRUE if the time span's duration is larger than zero
      Since:
        1.0
      See Also:
        `isEvent()`

    - #### isEvent

          boolean isEvent()

      Determines whether this time span represents an event. An event is commonly represented by a time span where the duration is equal to zero (as opposed to an activity). Implementors of this interface are free to choose other criteria for events.
      Returns:
        TRUE if the time span's duration is equal to zero
      Since:
        1.0
      See Also:
        `isEvent()`

    - #### move

          ITimeSpan move(long delta)

      Constructs a new time span based on this span where the given (delta) milliseconds are added to (or subtracted from if negative) the start and end time of this time span.
      Parameters:
        `delta` - the amount of milliseconds to add to or subtract from the new time span's start and end time
      Returns:
        a time span moved by 'delta' milliseconds
      Since:
        1.0

    - #### startsAfter

          boolean startsAfter(ITimeSpan span)

      Checks whether the given time span starts after this time span. One time span A starts after time span B if A.start > B.start.
      Parameters:
        `span` - the time span to test
      Returns:
        TRUE if the given time span starts after this time span
      Since:
        1.0
      See Also:
        `startsBefore(ITimeSpan)`

    - #### startsBefore

          boolean startsBefore(ITimeSpan span)

      Checks whether the given time span starts before this time span. One time span A starts before time span B if A.start < B.start.
      Parameters:
        `span` - the time span to test
      Returns:
        TRUE if the given time span starts before this time span
      Since:
        1.0
      See Also:
        `startsAfter(ITimeSpan)`

    - #### union

          ITimeSpan union(ITimeSpan span)

      The union of two time spans is a new time span, where the start time of the new span is the minimum start time and the end time is the maximum end time of the two spans. Special checks are required when one or both of the time spans are undefined (`isUndefined()`). If only one of the spans is undefined then the other span becomes the result of the union operation. If both of them are undefined then the result will be undefined, too.
      Parameters:
        `span` - the second time span for the union
      Returns:
        a new time span object based on the minimum start and maximum end time of this time span and the given time span
      Since:
        1.0

    - #### equals

          boolean equals(ITimeSpan span)

      Two time spans are considered equal if their start times and their end times are identical.
      Parameters:
        `span` - the time span to test
      Returns:
        TRUE if this time span and the given time span have the same start and end times
      Since:
        1.0

    - #### isUndefined

          boolean isUndefined()

      Checks whether this time span is undefined. Undefined time spans can be used in time span calculations to indicate that no time span has been computed, yet (example: the method `union(ITimeSpan)` first checks whether the span on which the method gets called is undefined. If so and the given second time span is not undefined then the result of the union operation will be a copy of the second span).
      Returns:
        TRUE if the time span is undefined
      Since:
        1.0

    - #### toString

          String toString(DateFormat format)

      Returns a compact string representation of the time span. The method uses the given date formatting object.
      Parameters:
        `format` - the formatter used to create a date string
      Returns:
        a nicely formatted text representation of the time span
      Since:
        1.0

Copyright © 2006–2020 Dirk Lemmermann Software & Consulting. All rights reserved.