- java.lang.Object
-
- com.pervasive.datarush.tokens.scalar.NullToken
-
- All Implemented Interfaces:
DataToken
,BinaryValued
,BooleanValued
,CharValued
,DateValued
,DoubleValued
,DurationValued
,FloatValued
,IntValued
,Ip4AddressValued
,Ip6AddressValued
,LongValued
,MoneyValued
,NumericValued
,PeriodValued
,ScalarToken
,ScalarValued
,StringValued
,TimestampValued
,TimeValued
,TokenValued
,ScalarTyped
,TokenTyped
,Serializable
,Comparable<NullToken>
public class NullToken extends Object implements ScalarToken, Comparable<NullToken>, BinaryValued, BooleanValued, CharValued, DateValued, IntValued, StringValued, TimeValued, TimestampValued, MoneyValued, DurationValued, PeriodValued, Ip4AddressValued, Ip6AddressValued
An null token.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static NullToken
NULL
A null valuedNullToken
-
Fields inherited from interface com.pervasive.datarush.tokens.scalar.NumericValued
MAX_INFINITY, MIN_INFINITY
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
NullToken()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
asAddress()
Gets the contained raw IPv4 address value.BigDecimal
asBigDecimal()
Gets the contained numeric value.byte[]
asBinary()
Gets the contained binary value.byte[]
asBinaryRef()
Gets a reference to the contained binary value.boolean
asBoolean()
Gets the contained boolean value.CalendarDate
asCalendarDate()
Gets the contained date value.long
asCents()
Gets the contained cents value as a longchar
asChar()
Gets the contained character value.Date
asDate()
Gets the contained date value as ajava.sql.Date
relative to the default time zone.Date
asDate(TimeZone tz)
Gets the contained date value as ajava.sql.Date
relative to the given time zone.int
asDayMillis()
Gets the contained time value as the number of milliseconds elapsed since midnight.double
asDouble()
Gets the contained double value.Duration
asDuration()
Gets the contained Duration value as ajava.time.Duration
.long
asEpochDays()
Gets the contained date value as the number of days since Java epoch (January 1, 1970).long
asEpochSecs()
Gets the contained timestamp value as the number of seconds since Java epoch (January 1, 1970 00:00:00 GMT).float
asFloat()
Gets the contained float value.Inet4Address
asInet4Address()
Gets the contained IP address as an Inet4Address.Inet6Address
asInet6Address()
Gets the contained IP address as an Inet6Address.int
asInt()
Gets the contained integer value.long
asLong()
Gets the contained long value.Period
asPeriod()
Gets the contained Period value as ajava.time.Period
.long
asSeconds()
Get the contained duration value as the number of seconds.String
asString()
Gets the contained string value.TimeOfDay
asTimeOfDay()
Gets the contained time value.Timestamp
asTimestamp()
Gets the contained timestamp value as ajava.sql.Timestamp
relative to the default time zone.int
compareTo(NullToken o)
boolean
equals(Object obj)
Indicates whether another object is equal to this token.int
getDays()
Gets the day portion of the contained period value.int
getMonths()
Gets the month portion of the contained period value.ScalarTokenType
getType()
Gets the data type of the token.int
getYears()
Gets the year portion of the contained period value.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.int
subsecNanos()
Gets the subsecond portion of the contained timestamp value.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.pervasive.datarush.tokens.TokenValued
isNull
-
-
-
-
Field Detail
-
NULL
public static final NullToken NULL
A null valuedNullToken
-
-
Method Detail
-
compareTo
public int compareTo(NullToken o)
- Specified by:
compareTo
in interfaceComparable<NullToken>
-
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)
.
-
getType
public 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.
-
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.
-
asDouble
public double asDouble()
Description copied from interface:DoubleValued
Gets the contained double value.- Specified by:
asDouble
in interfaceDoubleValued
- Returns:
- the contained value as a
double
. If null valued, as indicated byTokenValued.isNull()
,Double.NaN
is returned.
-
asBigDecimal
public BigDecimal asBigDecimal()
Description copied from interface:NumericValued
Gets the contained numeric value.- Specified by:
asBigDecimal
in interfaceNumericValued
- Returns:
- the contained value as a
java.math.BigDecimal
. If null valued, as indicated byTokenValued.isNull()
,null
is returned.
-
asLong
public long asLong()
Description copied from interface:LongValued
Gets the contained long value.- Specified by:
asLong
in interfaceLongValued
- Returns:
- the contained value as a
long
. If null valued, as indicated byTokenValued.isNull()
,0
is returned.
-
asFloat
public float asFloat()
Description copied from interface:FloatValued
Gets the contained float value.- Specified by:
asFloat
in interfaceFloatValued
- Returns:
- the contained value as a
float
. If null valued, as indicated byTokenValued.isNull()
,Float.NaN
is returned.
-
asTimestamp
public 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.
-
asEpochSecs
public 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 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 interfaceDurationValued
- 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 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()
-
asDayMillis
public int asDayMillis()
Description copied from interface:TimeValued
Gets the contained time value as the number of milliseconds elapsed since midnight.- Specified by:
asDayMillis
in interfaceTimeValued
- Returns:
- the contained value as milliseconds since midnight.
If null valued, as indicated by
TokenValued.isNull()
,0
is returned.
-
asTimeOfDay
public TimeOfDay asTimeOfDay()
Description copied from interface:TimeValued
Gets the contained time value. This value represents the timezone free time portion of a timestamp.- Specified by:
asTimeOfDay
in interfaceTimeValued
- Returns:
- the contained value.
If null valued, as indicated by
TokenValued.isNull()
,null
is returned.
-
asString
public String asString()
Description copied from interface:StringValued
Gets the contained string value.- Specified by:
asString
in interfaceStringValued
- Returns:
- the contained value as a
String
. If null valued, as indicated byTokenValued.isNull()
, the empty string (""
) is returned.
-
asInt
public int asInt()
Description copied from interface:IntValued
Gets the contained integer value.- Specified by:
asInt
in interfaceIntValued
- Returns:
- the contained value as an
int
. If null valued, as indicated byTokenValued.isNull()
,0
is returned.
-
asDate
public Date asDate()
Description copied from interface:DateValued
Gets the contained date value as ajava.sql.Date
relative to the default time zone. The time zone used byTimeZone.getDefault()
is used.- Specified by:
asDate
in interfaceDateValued
- Returns:
- the contained value as a
java.sql.Date
. If null valued, as indicated byTokenValued.isNull()
,null
is returned.
-
asDate
public Date asDate(TimeZone tz)
Description copied from interface:DateValued
Gets the contained date value as ajava.sql.Date
relative to the given time zone.- Specified by:
asDate
in interfaceDateValued
- Parameters:
tz
- the time zone in which to interpret the date- Returns:
- the contained value as a
java.sql.Date
. If null valued, as indicated byTokenValued.isNull()
,null
is returned.
-
asEpochDays
public long asEpochDays()
Description copied from interface:DateValued
Gets the contained date value as the number of days since Java epoch (January 1, 1970).- Specified by:
asEpochDays
in interfaceDateValued
- Returns:
- the contained value as days since Java epoch.
If null valued, as indicated by
TokenValued.isNull()
,0
is returned.
-
asCalendarDate
public CalendarDate asCalendarDate()
Description copied from interface:DateValued
Gets the contained date value. This value represents the timezone free date portion of a timestamp.- Specified by:
asCalendarDate
in interfaceDateValued
- Returns:
- the contained value as a calendar date.
If null valued, as indicated by
TokenValued.isNull()
,null
is returned.
-
asChar
public char asChar()
Description copied from interface:CharValued
Gets the contained character value.- Specified by:
asChar
in interfaceCharValued
- Returns:
- the contained value as a
char
. If null valued, as indicated byTokenValued.isNull()
,Character.MAX_VALUE
is returned.
-
asBoolean
public boolean asBoolean()
Description copied from interface:BooleanValued
Gets the contained boolean value.- Specified by:
asBoolean
in interfaceBooleanValued
- Returns:
- the contained value as a
boolean
. If null valued, as indicated byTokenValued.isNull()
,false
is returned.
-
asBinary
public byte[] asBinary()
Description copied from interface:BinaryValued
Gets the contained binary value.The array returned is a copy of the binary data contained in the object. To avoid this overhead, use
BinaryValued.asBinaryRef()
instead.- Specified by:
asBinary
in interfaceBinaryValued
- Returns:
- the contained value as a
byte[]
. If null valued, as indicated byTokenValued.isNull()
,null
is returned.
-
asBinaryRef
public byte[] asBinaryRef()
Description copied from interface:BinaryValued
Gets a reference to the contained binary value.While this call avoids the overhead seen with
BinaryValued.asBinary()
, the caller must guarantee that the returned array will not be modified. Failure to comply may result in the dataflow exhibiting unexpected behavior, as other operators may (or may not) see the modified value.- Specified by:
asBinaryRef
in interfaceBinaryValued
- Returns:
- a reference to the
byte[]
holding the contained value. If null valued, as indicated byTokenValued.isNull()
,null
is returned.
-
asInet4Address
public Inet4Address asInet4Address()
Description copied from interface:Ip4AddressValued
Gets the contained IP address as an Inet4Address.- Specified by:
asInet4Address
in interfaceIp4AddressValued
- Returns:
- the contained value as a
Inet4Address
. If null valued, as indicated byTokenValued.isNull()
,null
is returned.
-
asInet6Address
public Inet6Address asInet6Address()
Description copied from interface:Ip6AddressValued
Gets the contained IP address as an Inet6Address.- Specified by:
asInet6Address
in interfaceIp6AddressValued
- Returns:
- the contained value as a
Inet6Address
. If null valued, as indicated byTokenValued.isNull()
,null
is returned.
-
asAddress
public byte[] asAddress()
Description copied from interface:Ip4AddressValued
Gets the contained raw IPv4 address value. The array returned is a copy of the binary data contained in the object.- Specified by:
asAddress
in interfaceIp4AddressValued
- Specified by:
asAddress
in interfaceIp6AddressValued
- Returns:
- the contained value as a
byte[4]
. If null valued, as indicated byTokenValued.isNull()
,null
is returned.
-
asPeriod
public Period asPeriod()
Description copied from interface:PeriodValued
Gets the contained Period value as ajava.time.Period
.- Specified by:
asPeriod
in interfacePeriodValued
- Returns:
- the contained value as a
java.time.Period
. If null valued, as indicated byTokenValued.isNull()
,null
is returned.
-
getYears
public int getYears()
Description copied from interface:PeriodValued
Gets the year portion of the contained period value.- Specified by:
getYears
in interfacePeriodValued
- Returns:
- the year portion of the contained value
If null valued, as indicated by
TokenValued.isNull()
,0
is returned.
-
getMonths
public int getMonths()
Description copied from interface:PeriodValued
Gets the month portion of the contained period value. This does not include the year portion.- Specified by:
getMonths
in interfacePeriodValued
- Returns:
- the month portion of the contained value
If null valued, as indicated by
TokenValued.isNull()
,0
is returned.
-
getDays
public int getDays()
Description copied from interface:PeriodValued
Gets the day portion of the contained period value. This does not include the year or month portion.- Specified by:
getDays
in interfacePeriodValued
- Returns:
- the day portion of the contained value
If null valued, as indicated by
TokenValued.isNull()
,0
is returned.
-
asDuration
public Duration asDuration()
Description copied from interface:DurationValued
Gets the contained Duration value as ajava.time.Duration
.- Specified by:
asDuration
in interfaceDurationValued
- Returns:
- the contained value as a
java.time.Duration
. If null valued, as indicated byTokenValued.isNull()
,null
is returned.
-
asSeconds
public long asSeconds()
Description copied from interface:DurationValued
Get the contained duration value as the number of seconds.- Specified by:
asSeconds
in interfaceDurationValued
- Returns:
- the contained value as seconds.
If null valued, as indicated by
TokenValued.isNull()
,0
is returned. - See Also:
DurationValued.subsecNanos()
-
asCents
public long asCents()
Description copied from interface:MoneyValued
Gets the contained cents value as a long- Specified by:
asCents
in interfaceMoneyValued
- Returns:
- the contained cents value as a
long
. If null valued, as indicated byTokenValued.isNull()
,0
is returned.
-
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
-
-