Package com.yahoo.document.annotation
Class Span
java.lang.Object
com.yahoo.document.annotation.SpanNode
com.yahoo.document.annotation.Span
- All Implemented Interfaces:
SpanNodeParent
,Comparable<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
-
Constructor Summary
ConstructorDescriptionSpan()
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.Copies the given Span into a new Span instance.Span
(SpanNodeReader reader) Creates an empty Span, used mainly for deserialization. -
Method Summary
Modifier and TypeMethodDescriptionReturns a ListIterator that iterates over absolutely nothing.Returns a ListIterator that iterates over absolutely nothing.final int
getFrom()
Returns the character index where this SpanNode starts (inclusive).final int
Returns the length of this span, i.e. getFrom() - getTo().final CharSequence
getText
(CharSequence text) Returns the text that is covered by this SpanNode.final int
getTo()
Returns the character index where this SpanNode ends (exclusive).boolean
Always returns true.void
setFrom
(int from) NOTE: DO NOT USE.void
setLength
(int length) NOTE: DO NOT USE.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 Details
-
ID
public static final byte ID- See Also:
-
-
Constructor Details
-
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:
IllegalArgumentException
- if illegal span
-
Span
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
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). -
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
-
getText
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
Returns a ListIterator that iterates over absolutely nothing.- Specified by:
childIterator
in classSpanNode
- Returns:
- a ListIterator that iterates over absolutely nothing.
-
childIteratorRecursive
Returns a ListIterator that iterates over absolutely nothing.- Specified by:
childIteratorRecursive
in classSpanNode
- Returns:
- a ListIterator that iterates over absolutely nothing.
-