Class tstzset

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

public class tstzset extends Set<LocalDateTime> implements Time, TimeCollection
Class for representing lists of distinct timestamp values.
     ``tstzset`` objects can be created with a single argument of type string
     as in MobilityDB.

         >>> tstzset(string='{2019-09-08 00:00:00+01, 2019-09-10 00:00:00+01, 2019-09-11 00:00:00+01}')

     Another possibility is to give a tuple or list of composing timestamps,
     which can be instances of ``str`` or ``datetime``. The composing timestamps
     must be given in increasing order.

         >>> tstzset(timestamp_list=['2019-09-08 00:00:00+01', '2019-09-10 00:00:00+01', '2019-09-11 00:00:00+01'])
         >>> tstzset(timestamp_list=[parse('2019-09-08 00:00:00+01'), parse('2019-09-10 00:00:00+01'), parse('2019-09-11 00:00:00+01')])
 
Author:
Arijit Samal
  • Field Details

    • dateTimeList

      private final List<OffsetDateTime> dateTimeList
    • _inner

      private jnr.ffi.Pointer _inner
  • Constructor Details

    • tstzset

      public tstzset()
      The default constructor
    • tstzset

      public tstzset(jnr.ffi.Pointer _inner)
      Pointer constructor
      Parameters:
      _inner - Pointer
    • tstzset

      public tstzset(String value)
      The string constructor
      Parameters:
      value - - a string with a tstzset value
  • Method Details

    • createStringInner

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

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

      public static tstzset from_hexwkb(String hexwkb)
      Returns a "tstzset" from its WKB representation in hex-encoded ASCII.

      MEOS Functions:

    • set_from_hexwkb
    • Parameters:
      hexwkb - WKB representation in hex-encoded ASCII
      Returns:
      a new tstzset instance
    • toString

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

      MEOS Functions:

    • set_out
    • Overrides:
      toString in class Object
      Returns:
      a new String instance
    • to_periodset

      public tstzspanset to_periodset()
      Returns a tstzspanset that contains a tstzspan for each Timestamp in "this".

      MEOS Functions:

    • set_to_spanset
    • Returns:
      a new tstzspanset instance
    • to_span

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

      MEOS Functions:

    • set_span
    • Returns:
      a new tstzspan instance
    • to_spanset

      public tstzspanset to_spanset()
    • to_period

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

      MEOS Functions:

    • set_span
    • Returns:
      a new tstzspan instance
    • duration

      public Duration duration()
    • get_inner

      public jnr.ffi.Pointer get_inner()
      ------------------------- Accessors -------------------------------------
      Specified by:
      get_inner in class Set<LocalDateTime>
    • num_timestamps

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

      MEOS Functions:

    • set_num_values
    • Returns:
      a new Integer instance
    • start_element

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

      MEOS Functions:

    • timestampset_start_timestamp
    • Specified by:
      start_element in class Set<LocalDateTime>
      Returns:
      a instance
    • end_element

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

      MEOS Functions:

    • timestampset_end_timestamp
    • Specified by:
      end_element in class Set<LocalDateTime>
      Returns:
      a instance
    • element_n

      public LocalDateTime element_n(int n) throws Exception
      Description copied from class: Set
      Returns the n-th element in "this".
      Overrides:
      element_n in class Set<LocalDateTime>
      Parameters:
      n - the n-th element
      Returns:
      A Set instance
      Throws:
      Exception
    • elements

      public List<LocalDateTime> elements() throws Exception
      Throws:
      Exception
    • scale

      public tstzset scale(Integer duration)
    • shift

      public tstzset shift(Integer shift, Integer duration)
    • shift_scale

      public tstzset shift_scale(Integer shift, Integer duration)
    • hash

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

      MEOS Functions:

    • set_hash
    • Overrides:
      hash in class Set<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:
                   >>> tstzset('{2012-01-01, 2012-01-02}').is_adjacent(tstzspan('[2012-01-02, 2012-01-03]'))
                   >>> True
                   >>> tstzset('{2012-01-01, 2012-01-02}').is_adjacent(tstzspan('[2012-01-02, 2012-01-03]'))
                   >>> False  # Both contain bound
                   >>> tstzset('{2012-01-01, 2012-01-02}').is_adjacent(tstzspan('(2012-01-02, 2012-01-03]'))
                   >>> False  # Neither contain bound
      
      MEOS Functions:
      • adjacent_span_span
      • adjacent_spanset_span
      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:
                        >>> tstzset('{2012-01-02, 2012-01-03}').is_contained_in(tstzspan('[2012-01-01, 2012-01-04]'))
                        >>> True
                        >>> tstzset('{2012-01-01, 2012-01-02}').is_contained_in(tstzspan('[2012-01-01, 2012-01-02]'))
                        >>> True
                        >>> tstzset('{2012-01-01, 2012-01-02}').is_contained_in(tstzspan('(2012-01-01, 2012-01-02)'))
                        >>> False
           
      MEOS Functions:
      • contained_span_span
      • contained_span_spanset
      • contained_set_set
      • contained_spanset_spanset
      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 "this" temporally contains "other".
               Examples:
                   >>> tstzset('{2012-01-01, 2012-01-04}').contains(parse('2012-01-01]'))
                   >>> True
                   >>> tstzset('{2012-01-01, 2012-01-02}').contains(tstzset('{2012-01-01}'))
                   >>> True
                   >>> tstzset('{2012-01-01, 2012-01-02}').contains(tstzset('{2012-01-01, 2012-01-03}'))
                   >>> False
      
      MEOS Functions:
      • contains_timestampset_timestamp
      • contains_set_set
      • contains_spanset_spanset
      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:
                        >>> tstzset('{2012-01-01, 2012-01-02}').overlaps(tstzset('{2012-01-02, 2012-01-03}'))
                        >>> True
                        >>> tstzset('{2012-01-01, 2012-01-02}').overlaps(tstzspan('[2012-01-02, 2012-01-03]'))
                        >>> True
                        >>> tstzset('{2012-01-01, 2012-01-02}').overlaps(tstzspan('(2012-01-02, 2012-01-03]'))
                        >>> False
           
      MEOS Functions:
      • overlaps_set_set
      • overlaps_span_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(Time 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 `self`.
      Returns:
      true if same, false otherwise.
      Throws:
      Exception
    • is_after

      public boolean is_after(TemporalObject other) throws Exception
      Returns whether "this" is strictly after "other". That is, the first timestamp in "this" is after "other".
               Examples:
                   >>> tstzset('{2012-01-02, 2012-01-03}').is_after(tstzspan('[2012-01-01, 2012-01-02)'))
                   >>> True
                   >>> tstzset('{2012-01-02, 2012-01-03}').is_after(tstzset('{2012-01-01}'))
                   >>> True
                   >>> tstzset('{2012-01-02, 2012-01-03}').is_after(tstzspan('[2012-01-01, 2012-01-02]'))
                   >>> False
      
      MEOS Functions:
      • overbefore_timestamp_timestampset
      • right_set_set
      • right_span_span
      • right_span_spanset
      Parameters:
      other - temporal object to compare with
      Returns:
      true if after, 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:
                   >>> tstzset('{2012-01-01, 2012-01-02}').is_before(tstzset('{2012-01-03}'))
                   >>> True
                   >>> tstzset('{2012-01-01, 2012-01-02}').is_before(tstzspan('(2012-01-02, 2012-01-03]'))
                   >>> True
                   >>> tstzset('{2012-01-01, 2012-01-02}').is_before(tstzspan('[2012-01-02, 2012-01-03]'))
                   >>> False
       
      MEOS Functions:
      • overafter_timestamp_period
      • left_span_span
      • left_span_spanset
      Parameters:
      other - : temporal object to compare with
      Returns:
      true if before, 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:
                   >>> tstzset('{2012-01-02, 2012-01-03}').is_over_or_after(tstzspan('[2012-01-01, 2012-01-02)'))
                   >>> True
                   >>> tstzset('{2012-01-02, 2012-01-03}').is_over_or_after(tstzspan('[2012-01-01, 2012-01-02]'))
                   >>> True
                   >>> tstzset('{2012-01-02, 2012-01-03}').is_over_or_after(tstzspan('[2012-01-01, 2012-01-03]'))
                   >>> False
      
      MEOS Functions:
      • overafter_period_timestamp
      • overright_span_span
      • overright_span_spanset
      Parameters:
      other - temporal object to compare with
      Returns:
      true if overlapping or after, 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:
                   >>> tstzset('{2012-01-01, 2012-01-02}').is_over_or_before(tstzspan('[2012-01-02, 2012-01-03]'))
                   >>> True
                   >>> tstzset('{2012-01-01, 2012-01-02}').is_over_or_before(tstzspan('[2012-01-02, 2012-01-03]'))
                   >>> True
                   >>> tstzset('{2012-01-03, 2012-01-05}').is_over_or_before(tstzspan('[2012-01-01, 2012-01-04]'))
                   >>> False
      
      MEOS Functions:
      • overbefore_period_timestamp
      • overleft_span_span
      • overleft_span_spanset
      Parameters:
      other - temporal object to compare with
      Returns:
      true if before, false otherwise
      Throws:
      Exception
    • distance

      public Duration distance(Object other) throws Exception
      Throws:
      Exception
    • intersection

      public Time intersection(TemporalObject other) throws Exception
      Returns the temporal intersection of "this" and "other". MEOS Functions:
      • intersection_set_set
      • intersection_spanset_span
      • intersection_spanset_spanset
      Parameters:
      other - temporal object to intersect with
      Returns:
      a Time instance. The actual class depends on "other".
      Throws:
      Exception
    • mul

      public Time mul(TemporalObject other) throws Exception
      Returns the temporal intersection of "this" and "other". MEOS Functions:
      • intersection_set_set
      • intersection_spanset_span
      • intersection_spanset_spanset
      Parameters:
      other - temporal object to intersect with
      Returns:
      a Time instance. The actual class depends on "other".
      Throws:
      Exception
    • minus

      public Time minus(TemporalObject other) throws Exception
      Returns the temporal difference of "this" and "other". MEOS Functions:
      • minus_timestampset_timestamp
      • minus_set_set
      • minus_spanset_span
      • minus_spanset_spanset
      Parameters:
      other - temporal object to diff with
      Returns:
      a Time instance. The actual class depends on "other".
      Throws:
      Exception
    • sub

      public Time sub(Time other) throws Exception
      Returns the temporal difference of "this" and "other". MEOS Functions:
      • minus_timestampset_timestamp
      • minus_set_set
      • minus_spanset_span
      • minus_spanset_spanset
      Parameters:
      other - temporal object to diff with
      Returns:
      a Time instance. The actual class depends on "other".
      Throws:
      Exception
    • union

      public Time union(TemporalObject other) throws Exception
      Returns the temporal union of "this" and "other". MEOS Functions:
      • union_timestampset_timestamp
      • union_set_set
      • union_spanset_span
      • union_spanset_spanset
      Parameters:
      other - temporal object to merge with
      Returns:
      a Time instance. The actual class depends on "other".
      Throws:
      Exception
    • add

      public Time add(Time other) throws Exception
      Returns the temporal union of "this" and "other". MEOS Functions:
      • union_timestampset_timestamp
      • union_set_set
      • union_spanset_span
      • union_spanset_spanset
      Parameters:
      other - temporal object to merge with
      Returns:
      a Time instance. The actual class depends on "other".
      Throws:
      Exception