public interface ParentNode<N extends Node> extends Node
Important: Do not use outside of Soy code (treat as superpackage-private).
The parameter N represents the interface or class that is the superclass of all possible children for this ParentNode. E.g. for a Soy parse tree node, N is usually SoyNode, but for SoyFileSetNode N is SoyFileNode, for SoyFileNode N is TemplateNode, etc; for a Soy expression parse tree, N is usually ExprNode.
| Modifier and Type | Method and Description |
|---|---|
void |
addChild(int index,
N child)
Adds the given child at the given index (shifting existing children if necessary).
|
void |
addChild(N child)
Adds the given child.
|
void |
addChildren(int index,
List<? extends N> children)
Adds the given children at the given index (shifting existing children if necessary).
|
void |
addChildren(List<? extends N> children)
Adds the given children.
|
void |
appendSourceStringForChildren(StringBuilder sb)
Appends the source strings for all the children to the given StringBuilder.
|
void |
clearChildren()
Clears the list of children.
|
N |
getChild(int index)
Gets the child at the given index.
|
int |
getChildIndex(Node child)
Finds the index of the given child.
|
List<N> |
getChildren()
Gets the list of children.
|
int |
numChildren()
Gets the number of children.
|
void |
removeChild(int index)
Removes the child at the given index.
|
void |
removeChild(N child)
Removes the given child.
|
void |
replaceChild(int index,
N newChild)
Replaces the child at the given index with the given new child.
|
void |
replaceChild(N currChild,
N newChild)
Replaces the given current child with the given new child.
|
copy, couldHaveSyntaxVersionAtLeast, getNearestAncestor, getParent, getSourceLocation, getSyntaxVersionUpperBound, hasAncestor, maybeSetSyntaxVersionUpperBound, setParent, toSourceStringint numChildren()
N getChild(int index)
index - The index of the child to get.int getChildIndex(Node child)
child - The child to find the index of.List<N> getChildren()
Note: The returned list may not be a copy. Please do not modify the list directly. Instead, use the other methods in this class that are intended for modifying children. Also, if you're iterating over the children list as you're modifying it, then you should first make a copy of the children list to iterate over, in order to avoid ConcurrentModificationException.
void addChild(N child)
child - The child to add.void addChild(int index,
N child)
index - The index to add the child at.child - The child to add.void removeChild(int index)
index - The index of the child to remove.void removeChild(N child)
child - The child to remove.void replaceChild(int index,
N newChild)
index - The index of the child to replace.newChild - The new child.void replaceChild(N currChild, N newChild)
currChild - The current child to be replaced.newChild - The new child.void clearChildren()
void addChildren(List<? extends N> children)
children - The children to add.void addChildren(int index,
List<? extends N> children)
index - The index to add the children at.children - The children to add.void appendSourceStringForChildren(StringBuilder sb)
sb - The StringBuilder to which to append the children's source strings.