Class tstzspanset

All Implemented Interfaces:
Base, Collection, Time, TimeCollection, TemporalObject

public class tstzspanset extends SpanSet<LocalDateTime> implements Time, TimeCollection
Class for representing lists of disjoint periods.

``tstzspanset`` objects can be created with a single argument of type string as in MobilityDB.

>>> tstzspanset(string='{[2019-09-08 00:00:00+01, 2019-09-10 00:00:00+01], [2019-09-11 00:00:00+01, 2019-09-12 00:00:00+01]}')

Another possibility is to give a list specifying the composing periods, which can be instances of ``str`` or ``tstzspan``. The composing periods must be given in increasing order.

>>> tstzspanset(period_list=['[2019-09-08 00:00:00+01, 2019-09-10 00:00:00+01]', '[2019-09-11 00:00:00+01, 2019-09-12 00:00:00+01]']) >>> tstzspanset(period_list=[tstzspan('[2019-09-08 00:00:00+01, 2019-09-10 00:00:00+01]'), tstzspan('[2019-09-11 00:00:00+01, 2019-09-12 00:00:00+01]')])

Author:
ARIJIT SAMAL
  • Field Details

    • periodList

      private final List<tstzspan> periodList
    • _inner

      private jnr.ffi.Pointer _inner
  • Constructor Details

    • tstzspanset

      public tstzspanset()
      The default constructor
    • tstzspanset

      public tstzspanset(jnr.ffi.Pointer _inner)
      Pointer Constructor
      Parameters:
      _inner - Pointer
    • tstzspanset

      public tstzspanset(String value)
      The string constructor
      Parameters:
      value - - a string with a tstzspanset value
    • tstzspanset

      public tstzspanset(List<tstzspan> periods)
      The array of Periods constructor
      Parameters:
      periods - - an array of Periods separated by a comma
  • Method Details

    • createStringInner

      public jnr.ffi.Pointer createStringInner(String str)
      Specified by:
      createStringInner in class SpanSet<LocalDateTime>
    • createInner

      public jnr.ffi.Pointer createInner(jnr.ffi.Pointer inner)
      Specified by:
      createInner in class SpanSet<LocalDateTime>
    • createListInner

      public jnr.ffi.Pointer createListInner(List<tstzspan> periods)
    • copy

      public jnr.ffi.Pointer copy()
      Return a copy of "this".

      Meos Functions:

    • spanset_copy
    • Overrides:
      copy in class SpanSet<LocalDateTime>
      Returns:
      a new tstzspanset instance
    • from_hexwkb

      public jnr.ffi.Pointer from_hexwkb(String str)
      Returns a "tstzspanset" from its WKB representation in hex-encoded ASCII.

      MEOS Functions:

    • spanset_from_hexwkb
    • Parameters:
      str - WKB representation in hex-encoded ASCII
      Returns:
      a new tstzspanset instance
    • toString

      public String toString()
      Return the string representation of the content of "this".

      MEOS Functions:

    • periodset_out
    • Overrides:
      toString in class Object
      Returns:
      a new String instance
    • to_period

      public tstzspan to_period()
      Returns a period that encompasses "this".

      MEOS Functions:

    • spanset_span
    • Returns:
      a new tstzspan instance
    • to_span

      public tstzspan to_span()
      Returns a period that encompasses "this".

      MEOS Functions:

    • spanset_span
    • Returns:
      a new tstzspan instance
    • get_inner

      public jnr.ffi.Pointer get_inner()
      Returns the C inner object
      Specified by:
      get_inner in class SpanSet<LocalDateTime>
      Returns:
      the inner Pointer
    • num_timestamps

      public int num_timestamps()
      Returns the number of timestamps in "this".

      MEOS Functions:

    • periodset_num_timestamps
    • Returns:
      an Integer instance
    • start_timestamp

      public LocalDateTime start_timestamp()
      Returns the first timestamp in "this".

      MEOS Functions:

    • periodset_start_timestamp
    • Returns:
      A LocalDateTime instance
    • end_timestamp

      public LocalDateTime end_timestamp()
      Returns the last timestamp in "this".

      MEOS Functions:

    • periodset_end_timestamp
    • Returns:
      A LocalDateTime instance
    • timestamp_n

      public LocalDateTime timestamp_n(int n)
      Returns the nth timestamp of the tstzspanset
      Parameters:
      n - the nth element
      Returns:
      Returns the nth timestamp of the tstzspanset
    • num_periods

      public int num_periods()
      Returns the number of periods in "this".

      MEOS Functions:

    • spanset_num_spans
    • Returns:
      an Integer instance
    • start_period

      public tstzspan start_period()
      Returns the first period in "this".

      MEOS Functions:

    • periodset_lower
    • Returns:
      a new tstzspan instance
    • start_span

      public tstzspan start_span()
      Returns the first period in "this".

      MEOS Functions:

    • periodset_lower
    • Returns:
      a new tstzspan instance
    • end_period

      public tstzspan end_period()
      Returns the last period in "this".

      MEOS Functions:

    • periodset_upper
    • Returns:
      a new tstzspan instance
    • end_span

      public tstzspan end_span()
      Returns the last period in "this".

      MEOS Functions:

    • periodset_upper
    • Returns:
      a new tstzspan instance
    • hash

      public long hash()
      Return the hash representation of "this".

      MEOS Functions:

    • spanset_hash
    • Overrides:
      hash in class SpanSet<LocalDateTime>
      Returns:
      a new Integer instance
    • is_adjacent

      public boolean is_adjacent(TemporalObject other) throws Exception
      Returns whether "this" is temporally adjacent to "other". That is, they share a bound but only one of them contains it.
       Examples:
       >>> tstzspanset('{[2012-01-01, 2012-01-02)}').is_adjacent(tstzspanset('{[2012-01-02, 2012-01-03]}'))
       >>> True
       >>> tstzspanset('{[2012-01-01, 2012-01-02]}').is_adjacent(tstzspanset('{[2012-01-02, 2012-01-03]}'))
       >>> False  # Both contain bound
       >>> tstzspanset('{[2012-01-01, 2012-01-02)}').is_adjacent(tstzspanset('{[(2012-01-02, 2012-01-03]]}'))
       >>> False  # Neither contain bound
       
      MEOS Functions:
      • adjacent_spanset_span
      • adjacent_spanset_spanset
      • adjacent_periodset_timestamp
      • adjacent_periodset_timestampset
      Parameters:
      other - temporal object to compare with
      Returns:
      True if adjacent, False otherwise
      Throws:
      Exception
    • is_contained_in

      public boolean is_contained_in(TemporalObject other) throws Exception
      Returns whether "this" is temporally contained in "other".
           Examples:
           >>> tstzspanset('{[2012-01-02, 2012-01-03]}').is_contained_in(tstzspan('{[2012-01-01, 2012-01-04]}'))
           >>> True
           >>> tstzspanset('{(2012-01-01, 2012-01-02)}').is_contained_in(tstzspan('{[2012-01-01, 2012-01-02]}'))
           >>> True
           >>> tstzspanset('{[2012-01-01, 2012-01-02]}').is_contained_in(tstzspan('{(2012-01-01, 2012-01-02)}'))
           >>> False
       
      MEOS Functions:
      • contained_spanset_span
      • contained_spanset_spanset
      • contained_periodset_temporal
      Parameters:
      other - temporal object to compare with
      Returns:
      True if contained, False otherwise
      Throws:
      Exception
    • contains

      public boolean contains(TemporalObject other) throws Exception
      Returns whether ``self`` temporally contains ``content``.
           Examples:
           >>> tstzspanset('{[2012-01-01, 2012-01-04]}').contains(tstzspanset('{[2012-01-02, 2012-01-03]}'))
           >>> True
           >>> tstzspanset('{[2012-01-01, 2012-01-02]}').contains(tstzspanset('{(2012-01-01, 2012-01-02)}'))
           >>> True
           >>> tstzspanset('{(2012-01-01, 2012-01-02)}').contains(tstzspanset('{[2012-01-01, 2012-01-02]}'))
           >>> False
       
      MEOS Functions:
      • contains_spanset_span
      • contains_spanset_spanset
      • contains_periodset_timestamp
      Parameters:
      other - temporal object to compare with
      Returns:
      True if contains, False otherwise
      Throws:
      Exception
    • overlaps

      public boolean overlaps(TemporalObject other) throws Exception
      Returns whether "this" temporally overlaps "other". That is, both share at least an instant
          Examples:
          >>> tstzspanset('{[2012-01-01, 2012-01-02]}').overlaps(tstzspanset('{[2012-01-02, 2012-01-03]}'))
          >>> True
          >>> tstzspanset('{[2012-01-01, 2012-01-02)}').overlaps(tstzspanset('{[2012-01-02, 2012-01-03]}'))
          >>> False
          >>> tstzspanset('{[2012-01-01, 2012-01-02)}').overlaps(tstzspanset('{(2012-01-02, 2012-01-03]}'))
          >>> False
      
      MEOS Functions:
      • overlaps_spanset_span
      • overlaps_spanset_spanset
      Parameters:
      other - temporal object to compare with
      Returns:
      True if overlaps, False otherwise
      Throws:
      Exception
    • is_same

      public boolean is_same(TemporalObject other) throws Exception
      Returns whether the bounding period of "this" is the same as the bounding period of "other".

      See Also: tstzspan.is_same(TemporalObject)

      Parameters:
      other - A time or temporal object to compare to "this".
      Returns:
      True if same, False otherwise.
      Throws:
      Exception
    • is_before

      public boolean is_before(TemporalObject other) throws Exception
      Returns whether "this" is strictly before "other". That is, "this" ends before "other" starts.
          Examples:
          >>> tstzspanset('{[2012-01-01, 2012-01-02)}').is_before(tstzspanset('{[2012-01-02, 2012-01-03]}'))
          >>> True
          >>> tstzspanset('{[2012-01-01, 2012-01-02)}').is_before(tstzspanset('{(2012-01-02, 2012-01-03]}'))
          >>> True
          >>> tstzspanset('{[2012-01-01, 2012-01-02]}').is_before(tstzspanset('{[2012-01-02, 2012-01-03]}'))
          >>> False
      
      MEOS Functions:
      • before_periodset_timestamp
      • left_spanset_span
      • left_spanset_spanset
      Parameters:
      other - temporal object to compare with
      Returns:
      True if before, False otherwise
      Throws:
      Exception
    • is_over_or_before

      public boolean is_over_or_before(TemporalObject other) throws Exception
      Returns whether "this" is before "other" allowing overlap. That is, "this" ends before "other" ends (or at the same time).
          Examples:
          >>> tstzspanset('{[2012-01-01, 2012-01-02)}').is_over_or_before(tstzspanset('{[2012-01-02, 2012-01-03]}'))
          >>> True
          >>> tstzspanset('{[2012-01-01, 2012-01-02]}').is_over_or_before(tstzspanset('{[2012-01-02, 2012-01-03]}'))
          >>> True
          >>> tstzspanset('{[2012-01-03, 2012-01-05]}').is_over_or_before(tstzspanset('{[2012-01-01, 2012-01-04]}'))
          >>> False
      
      MEOS Functions:
      • overleft_spanset_span
      • overleft_spanset_spanset
      • overbefore_periodset_timestamp
      • overbefore_periodset_timestampset
      • overbefore_periodset_temporal
      Parameters:
      other - temporal object to compare with
      Returns:
      True if before, False otherwise
      Throws:
      Exception
    • is_after

      public boolean is_after(TemporalObject other) throws Exception
      Returns whether "this" is strictly after "other".That is, "this" starts after "other" ends.
          Examples:
          >>> tstzspanset('{[2012-01-02, 2012-01-03]}').is_after(tstzspanset('{[2012-01-01, 2012-01-02)}'))
          >>> True
          >>> tstzspanset('{(2012-01-02, 2012-01-03]}').is_after(tstzspanset('{[2012-01-01, 2012-01-02)}'))
          >>> True
          >>> tstzspanset('{[2012-01-02, 2012-01-03]}').is_after(tstzspanset('{[2012-01-01, 2012-01-02]}'))
          >>> False
      
      MEOS Functions:
      • right_spanset_span
      • right_spanset_spanset
      • overbefore_timestamp_periodset
      Parameters:
      other - temporal object to compare with
      Returns:
      True if after, False otherwise
      Throws:
      Exception
    • is_over_or_after

      public boolean is_over_or_after(TemporalObject other) throws Exception
      Returns whether "this" is after "other" allowing overlap. That is, "this" starts after "other" starts (or at the same time).
          Examples:
          >>> tstzspanset('{[2012-01-02, 2012-01-03]}').is_over_or_after(tstzspanset('{[2012-01-01, 2012-01-02)}'))
          >>> True
          >>> tstzspanset('{[2012-01-02, 2012-01-03]}').is_over_or_after(tstzspanset('{[2012-01-01, 2012-01-02]}'))
          >>> True
          >>> tstzspanset('{[2012-01-02, 2012-01-03]}').is_over_or_after(tstzspanset('{[2012-01-01, 2012-01-03]}'))
          >>> False
      
      MEOS Functions:
      • overright_spanset_span
      • overright_spanset_spanset
      • overafter_periodset_timestamp
      • overafter_periodset_timestampset
      Parameters:
      other - temporal object to compare with
      Returns:
      True if overlapping or after, False otherwise
      Throws:
      Exception
    • intersection

      public Time intersection(Time other)
      Returns the temporal intersection of "this" and "other".

      MEOS Functions:

      • intersection_periodset_timestamp
      • intersection_spanset_spanset
      • intersection_spanset_span
      Parameters:
      other - temporal object to intersect with
      Returns:
      a Time instance. The actual class depends on "other"
    • mul

      public Time mul(Time other)
      Returns the temporal intersection of "this" and "other".

      MEOS Functions:

      • intersection_periodset_timestamp
      • intersection_spanset_spanset
      • intersection_spanset_span
      Parameters:
      other - temporal object to intersect with
      Returns:
      a Time instance. The actual class depends on "other"
    • minus

      public tstzspanset minus(Time other)
      Returns the temporal difference of "this" and "other".

      MEOS Functions:

      • minus_spanset_span
      • minus_spanset_spanset
      • minus_periodset_timestamp
      Parameters:
      other - temporal object to diff with
      Returns:
      a tstzspanset instance
    • sub

      public tstzspanset sub(Time other)
      Returns the temporal difference of "this" and "other".

      MEOS Functions:

      • minus_spanset_span
      • minus_spanset_spanset
      • minus_periodset_timestamp
      Parameters:
      other - temporal object to diff with
      Returns:
      a tstzspanset instance
    • union

      public tstzspanset union(Time other)
      Returns the temporal union of "this" and "other".

      MEOS Functions:

      • union_periodset_timestamp
      • union_spanset_spanset
      • union_spanset_span
      Parameters:
      other - temporal object to merge with
      Returns:
      a tstzspanset instance
    • add

      public tstzspanset add(Time other)
      Returns the temporal union of "this" and "other".

      MEOS Functions:

      • union_periodset_timestamp
      • union_spanset_spanset
      • union_spanset_span
      Parameters:
      other - temporal object to merge with
      Returns:
      a tstzspanset instance
    • eq

      public boolean eq(Time other)
      Return whether "this" and "other" are equal.

      MEOS Functions:

    • spanset_eq
    • Parameters:
      other - temporal object to compare with
      Returns:
      True if equal, False otherwise
    • notEquals

      public boolean notEquals(Time other)
      Return whether "this" and "other" are not equal.

      MEOS Functions:

    • spanset_ne
    • Parameters:
      other - temporal object to compare with
      Returns:
      True if not equal, False otherwise
    • lessThan

      public boolean lessThan(Time other) throws OperationNotSupportedException
      Return whether "this" is less than "other".

      MEOS Functions:

    • spanset_lt
    • Parameters:
      other - temporal object to compare with
      Returns:
      True if less than, False otherwise
      Throws:
      OperationNotSupportedException
    • lessThanOrEqual

      public boolean lessThanOrEqual(Time other) throws OperationNotSupportedException
      Return whether "this" is less than or equal to "other.

      MEOS Functions:

    • spanset_le
    • Parameters:
      other - temporal object to compare with
      Returns:
      True if less than or equal, False otherwise
      Throws:
      OperationNotSupportedException
    • greaterThan

      public boolean greaterThan(Time other) throws OperationNotSupportedException
      Return whether "this" is greater than "other".

      MEOS Functions:

    • spanset_gt
    • Parameters:
      other - temporal object to compare with
      Returns:
      True if greater than, False otherwise
      Throws:
      OperationNotSupportedException
    • greaterThanOrEqual

      public boolean greaterThanOrEqual(Time other) throws OperationNotSupportedException
      Return whether ``self`` is greater than or equal to ``other``.

      MEOS Functions:

    • spanset_ge
    • Parameters:
      other - temporal object to compare with
      Returns:
      True if greater than or equal, False otherwise
      Throws:
      OperationNotSupportedException