Package org.apache.commons.lang3.time
Class DurationFormatUtils.Token
java.lang.Object
org.apache.commons.lang3.time.DurationFormatUtils.Token
- Enclosing class:
- DurationFormatUtils
Element that is parsed from the format pattern.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate static final DurationFormatUtils.Token[]Empty array.private final StringBuilderprivate final intprivate final DurationFormatUtils.Unit -
Constructor Summary
ConstructorsConstructorDescriptionToken(StringBuilder literal, boolean optional, int optionalIndex) Wraps a token around literal text.Token(DurationFormatUtils.Unit value, boolean optional, int optionalIndex) Wraps a token around a duration unit. -
Method Summary
Modifier and TypeMethodDescription(package private) static booleancontainsTokenWithValue(DurationFormatUtils.Token[] tokens, DurationFormatUtils.Unit value) Determines whether a set of tokens contains a duration unit.booleanSupports equality of this Token to another Token.(package private) intgetCount()Gets the current number of values represented.(package private) DurationFormatUtils.UnitgetValue()Gets the duration unit this token represents.inthashCode()Computes a hash code from the duration unit or literal text, excluding the repetition count.(package private) voidAdds another one of the value.toString()Represents this token as a String.
-
Field Details
-
EMPTY_ARRAY
Empty array. -
value
-
literal
-
count
private int count -
optionalIndex
private final int optionalIndex
-
-
Constructor Details
-
Token
Token(StringBuilder literal, boolean optional, int optionalIndex) Wraps a token around literal text.- Parameters:
literal- literal text to wrap, non-null.optional- whether the token is optional.optionalIndex- The index of the optional token within the pattern.
-
Token
Token(DurationFormatUtils.Unit value, boolean optional, int optionalIndex) Wraps a token around a duration unit.- Parameters:
value- duration unit to wrap, non-null.optional- whether the token is optional.optionalIndex- The index of the optional token within the pattern.
-
-
Method Details
-
containsTokenWithValue
static boolean containsTokenWithValue(DurationFormatUtils.Token[] tokens, DurationFormatUtils.Unit value) Determines whether a set of tokens contains a duration unit.- Parameters:
tokens- set to search.value- duration unit to find.- Returns:
- boolean
trueif contained.
-
equals
Supports equality of this Token to another Token. -
getCount
int getCount()Gets the current number of values represented.- Returns:
- int number of values represented.
-
getValue
DurationFormatUtils.Unit getValue()Gets the duration unit this token represents.- Returns:
- the duration unit, or null for a literal token.
-
hashCode
public int hashCode()Computes a hash code from the duration unit or literal text, excluding the repetition count. -
increment
void increment()Adds another one of the value. -
toString
Represents this token as a String.
-