- 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 immutableTimestampValued
object.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static TimestampToken
NULL
A null valuedTimestampToken
static TimestampToken
ZERO
A zero valuedTimestampToken
-
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).TimestampToken(TimestampValued value)
Constructs a new token with the timestamp value in the given container.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
asEpochSecs()
Gets the contained timestamp value as the number of seconds since Java epoch (January 1, 1970 00:00:00 GMT).Timestamp
asTimestamp()
Gets the contained timestamp value as ajava.sql.Timestamp
relative to the default time zone.int
compareTo(TimestampToken that)
boolean
equals(Object obj)
Indicates whether another object is equal to this token.protected com.pervasive.datarush.tokens.scalar.TimestampParser
getParser()
Get the cached parser used by this object.ScalarTokenType
getType()
Gets the data type of the token.int
hashCode()
Returns a hash code for the token.boolean
isNull()
Indicates whether the token is null valued.boolean
isZero()
Indicates whether the value is the zero value for the type.int
offsetSecs()
Gets the time zone and daylight saving time offset of the contained timestamp value, in seconds.static TimestampToken
parse(String value)
Converts a string representation of a timestamp value into a token.int
subsecNanos()
Gets the subsecond portion of the contained timestamp value.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.pervasive.datarush.tokens.scalar.ScalarValued
getType, isZero
-
Methods inherited from interface com.pervasive.datarush.tokens.TokenValued
isNull
-
-
-
-
Field Detail
-
NULL
public static final TimestampToken NULL
A null valuedTimestampToken
-
ZERO
public static final TimestampToken ZERO
A zero valuedTimestampToken
-
-
Constructor Detail
-
TimestampToken
public TimestampToken(TimestampValued value)
Constructs a new token with the timestamp value in the given container.- Parameters:
value
- aTimestampValued
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, useNULL
.- Parameters:
epochSecs
- number of seconds since Java epochsubsecNanos
- fractional portion of epoch time in nanosecondsoffsetSecs
- time zone and daylight saving time offset in seconds
-
-
Method Detail
-
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 ofTokenComparator.equal(TokenValued,TokenValued)
but makes it possible to storeDataToken
s inMap
s.
-
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 byTokenConverter.asHashCode(TokenValued)
.
-
compareTo
public int compareTo(TimestampToken that)
- Specified by:
compareTo
in interfaceComparable<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 interfaceScalarTyped
- Specified by:
getType
in interfaceScalarValued
- Specified by:
getType
in interfaceTokenTyped
- Specified by:
getType
in interfaceTokenValued
- 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, usesubsecNanos()
in conjunction with this method.- Specified by:
asEpochSecs
in interfaceTimestampValued
- Returns:
- the contained value as days since Java epoch.
If null valued, as indicated by
TokenValued.isNull()
,0
is returned. - See Also:
TimestampValued.subsecNanos()
-
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 byasEpochSecs()
. Thus the valueasEpochSecs() * 1000000000 + subsecNanos()
represents the number of nanoseconds since Java epoch.- Specified by:
subsecNanos
in interfaceTimestampValued
- Returns:
- the subsecond portion of the contained value, in
nanoseconds. If null valued, as indicated by
TokenValued.isNull()
,0
is returned. - See Also:
TimestampValued.asEpochSecs()
-
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 interfaceTimestampValued
- 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:
TimestampValued.asEpochSecs()
-
asTimestamp
public final Timestamp asTimestamp()
Description copied from interface:TimestampValued
Gets the contained timestamp value as ajava.sql.Timestamp
relative to the default time zone. The time zone used byTimeZone#getDefault()
is used.- Specified by:
asTimestamp
in interfaceTimestampValued
- Returns:
- the contained value as a
java.sql.Timestamp
. If null valued, as indicated byTokenValued.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
-
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 interfaceScalarValued
- 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 interfaceTokenValued
- Returns:
true
if the token is null valued,false
otherwise
-
-