Package com.yahoo.document.annotation
Class Span
- java.lang.Object
-
- com.yahoo.document.annotation.SpanNode
-
- com.yahoo.document.annotation.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 throwIllegalArgumentException
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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.ListIterator<SpanNode>
childIterator()
Returns a ListIterator that iterates over absolutely nothing.java.util.ListIterator<SpanNode>
childIteratorRecursive()
Returns a ListIterator that iterates over absolutely nothing.int
getFrom()
Returns the character index where this SpanNode starts (inclusive).int
getLength()
Returns the length of this span, i.e. getFrom() - getTo().java.lang.CharSequence
getText(java.lang.CharSequence text)
Returns the text that is covered by this SpanNode.int
getTo()
Returns the character index where this SpanNode ends (exclusive).boolean
isLeafNode()
Always returns true.void
setFrom(int from)
NOTE: DO NOT USE.void
setLength(int length)
NOTE: DO NOT USE.java.lang.String
toString()
-
Methods inherited from class com.yahoo.document.annotation.SpanNode
annotate, annotate, annotate, annotate, annotate, compareTo, contains, equals, getParent, getScratchId, getSpanTree, getStringFieldValue, hashCode, isValid, overlaps, setScratchId
-
-
-
-
Field Detail
-
ID
public static final byte ID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Span
public Span(int from, int length)
This will construct a valid span or throwIllegalArgumentException
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).
-
setFrom
public void setFrom(int from)
NOTE: DO NOT USE. Should only be used bySpanNodeReader
.- 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).
-
getLength
public final int getLength()
Description copied from class:SpanNode
Returns the length of this span, i.e. getFrom() - getTo().
-
setLength
public void setLength(int length)
NOTE: DO NOT USE. Should only be used bySpanNodeReader
.- Parameters:
length
- the length value to set
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.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.
-
isLeafNode
public boolean isLeafNode()
Always returns true.- Specified by:
isLeafNode
in classSpanNode
- Returns:
- always true.
-
childIterator
public java.util.ListIterator<SpanNode> childIterator()
Returns a ListIterator that iterates over absolutely nothing.- Specified by:
childIterator
in classSpanNode
- 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 classSpanNode
- Returns:
- a ListIterator that iterates over absolutely nothing.
-
-