public final class MixinParentNode<N extends Node> extends Object
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 the master 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.
| Constructor and Description |
|---|
MixinParentNode(MixinParentNode<N> orig,
ParentNode<N> newMaster,
CopyState copyState)
Copy constructor.
|
MixinParentNode(ParentNode<N> master) |
| 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.
|
String |
toTreeString(int indent)
Builds a string that visually shows the subtree rooted at this node (for debugging).
|
public MixinParentNode(ParentNode<N> master)
master - The master node that delegates to this instance.public MixinParentNode(MixinParentNode<N> orig, ParentNode<N> newMaster, CopyState copyState)
orig - The node to copy.newMaster - The master node for the copy.public int numChildren()
public N getChild(int index)
index - The index of the child to get.public int getChildIndex(Node child)
child - The child to find the index of.public List<N> getChildren()
Note: The returned list is not 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.
public void addChild(N child)
child - The child to add.public void addChild(int index,
N child)
index - The index to add the child at.child - The child to add.public void removeChild(int index)
index - The index of the child to remove.public void removeChild(N child)
child - The child to remove.public void replaceChild(int index,
N newChild)
index - The index of the child to replace.newChild - The new child.public void replaceChild(N currChild, N newChild)
currChild - The current child to be replaced.newChild - The new child.public void clearChildren()
public void addChildren(List<? extends N> children)
children - The children to add.public void addChildren(int index,
List<? extends N> children)
index - The index to add the children at.children - The children to add.public void appendSourceStringForChildren(StringBuilder sb)
sb - The StringBuilder to which to append the children's source strings.public String toTreeString(int indent)
indent - The indentation for each line of the tree string (usually pass 0).