Class Span

java.lang.Object
com.yahoo.document.annotation.SpanNode
com.yahoo.document.annotation.Span
All Implemented Interfaces:
SpanNodeParent, Comparable<SpanNode>

public class Span extends SpanNode
This class represents a range of characters from a string. This is the leaf node in a Span tree. Its boundaries are defined as inclusive-from and exclusive-to.
Author:
baldersheim, Einar M R Rosenvinge
  • Field Details

  • Constructor Details

    • Span

      public Span(int from, int length)
      This will construct a valid span or throw IllegalArgumentException if the span is invalid.
      Parameters:
      from - Start of the span. Must be >= 0.
      length - of the span. Must be >= 0.
      Throws:
      IllegalArgumentException - if illegal span
    • Span

      public Span(SpanNodeReader reader)
      Creates an empty Span, used mainly for deserialization.
      Parameters:
      reader - the reader that must populate this Span instance
    • Span

      public Span()
      WARNING! Only to be used by deserializers! Creates an empty Span instance.
    • Span

      public Span(Span spanToCopy)
      Copies the given Span into a new Span instance.
      Parameters:
      spanToCopy - the Span to copy.
  • Method Details

    • getFrom

      public final int getFrom()
      Description copied from class: SpanNode
      Returns the character index where this SpanNode starts (inclusive).
      Specified by:
      getFrom in class SpanNode
      Returns:
      the character index where this SpanNode starts (inclusive).
    • setFrom

      public void setFrom(int from)
      NOTE: DO NOT USE. Should only be used by SpanNodeReader.
      Parameters:
      from - the from value to set
    • getTo

      public final int getTo()
      Description copied from class: SpanNode
      Returns the character index where this SpanNode ends (exclusive).
      Specified by:
      getTo in class SpanNode
      Returns:
      the character index where this SpanNode ends (exclusive).
    • getLength

      public final int getLength()
      Description copied from class: SpanNode
      Returns the length of this span, i.e. getFrom() - getTo().
      Specified by:
      getLength in class SpanNode
      Returns:
      the length of this span
    • setLength

      public void setLength(int length)
      NOTE: DO NOT USE. Should only be used by SpanNodeReader.
      Parameters:
      length - the length value to set
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getText

      public final CharSequence getText(CharSequence text)
      Description copied from class: SpanNode
      Returns the text that is covered by this SpanNode.
      Specified by:
      getText in class SpanNode
      Parameters:
      text - the input text
      Returns:
      the text that is covered by this SpanNode.
    • isLeafNode

      public boolean isLeafNode()
      Always returns true.
      Specified by:
      isLeafNode in class SpanNode
      Returns:
      always true.
    • childIterator

      public ListIterator<SpanNode> childIterator()
      Returns a ListIterator that iterates over absolutely nothing.
      Specified by:
      childIterator in class SpanNode
      Returns:
      a ListIterator that iterates over absolutely nothing.
    • childIteratorRecursive

      public ListIterator<SpanNode> childIteratorRecursive()
      Returns a ListIterator that iterates over absolutely nothing.
      Specified by:
      childIteratorRecursive in class SpanNode
      Returns:
      a ListIterator that iterates over absolutely nothing.