Class DurationFormatUtils.Token

java.lang.Object
org.apache.commons.lang3.time.DurationFormatUtils.Token
Enclosing class:
DurationFormatUtils

static class DurationFormatUtils.Token extends Object
Element that is parsed from the format pattern.
  • Field Details

    • EMPTY_ARRAY

      private static final DurationFormatUtils.Token[] EMPTY_ARRAY
      Empty array.
    • value

      private final CharSequence value
    • count

      private int count
    • optionalIndex

      private int optionalIndex
  • Constructor Details

    • Token

      Token(CharSequence value, boolean optional, int optionalIndex)
      Wraps a token around a value. A value would be something like a 'Y'.
      Parameters:
      value - value 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, Object value)
      Helper method to determine if a set of tokens contain a value
      Parameters:
      tokens - set to look in
      value - to look for
      Returns:
      boolean true if contained
    • equals

      public boolean equals(Object obj2)
      Supports equality of this Token to another Token.
      Overrides:
      equals in class Object
      Parameters:
      obj2 - Object to consider equality of
      Returns:
      boolean true if equal
    • getCount

      int getCount()
      Gets the current number of values represented
      Returns:
      int number of values represented
    • getValue

      Object getValue()
      Gets the particular value this token represents.
      Returns:
      Object value, non-null.
    • hashCode

      public int hashCode()
      Returns a hash code for the token equal to the hash code for the token's value. Thus 'TT' and 'TTTT' will have the same hash code.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code for the token
    • increment

      void increment()
      Adds another one of the value
    • toString

      public String toString()
      Represents this token as a String.
      Overrides:
      toString in class Object
      Returns:
      String representation of the token