Package com.yahoo.document.annotation
Class SpanList
java.lang.Object
com.yahoo.document.annotation.SpanNode
com.yahoo.document.annotation.SpanList
- All Implemented Interfaces:
SpanNodeParent,Comparable<SpanNode>
- Direct Known Subclasses:
AlternateSpanList
A node in a Span tree that can have child nodes.
- Author:
- Einar M R Rosenvinge
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a child node to this SpanList.Traverses all immediate children of this SpanList.Recursively traverses all children (not only leaf nodes) of this SpanList, in a depth-first fashion.children()Returns a modifiable list of the immediate children of this SpanList.voidRemoves and invalidates all references to child nodes.booleanintgetFrom()Returns the character index where thisSpanNodestarts (inclusive), i.e. the smallestSpanNode.getFrom()of all children.intReturns the length of this span, i.e. getFrom() - getTo().getText(CharSequence text) Returns the text that is covered by this SpanNode.intgetTo()Returns the character index where thisSpanNodeends (exclusive), i.e. the greatestSpanNode.getTo()of all children.inthashCode()booleanAlways returns false, even if this node has no children.voidmove(int nodeNum, AlternateSpanList target, int targetSubTree) Moves a child of this SpanList to another SpanList.voidMoves a child of this SpanList to another SpanList.voidmove(SpanNode node, AlternateSpanList target, int targetSubTree) Moves a child of this SpanList to another SpanList.voidMoves a child of this SpanList to another SpanList.intReturns the number of children this SpanList holds.remove(int i) Removes and invalidates the SpanNode at the given index from this.Removes and invalidates the given SpanNode from this.voidSorts children by occurrence in the text covered.voidRecursively sorts all children by occurrence in the text covered.span(int from, int length) Create a span, add it to this list and return ittoString()Methods inherited from class com.yahoo.document.annotation.SpanNode
annotate, annotate, annotate, annotate, annotate, compareTo, contains, getParent, getScratchId, getSpanTree, getStringFieldValue, isValid, overlaps, setScratchId
-
Field Details
-
ID
public static final byte ID- See Also:
-
-
Constructor Details
-
SpanList
public SpanList()Creates a new SpanList. -
SpanList
-
SpanList
-
SpanList
Deep-copies a SpanList.- Parameters:
other- the SpanList to copy.
-
-
Method Details
-
add
Adds a child node to this SpanList.- Parameters:
node- the node to add.- Returns:
- this, for call chaining
- Throws:
IllegalStateException- if SpanNode.isValid() returns false.
-
span
Create a span, add it to this list and return it -
move
Moves a child of this SpanList to another SpanList.- Parameters:
node- the node to movetarget- the SpanList to add the node to- Throws:
IllegalArgumentException- if the given node is not a child of this SpanList
-
move
Moves a child of this SpanList to another SpanList.- Parameters:
nodeNum- the index of the node to movetarget- the SpanList to add the node to- Throws:
IndexOutOfBoundsException- if the given index is out of range
-
move
Moves a child of this SpanList to another SpanList.- Parameters:
node- the node to movetarget- the SpanList to add the node totargetSubTree- the index of the subtree of the given AlternateSpanList to add the node to- Throws:
IllegalArgumentException- if the given node is not a child of this SpanListIndexOutOfBoundsException- if the target subtree index is out of range
-
move
Moves a child of this SpanList to another SpanList.- Parameters:
nodeNum- the index of the node to movetarget- the SpanList to add the node totargetSubTree- the index of the subtree of the given AlternateSpanList to add the node to- Throws:
IndexOutOfBoundsException- if the given index is out of range, or the target subtree index is out of range
-
remove
Removes and invalidates the given SpanNode from this.- Parameters:
node- the node to remove.- Returns:
- this, for chaining.
-
remove
Removes and invalidates the SpanNode at the given index from this.- Parameters:
i- the index of the node to remove.- Returns:
- this, for chaining.
-
children
Returns a modifiable list of the immediate children of this SpanList. -
numChildren
public int numChildren()Returns the number of children this SpanList holds. -
childIterator
Traverses all immediate children of this SpanList. The ListIterator returned support all optional operations specified in the ListIterator interface.- Specified by:
childIteratorin classSpanNode- Returns:
- a ListIterator which traverses all immediate children of this SpanNode
- See Also:
-
childIteratorRecursive
Recursively traverses all children (not only leaf nodes) of this SpanList, in a depth-first fashion. The ListIterator only supports iteration forwards, and the optional operations that are implemented are remove() and set(). add() is not supported.- Specified by:
childIteratorRecursivein classSpanNode- Returns:
- a ListIterator which recursively traverses all children and their children etc. of this SpanList.
- See Also:
-
clearChildren
public void clearChildren()Removes and invalidates all references to child nodes. -
sortChildren
public void sortChildren()Sorts children by occurrence in the text covered.- See Also:
-
sortChildrenRecursive
public void sortChildrenRecursive()Recursively sorts all children by occurrence in the text covered. -
isLeafNode
public boolean isLeafNode()Always returns false, even if this node has no children.- Specified by:
isLeafNodein classSpanNode- Returns:
- always false, even if this node has no children
-
getFrom
public int getFrom()Returns the character index where thisSpanNodestarts (inclusive), i.e. the smallestSpanNode.getFrom()of all children. -
getTo
public int getTo()Returns the character index where thisSpanNodeends (exclusive), i.e. the greatestSpanNode.getTo()of all children. -
getLength
public int getLength()Returns the length of this span, i.e. getFrom() - getTo(). -
getText
Returns the text that is covered by this SpanNode. -
equals
-
hashCode
public int hashCode() -
toString
-