- java.lang.Object
 - 
- com.pervasive.datarush.tokens.scalar.PeriodToken
 
 
- 
- All Implemented Interfaces:
 DataToken,PeriodValued,ScalarToken,ScalarValued,TokenValued,ScalarTyped,TokenTyped,Serializable,Comparable<PeriodToken>
public final class PeriodToken extends Object implements ScalarToken, Comparable<PeriodToken>
An immutablePeriodValuedobject.- See Also:
 - Serialized Form
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description static PeriodTokenNULLA null valuedPeriodTokenstatic PeriodTokenZEROA zero valuedPeriodTokenstatic PeriodZERO_VALUEThe period zero value,0. 
- 
Constructor Summary
Constructors Constructor Description PeriodToken(int years, int months, int days)Constructs a new token with the given non-null period value.PeriodToken(PeriodValued value)Constructs a new token with the period value in the given container.PeriodToken(Period value)Constructs a new token with the given non-null period value. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PeriodasPeriod()Gets the contained Period value as ajava.time.Period.intcompareTo(PeriodToken that)booleanequals(Object obj)Indicates whether another object is equal to this token.intgetDays()Gets the day portion of the contained period value.intgetMonths()Gets the month portion of the contained period value.ScalarTokenTypegetType()Gets the data type of the token.intgetYears()Gets the year portion of the contained period value.inthashCode()Returns a hash code for the token.booleanisNull()Indicates whether the token is null valued.booleanisZero()Indicates whether the value is the zero value for the type.static PeriodTokenparse(String value)Converts a string representation of a Period value into a token.StringtoString()- 
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 PeriodToken NULL
A null valuedPeriodToken 
- 
ZERO_VALUE
public static final Period ZERO_VALUE
The period zero value,0. 
- 
ZERO
public static final PeriodToken ZERO
A zero valuedPeriodToken 
 - 
 
- 
Constructor Detail
- 
PeriodToken
public PeriodToken(PeriodValued value)
Constructs a new token with the period value in the given container.- Parameters:
 value- aPeriodValuedcontaining the desired value
 
- 
PeriodToken
public PeriodToken(Period value)
Constructs a new token with the given non-null period value. If a null valued token is desired, useNULL.- Parameters:
 value- the period value of the token
 
- 
PeriodToken
public PeriodToken(int years, int months, int days)Constructs a new token with the given non-null period value. If a null valued token is desired, useNULL.- Parameters:
 years- the year portion of the periodmonths- the month portion of the perioddays- the day portion of the period
 
 - 
 
- 
Method Detail
- 
compareTo
public int compareTo(PeriodToken that)
- Specified by:
 compareToin interfaceComparable<PeriodToken>
 
- 
equals
public boolean equals(Object obj)
Description copied from interface:DataTokenIndicates 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 storeDataTokens inMaps. 
- 
hashCode
public int hashCode()
Description copied from interface:DataTokenReturns a hash code for the token. This value is guaranteed to be consistent with that returned byTokenConverter.asHashCode(TokenValued). 
- 
parse
public static PeriodToken parse(String value)
Converts a string representation of a Period value into a token.- Parameters:
 value- a string value to interpret as period; seePeriod#parse(String)- Returns:
 - a token with the specified value
 
 
- 
getType
public final ScalarTokenType getType()
Description copied from interface:TokenValuedGets the data type of the token. This type will dictate the valid values that can be contained.- Specified by:
 getTypein interfaceScalarTyped- Specified by:
 getTypein interfaceScalarValued- Specified by:
 getTypein interfaceTokenTyped- Specified by:
 getTypein interfaceTokenValued- Returns:
 - the token type.
 
 
- 
getYears
public int getYears()
Description copied from interface:PeriodValuedGets the year portion of the contained period value.- Specified by:
 getYearsin interfacePeriodValued- Returns:
 - the year portion of the contained value
 If null valued, as indicated by 
TokenValued.isNull(),0is returned. 
 
- 
getMonths
public int getMonths()
Description copied from interface:PeriodValuedGets the month portion of the contained period value. This does not include the year portion.- Specified by:
 getMonthsin interfacePeriodValued- Returns:
 - the month portion of the contained value
 If null valued, as indicated by 
TokenValued.isNull(),0is returned. 
 
- 
getDays
public int getDays()
Description copied from interface:PeriodValuedGets the day portion of the contained period value. This does not include the year or month portion.- Specified by:
 getDaysin interfacePeriodValued- Returns:
 - the day portion of the contained value
 If null valued, as indicated by 
TokenValued.isNull(),0is returned. 
 
- 
asPeriod
public final Period asPeriod()
Description copied from interface:PeriodValuedGets the contained Period value as ajava.time.Period.- Specified by:
 asPeriodin interfacePeriodValued- Returns:
 - the contained value as a 
java.time.Period. If null valued, as indicated byTokenValued.isNull(),nullis returned. 
 
- 
isZero
public final boolean isZero()
Description copied from interface:ScalarValuedIndicates whether the value is the zero value for the type. Zero values are not stored in sparse representation formats.- Specified by:
 isZeroin interfaceScalarValued- Returns:
 trueif the value is the zero value,falseotherwise.
 
- 
isNull
public final boolean isNull()
Description copied from interface:TokenValuedIndicates 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:
 isNullin interfaceTokenValued- Returns:
 trueif the token is null valued,falseotherwise
 
 - 
 
 -