Class ElementPosition

java.lang.Object
net.time4j.format.expert.ElementPosition

public final class ElementPosition extends Object

Represents a position information of a chronological element with a formatted text.

Since:
3.0
Author:
Meno Hochschild
  • Constructor Details

    • ElementPosition

      public ElementPosition(ChronoElement<?> element, int startIndex, int endIndex)

      Creates a new instance of an ElementPosition.

      The section text.substring(startIndex, endIndex) of the formatted text referring to given element denotes the element-specific text.

      Parameters:
      element - chronological element
      startIndex - index in formatted text which indicates the starting position of associated element (inclusive)
      endIndex - index in formatted text which indicates the end position of associated element (exclusive)
      Throws:
      IllegalArgumentException - if the start index is negative or after the end index
  • Method Details

    • getElement

      public ChronoElement<?> getElement()

      Yields the formatted chronolocial element.

      Returns:
      ChronoElement
    • getStartIndex

      public int getStartIndex()

      Yields the start index of associated formatted text.

      Returns:
      int
    • getEndIndex

      public int getEndIndex()

      Yields the end index of associated formatted text.

      Returns:
      int
    • equals

      public boolean equals(Object obj)

      Compares element, start index and end index.

      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()

      For debugging purposes.

      Overrides:
      toString in class Object