public class SpanList extends SpanNode
Modifier and Type | Field and Description |
---|---|
private int |
cachedFrom |
private int |
cachedTo |
private List<SpanNode> |
children |
static byte |
ID |
Modifier | Constructor and Description |
---|---|
|
SpanList()
Creates a new SpanList.
|
protected |
SpanList(List<SpanNode> children) |
|
SpanList(SpanList other)
Deep-copies a SpanList.
|
|
SpanList(SpanNodeReader reader) |
Modifier and Type | Method and Description |
---|---|
SpanList |
add(SpanNode node)
Adds a child node to this SpanList.
|
private void |
calculateFrom() |
private void |
calculateTo() |
(package private) void |
checkValidity(SpanNode node,
List<SpanNode> childrenToCheck) |
ListIterator<SpanNode> |
childIterator()
Traverses all immediate children of this SpanList.
|
ListIterator<SpanNode> |
childIteratorRecursive()
Recursively traverses all children (not only leaf nodes) of this SpanList, in a depth-first fashion.
|
protected List<SpanNode> |
children()
Returns a modifiable list of the immediate children of this SpanList.
|
void |
clearChildren()
Removes and invalidates all references to child nodes.
|
boolean |
equals(Object o) |
int |
getFrom()
Returns the character index where this
SpanNode starts (inclusive), i.e. the smallest SpanNode.getFrom() of all children. |
int |
getLength()
Returns the length of this span, i.e. getFrom() - getTo().
|
CharSequence |
getText(CharSequence text)
Returns the text that is covered by this SpanNode.
|
int |
getTo()
Returns the character index where this
SpanNode ends (exclusive), i.e. the greatest SpanNode.getTo() of all children. |
int |
hashCode() |
boolean |
isLeafNode()
Always returns false, even if this node has no children.
|
void |
move(int nodeNum,
AlternateSpanList target,
int targetSubTree)
Moves a child of this SpanList to another SpanList.
|
void |
move(int nodeNum,
SpanList target)
Moves a child of this SpanList to another SpanList.
|
void |
move(SpanNode node,
AlternateSpanList target,
int targetSubTree)
Moves a child of this SpanList to another SpanList.
|
void |
move(SpanNode node,
SpanList target)
Moves a child of this SpanList to another SpanList.
|
int |
numChildren()
Returns the number of children this SpanList holds.
|
SpanList |
remove(int i)
Removes and invalidates the SpanNode at the given index from this.
|
SpanList |
remove(SpanNode node)
Removes and invalidates the given SpanNode from this.
|
(package private) void |
resetCachedFromAndTo() |
(package private) void |
setInvalid() |
void |
sortChildren()
Sorts children by occurrence in the text covered.
|
void |
sortChildrenRecursive()
Recursively sorts all children by occurrence in the text covered.
|
Span |
span(int from,
int length)
Create a span, add it to this list and return it
|
String |
toString() |
annotate, annotate, annotate, annotate, annotate, compareTo, contains, getParent, getScratchId, getSpanTree, getStringFieldValue, isValid, overlaps, setParent, setScratchId
public static final byte ID
private int cachedFrom
private int cachedTo
public SpanList()
public SpanList(SpanNodeReader reader)
public SpanList(SpanList other)
other
- the SpanList to copy.public SpanList add(SpanNode node)
node
- the node to add.IllegalStateException
- if SpanNode.isValid() returns false.public Span span(int from, int length)
void setInvalid()
setInvalid
in class SpanNode
public void move(SpanNode node, SpanList target)
node
- the node to movetarget
- the SpanList to add the node toIllegalArgumentException
- if the given node is not a child of this SpanListpublic void move(int nodeNum, SpanList target)
nodeNum
- the index of the node to movetarget
- the SpanList to add the node toIndexOutOfBoundsException
- if the given index is out of rangepublic void move(SpanNode node, AlternateSpanList target, int targetSubTree)
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 toIllegalArgumentException
- if the given node is not a child of this SpanListIndexOutOfBoundsException
- if the target subtree index is out of rangepublic void move(int nodeNum, AlternateSpanList target, int targetSubTree)
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 toIndexOutOfBoundsException
- if the given index is out of range, or the target subtree index is out of rangepublic SpanList remove(SpanNode node)
node
- the node to remove.public SpanList remove(int i)
i
- the index of the node to remove.protected List<SpanNode> children()
public int numChildren()
public ListIterator<SpanNode> childIterator()
childIterator
in class SpanNode
ListIterator
public ListIterator<SpanNode> childIteratorRecursive()
childIteratorRecursive
in class SpanNode
ListIterator
public void clearChildren()
public void sortChildren()
SpanNode.compareTo(SpanNode)
public void sortChildrenRecursive()
public boolean isLeafNode()
isLeafNode
in class SpanNode
private void calculateFrom()
public int getFrom()
SpanNode
starts (inclusive), i.e. the smallest SpanNode.getFrom()
of all children.private void calculateTo()
public int getTo()
SpanNode
ends (exclusive), i.e. the greatest SpanNode.getTo()
of all children.void resetCachedFromAndTo()
public int getLength()
public CharSequence getText(CharSequence text)
Copyright © 2018. All rights reserved.