Class TimestampToken

java.lang.Object
com.pervasive.datarush.tokens.scalar.TimestampToken
All Implemented Interfaces:
DataToken, ScalarToken, ScalarValued, TimestampValued, TokenValued, ScalarTyped, TokenTyped, Serializable, Comparable<TimestampToken>

public final class TimestampToken extends Object implements ScalarToken, Comparable<TimestampToken>
An immutable TimestampValued object.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final TimestampToken
    A null valued TimestampToken
    static final TimestampToken
    A zero valued TimestampToken
  • Constructor Summary

    Constructors
    Constructor
    Description
    TimestampToken(long epochSecs, int subsecNanos, int offsetSecs)
    Constructs a new token with the non-null timestamp value specified as the number of seconds since Java epoch (January 1, 1970 00:00:00 GMT).
    Constructs a new token with the timestamp value in the given container.
  • Method Summary

    Modifier and Type
    Method
    Description
    final long
    Gets the contained timestamp value as the number of seconds since Java epoch (January 1, 1970 00:00:00 GMT).
    final Timestamp
    Gets the contained timestamp value as a java.sql.Timestamp relative to the default time zone.
    int
     
    boolean
    Indicates whether another object is equal to this token.
    protected com.pervasive.datarush.tokens.scalar.TimestampParser
    Get the cached parser used by this object.
    Gets the data type of the token.
    int
    Returns a hash code for the token.
    final boolean
    Indicates whether the token is null valued.
    boolean
    Indicates whether the value is the zero value for the type.
    final int
    Gets the time zone and daylight saving time offset of the contained timestamp value, in seconds.
    parse(String value)
    Converts a string representation of a timestamp value into a token.
    final int
    Gets the subsecond portion of the contained timestamp value.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.pervasive.datarush.tokens.DataToken

    toString

    Methods inherited from interface com.pervasive.datarush.tokens.scalar.ScalarValued

    getType, isZero

    Methods inherited from interface com.pervasive.datarush.tokens.TokenValued

    isNull
  • Field Details

    • NULL

      public static final TimestampToken NULL
      A null valued TimestampToken
    • ZERO

      public static final TimestampToken ZERO
      A zero valued TimestampToken
  • Constructor Details

    • TimestampToken

      public TimestampToken(TimestampValued value)
      Constructs a new token with the timestamp value in the given container.
      Parameters:
      value - a TimestampValued containing the desired value
    • TimestampToken

      public TimestampToken(long epochSecs, int subsecNanos, int offsetSecs)
      Constructs a new token with the non-null timestamp value specified as the number of seconds since Java epoch (January 1, 1970 00:00:00 GMT). Nanosecond precision and originating time zone and daylight saving time offset information may also be provided. If a null valued token is desired, use NULL.
      Parameters:
      epochSecs - number of seconds since Java epoch
      subsecNanos - fractional portion of epoch time in nanoseconds
      offsetSecs - time zone and daylight saving time offset in seconds
  • Method Details

    • equals

      public boolean equals(Object obj)
      Description copied from interface: DataToken
      Indicates whether another object is equal to this token. Two null valued tokens are considered equal. This differs from the behavior of TokenComparator.equal(TokenValued,TokenValued) but makes it possible to store DataTokens in Maps.
      Specified by:
      equals in interface DataToken
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare
      Returns:
      true if the other object is a token of the same type and contains the same value, false otherwise.
    • hashCode

      public int hashCode()
      Description copied from interface: DataToken
      Returns a hash code for the token. This value is guaranteed to be consistent with that returned by TokenConverter.asHashCode(TokenValued).
      Specified by:
      hashCode in interface DataToken
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for the token
    • compareTo

      public int compareTo(TimestampToken that)
      Specified by:
      compareTo in interface Comparable<TimestampToken>
    • parse

      public static TimestampToken parse(String value)
      Converts a string representation of a timestamp value into a token.
      Parameters:
      value - a string value to interpret as a timestamp; this must be in ISO8601 format.
      Returns:
      a token with the specified value
    • getType

      public final ScalarTokenType getType()
      Description copied from interface: TokenValued
      Gets the data type of the token. This type will dictate the valid values that can be contained.
      Specified by:
      getType in interface ScalarTyped
      Specified by:
      getType in interface ScalarValued
      Specified by:
      getType in interface TokenTyped
      Specified by:
      getType in interface TokenValued
      Returns:
      the token type.
    • asEpochSecs

      public final long asEpochSecs()
      Description copied from interface: TimestampValued
      Gets the contained timestamp value as the number of seconds since Java epoch (January 1, 1970 00:00:00 GMT). Timestamp values support nanosecond precision, although this method does not expose it. To access this level of detail, use subsecNanos() in conjunction with this method.
      Specified by:
      asEpochSecs in interface TimestampValued
      Returns:
      the contained value as days since Java epoch. If null valued, as indicated by TokenValued.isNull(), 0 is returned.
      See Also:
    • subsecNanos

      public final int subsecNanos()
      Description copied from interface: TimestampValued
      Gets the subsecond portion of the contained timestamp value. The value returned is relative to the seconds value returned by asEpochSecs(). Thus the value asEpochSecs() * 1000000000 + subsecNanos() represents the number of nanoseconds since Java epoch.
      Specified by:
      subsecNanos in interface TimestampValued
      Returns:
      the subsecond portion of the contained value, in nanoseconds. If null valued, as indicated by TokenValued.isNull(), 0 is returned.
      See Also:
    • offsetSecs

      public final int offsetSecs()
      Description copied from interface: TimestampValued
      Gets the time zone and daylight saving time offset of the contained timestamp value, in seconds.
      Specified by:
      offsetSecs in interface TimestampValued
      Returns:
      the time zone and daylight saving time offset of the contained value, in seconds. If null valued, as indicated by TokenValued.isNull(), 0 is returned.
      See Also:
    • asTimestamp

      public final Timestamp asTimestamp()
      Description copied from interface: TimestampValued
      Gets the contained timestamp value as a java.sql.Timestamp relative to the default time zone. The time zone used by TimeZone#getDefault() is used.
      Specified by:
      asTimestamp in interface TimestampValued
      Returns:
      the contained value as a java.sql.Timestamp. If null valued, as indicated by TokenValued.isNull(), null is returned.
    • getParser

      protected com.pervasive.datarush.tokens.scalar.TimestampParser getParser()
      Get the cached parser used by this object.
      Returns:
      the cached parser
    • toString

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

      public boolean isZero()
      Description copied from interface: ScalarValued
      Indicates whether the value is the zero value for the type. Zero values are not stored in sparse representation formats.
      Specified by:
      isZero in interface ScalarValued
      Returns:
      true if the value is the zero value, false otherwise.
    • isNull

      public final boolean isNull()
      Description copied from interface: TokenValued
      Indicates whether the token is null valued. Tokens support null values analogous to SQL. Before accessing the value of the container, it is usually best to ensure it is not null valued using this method.
      Specified by:
      isNull in interface TokenValued
      Returns:
      true if the token is null valued, false otherwise