Class Span

  • All Implemented Interfaces:
    SpanNodeParent, java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      static byte ID  
    • Constructor Summary

      Constructors 
      Constructor Description
      Span()
      WARNING! Only to be used by deserializers! Creates an empty Span instance.
      Span​(int from, int length)
      This will construct a valid span or throw IllegalArgumentException if the span is invalid.
      Span​(Span spanToCopy)
      Copies the given Span into a new Span instance.
      Span​(SpanNodeReader reader)
      Creates an empty Span, used mainly for deserialization.
    • Constructor Detail

      • 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:
        java.lang.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 Detail

      • 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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getText

        public final java.lang.CharSequence getText​(java.lang.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 java.util.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 java.util.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.