Class tstzspan

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

public class tstzspan extends Span<LocalDateTime> implements Time, TimeCollection
Class for representing sets of contiguous timestamps between a lower and an upper bound. The bounds may be inclusive or not.

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

>>> new tstzspan("(2019-09-08 00:00:00+01, 2019-09-10 00:00:00+01)")

Another possibility is to provide the ``lower`` and ``upper`` named parameters (of type str or datetime), and optionally indicate whether the bounds are inclusive or exclusive (by default, the lower bound is inclusive and the upper is exclusive):

>>> new tstzspan(lower='2019-09-08 00:00:00+01', upper='2019-09-10 00:00:00+01') >>> new tstzspan(lower='2019-09-08 00:00:00+01', upper='2019-09-10 00:00:00+01', lower_inc=False, upper_inc=True) >>> new tstzspan(lower=parse('2019-09-08 00:00:00+01'), upper=parse('2019-09-10 00:00:00+01'), upper_inc=True)

Author:
ARIJIT SAMAL
  • Field Details

  • Constructor Details

    • tstzspan

      public tstzspan()
      The default constructor
    • tstzspan

      public tstzspan(tstzspan other)
      Constructor by copy
      Parameters:
      other - period instace
    • tstzspan

      public tstzspan(jnr.ffi.Pointer _inner)
      Constructor through Meos (C) inner object
      Parameters:
      _inner - Pointer to C object
    • tstzspan

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

      public tstzspan(String lower, String upper)
      The timestamps without bounds constructor
      Parameters:
      lower - - a timestamp for the lower bound
      upper - - a timestamp for the upper bound
    • tstzspan

      public tstzspan(String lower, String upper, boolean lowerInclusive, boolean upperInclusive)
      The timestamps and bounds constructor
      Parameters:
      lower - - a timestamp for the lower bound
      upper - - a timestamp for the upper bound
      lowerInclusive - - if the lower bound is inclusive
      upperInclusive - - if the upper bound is inclusive
    • tstzspan

      public tstzspan(LocalDateTime lower, LocalDateTime upper)
      The timestamps without bounds constructor
      Parameters:
      lower - - a timestamp for the lower bound
      upper - - a timestamp for the upper bound
    • tstzspan

      public tstzspan(LocalDateTime lower, LocalDateTime upper, boolean lowerInclusive, boolean upperInclusive)
      The timestamps and bounds constructor
      Parameters:
      lower - - a timestamp for the lower bound
      upper - - a timestamp for the upper bound
      lowerInclusive - - if the lower bound is inclusive
      upperInclusive - - if the upper bound is inclusive
    • tstzspan

      public tstzspan(String lower, LocalDateTime upper)
      The timestamps without bounds constructor
      Parameters:
      lower - - a timestamp for the lower bound
      upper - - a timestamp for the upper bound
    • tstzspan

      public tstzspan(LocalDateTime lower, String upper)
      The timestamps without bounds constructor
      Parameters:
      lower - - a timestamp for the lower bound
      upper - - a timestamp for the upper bound
  • Method Details

    • createStringInner

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

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

      public jnr.ffi.Pointer createIntInt(Number lower, Number upper, boolean lower_inc, boolean upper_inc)
      Specified by:
      createIntInt in class Span<LocalDateTime>
    • createIntStr

      public jnr.ffi.Pointer createIntStr(Number lower, String upper, boolean lower_inc, boolean upper_inc)
      Specified by:
      createIntStr in class Span<LocalDateTime>
    • createStrStr

      public jnr.ffi.Pointer createStrStr(String lower, String upper, boolean lower_inc, boolean upper_inc)
      Specified by:
      createStrStr in class Span<LocalDateTime>
    • createStrInt

      public jnr.ffi.Pointer createStrInt(String lower, Number upper, boolean lower_inc, boolean upper_inc)
      Specified by:
      createStrInt in class Span<LocalDateTime>
    • createIntIntNb

      public jnr.ffi.Pointer createIntIntNb(Number lower, Number upper)
      Specified by:
      createIntIntNb in class Span<LocalDateTime>
    • copy

      public tstzspan copy()
      Return a copy of "this" object.

      MEOS Functions:

      • span_copy

      Returns:
      Instance of tstzspan class
    • from_hexwkb

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

      MEOS Functions:

      • span_from_hexwkb

      Parameters:
      hexwkb - : WKB representation in hex-encoded ASCII
      Returns:
      Instance of tstzspan class
    • toString

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

      MEOS Functions:

      • period_out

      Overrides:
      toString in class Object
      Returns:
      string instance
    • to_spanset

      public tstzspanset to_spanset()
      Returns a period set containing "this" object.

      MEOS Functions:

      • span_to_spanset

      Returns:
      tstzspanset instance
    • to_periodset

      public tstzspanset to_periodset()
      Returns a period set containing "this" object.

      MEOS Functions:

      • span_to_spanset

      Returns:
      tstzspanset instance
    • get_inner

      public jnr.ffi.Pointer get_inner()
      Specified by:
      get_inner in class Span<LocalDateTime>
    • lower_inc

      public boolean lower_inc()
      Returns whether the lower bound of the period is inclusive or not

      MEOS Functions:

      • span_lower_inc

      Overrides:
      lower_inc in class Span<LocalDateTime>
      Returns:
      true if the lower bound of the period is inclusive and false otherwise
    • upper_inc

      public boolean upper_inc()
      Returns whether the upper bound of the period is inclusive or not

      MEOS Functions:

    • span_upper_inc
    • Overrides:
      upper_inc in class Span<LocalDateTime>
      Returns:
      True if the upper bound of the period is inclusive and False otherwise
    • lower

      public LocalDateTime lower()
      Returns the lower bound of a period

      MEOS Functions:

    • period_lower
    • Specified by:
      lower in class Span<LocalDateTime>
      Returns:
      The lower bound of the period as a LocalDateTime
    • upper

      public LocalDateTime upper()
      Returns the upper bound of a period

      MEOS Functions:

    • period_upper
    • Specified by:
      upper in class Span<LocalDateTime>
      Returns:
      The upper bound of the period as a LocalDateTime
    • duration

      public Duration duration()
      Returns the duration of the period.

      MEOS Functions:

    • period_duration
    • Returns:
      timedelta instance representing the duration of the period
    • duration_in_second

      public long duration_in_second()
      Returns the duration of the period.

      MEOS Functions:

    • span_width
    • Returns:
      a float representing the duration of the period in seconds
    • hash

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

      MEOS Functions:

    • span_hash
    • Overrides:
      hash in class Span<LocalDateTime>
      Returns:
      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:
                   >>> tstzspan('[2012-01-01, 2012-01-02)').is_adjacent(tstzspan('[2012-01-02, 2012-01-03]'))
                   >>> True
                   >>> tstzspan('[2012-01-01, 2012-01-02]').is_adjacent(tstzspan('[2012-01-02, 2012-01-03]'))
                   >>> False  # Both contain bound
                   >>> tstzspan('[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_span_spanset
      • adjacent_period_timestamp
      • adjacent_period_timestampset
      • adjacent_period_temporal
      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 "container".
               Examples:
                   >>> tstzspan('[2012-01-02, 2012-01-03]').is_contained_in(tstzspan('[2012-01-01, 2012-01-04]'))
                   >>> True
                   >>> tstzspan('(2012-01-01, 2012-01-02)').is_contained_in(tstzspan('[2012-01-01, 2012-01-02]'))
                   >>> True
                   >>> tstzspan('[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_period_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 "this" temporally contains "other".
               Examples:
                   >>> tstzspan('[2012-01-01, 2012-01-04]').contains(tstzspan('[2012-01-02, 2012-01-03]'))
                   >>> True
                   >>> tstzspan('[2012-01-01, 2012-01-02]').contains(tstzspan('(2012-01-01, 2012-01-02)'))
                   >>> True
                   >>> tstzspan('(2012-01-01, 2012-01-02)').contains(tstzspan('[2012-01-01, 2012-01-02]'))
                   >>> False
        
      MEOS Functions:
      • contains_span_span
      • contains_span_spanset
      • contains_period_timestamp
      • contains_period_timestampset
      • contains_period_temporal
      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:
                   >>> tstzspan('[2012-01-01, 2012-01-02]').overlaps(tstzspan('[2012-01-02, 2012-01-03]'))
                   >>> True
                   >>> tstzspan('[2012-01-01, 2012-01-02)').overlaps(tstzspan('[2012-01-02, 2012-01-03]'))
                   >>> False
                   >>> tstzspan('[2012-01-01, 2012-01-02)').overlaps(tstzspan('(2012-01-02, 2012-01-03]'))
                   >>> False
      
      MEOS Functions:
      • overlaps_span_span
      • overlaps_span_spanset
      • overlaps_period_timestampset
      • overlaps_period_temporal
      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 "this" and the bounding period of "other" is the same.

      MEOS Functions:

      • same_period_temporal

      Parameters:
      other - temporal object to compare with
      Returns:
      true if equal, 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:
                   >>> tstzspan('[2012-01-01, 2012-01-02)').is_before(tstzspan('[2012-01-02, 2012-01-03]'))
                   >>> True
                   >>> tstzspan('[2012-01-01, 2012-01-02)').is_before(tstzspan('(2012-01-02, 2012-01-03]'))
                   >>> True
                   >>> tstzspan('[2012-01-01, 2012-01-02]').is_before(tstzspan('[2012-01-02, 2012-01-03]'))
                   >>> False
      
      MEOS Functions:
      • left_span_span
      • left_span_spanset
      • before_period_timestamp
      • before_period_timestampset
      • before_period_temporal
      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:
                   >>> tstzspan('[2012-01-01, 2012-01-02)').is_over_or_before(tstzspan('[2012-01-02, 2012-01-03]'))
                   >>> True
                   >>> tstzspan('[2012-01-01, 2012-01-02]').is_over_or_before(tstzspan('[2012-01-02, 2012-01-03]'))
                   >>> True
                   >>> tstzspan('[2012-01-03, 2012-01-05]').is_over_or_before(tstzspan('[2012-01-01, 2012-01-04]'))
                   >>> False
       
      MEOS Functions:
      • overleft_span_span
      • overleft_span_spanset
      • overbefore_period_timestamp
      • overbefore_period_timestampset
      • overbefore_period_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:
                   >>> tstzspan('[2012-01-02, 2012-01-03]').is_after(tstzspan('[2012-01-01, 2012-01-02)'))
                   >>> True
                   >>> tstzspan('(2012-01-02, 2012-01-03]').is_after(tstzspan('[2012-01-01, 2012-01-02)'))
                   >>> True
                   >>> tstzspan('[2012-01-02, 2012-01-03]').is_after(tstzspan('[2012-01-01, 2012-01-02]'))
                   >>> False
       
      MEOS Functions:
      • right_span_span
      • right_span_spanset
      • after_period_timestamp
      • after_period_timestampset
      • after_period_temporal
      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:
                   >>> tstzspan('[2012-01-02, 2012-01-03]').is_over_or_after(tstzspan('[2012-01-01, 2012-01-02)'))
                   >>> True
                   >>> tstzspan('[2012-01-02, 2012-01-03]').is_over_or_after(tstzspan('[2012-01-01, 2012-01-02]'))
                   >>> True
                   >>> tstzspan('[2012-01-02, 2012-01-03]').is_over_or_after(tstzspan('[2012-01-01, 2012-01-03]'))
                   >>> False
        
      MEOS Functions:
      • overright_span_span
      • overright_span_spanset
      • overafter_period_timestamp
      • overafter_period_timestampset
      • overafter_period_temporal
      Parameters:
      other - temporal object to compare with
      Returns:
      true if overlapping or after, false otherwise
      Throws:
      Exception
    • distance

      public double distance(TemporalObject other) throws Exception
      Returns the temporal distance between "this" and "other".

      MEOS Functions:

      • distance_span_span
      • distance_spanset_span
      • distance_period_timestamp

      Parameters:
      other - temporal object to compare with
      Returns:
      a timedelta instance
      Throws:
      Exception
    • intersection

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

      MEOS Functions:

      • intersection_span_span
      • intersection_spanset_span
      • intersection_period_timestamp

      Parameters:
      other - temporal object to intersect with
      Returns:
      Time instance. The actual class depends on "other".
      Throws:
      Exception
    • mul

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

      MEOS Functions:

      • intersection_span_span
      • intersection_spanset_span
      • intersection_period_timestamp

      Parameters:
      other - temporal object to intersect with
      Returns:
      Time instance. The actual class depends on "other".
      Throws:
      Exception
    • minus

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

      MEOS Functions:

      • minus_period_timestamp
      • minus_span_spanset
      • minus_span_span

      Parameters:
      other - temporal object to diff with
      Returns:
      tstzspanset instance
    • sub

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

      MEOS Functions:

      • minus_period_timestamp
      • minus_span_spanset
      • minus_span_span

      Parameters:
      other - temporal object to diff with
      Returns:
      tstzspanset instance
    • union

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

      MEOS Functions:

      • union_period_timestamp
      • union_spanset_span
      • union_span_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_period_timestamp
      • union_spanset_span
      • union_span_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:
      • span_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:

    • span_neq
    • 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:

      • span_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:

    • span_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:

    • span_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 "this" is greater than or equal to "other".

      MEOS Functions:

    • span_ge
    • Parameters:
      other - temporal object to compare with
      Returns:
      true if greater than or equal, false otherwise
      Throws:
      OperationNotSupportedException