@java.lang.SuppressWarnings("unused") public class MNode extends java.lang.Object implements AdapterTemplateModel, TemplateHashModelEx, TemplateNodeModel, TemplateScalarModel, TemplateSequenceModel
An alternative to groovy.util.Node with methods more type safe and generally useful in Moqui.
Modifiers | Name | Description |
---|---|---|
protected static org.slf4j.Logger |
logger |
Constructor and description |
---|
MNode
(groovy.util.Node node) |
MNode
(java.lang.String name, java.util.Map<java.lang.String, java.lang.String> attributes, MNode parent, java.util.List<MNode> children, java.lang.String text) |
MNode
(java.lang.String name, java.util.Map<java.lang.String, java.lang.String> attributes) |
Type Params | Return Type | Name and description |
---|---|---|
|
public void |
append(MNode child) |
|
public void |
append(MNode child, int index) |
|
public MNode |
append(groovy.util.Node child) |
|
public MNode |
append(java.lang.String name, java.util.Map<java.lang.String, java.lang.String> attributes, java.util.List<MNode> children, java.lang.String text) |
|
public MNode |
append(java.lang.String name, java.util.Map<java.lang.String, java.lang.String> attributes) |
|
public void |
appendAll(java.util.List<MNode> children, boolean clone) Append nodes to end of current child nodes, optionally clone |
|
public void |
appendAll(java.util.List<MNode> children, int index, boolean clone) Append child nodes at given index, optionally clone |
|
public java.lang.String |
attribute(java.lang.String attrName) |
|
public java.util.ArrayList<MNode> |
breadthFirst(groovy.lang.Closure<java.lang.Boolean> condition) |
|
public MNode |
child(int index) Get child at index, will throw an exception if index out of bounds |
|
public java.util.ArrayList<MNode> |
children(java.lang.String name) |
|
public java.util.ArrayList<MNode> |
children(java.lang.String name, java.lang.String attrNamesValues) |
|
public java.util.ArrayList<MNode> |
children(groovy.lang.Closure<java.lang.Boolean> condition) |
|
public static void |
clearParsedNodeCache() |
|
public MNode |
deepCopy(MNode parent) |
|
public java.util.ArrayList<MNode> |
depthFirst(groovy.lang.Closure<java.lang.Boolean> condition) |
|
public java.util.Map<java.lang.String, java.util.ArrayList<MNode>> |
descendants(java.util.Set<java.lang.String> names) Search all descendants for nodes matching any of the names, return a Map with a List for each name with nodes found or empty List if no nodes found |
|
public void |
descendants(java.util.Set<java.lang.String> names, java.util.Map<java.lang.String, java.util.ArrayList<MNode>> nodes) |
|
public java.util.ArrayList<MNode> |
descendants(java.lang.String name) |
|
public MNode |
first() Get the first child node |
|
public MNode |
first(java.lang.String name) Get the first child node with the given name |
|
public MNode |
first(java.lang.String name, java.lang.String attrNamesValues) |
|
public MNode |
first(groovy.lang.Closure<java.lang.Boolean> condition) |
|
public int |
firstIndex(java.lang.String name) |
|
public int |
firstIndex(groovy.lang.Closure<java.lang.Boolean> condition) |
|
public int |
firstIndex(MNode child) |
|
public TemplateModel |
get(java.lang.String s) |
|
public TemplateModel |
get(int i) |
|
public java.lang.Object |
getAdaptedObject(java.lang.Class aClass) |
|
public java.lang.String |
getAsString() |
|
public java.lang.Object |
getAt(java.lang.String name) Groovy specific method for square brace syntax |
|
public java.util.Map<java.lang.String, java.lang.String> |
getAttributes() |
|
public TemplateSequenceModel |
getChildNodes() |
|
public java.util.ArrayList<MNode> |
getChildren() |
|
public java.util.Map<java.lang.String, java.util.ArrayList<MNode>> |
getChildrenByName() |
|
public java.lang.String |
getFileLocation() |
|
public java.lang.String |
getName() |
|
public java.lang.String |
getNodeName() |
|
public java.lang.String |
getNodeNamespace() |
|
public java.lang.String |
getNodeType() |
|
public java.lang.Object |
getObject(java.lang.String name) If name starts with an ampersand (@) then get an attribute, otherwise get a list of child nodes with the given name. |
|
public MNode |
getParent() |
|
public TemplateNodeModel |
getParentNode() |
|
public java.lang.String |
getText() |
|
public boolean |
hasAncestor(java.lang.String nodeName) |
|
public boolean |
hasChild(java.lang.String name) |
|
public boolean |
isEmpty() |
|
public TemplateCollectionModel |
keys() |
|
public void |
mergeChildWithChildKey(MNode overrideNode, java.lang.String childName, java.lang.String grandchildName, java.lang.String keyAttributeName, groovy.lang.Closure grandchildMerger) |
|
public void |
mergeChildrenByKey(MNode overrideNode, java.lang.String childNodesName, java.lang.String keyAttributeName, groovy.lang.Closure childMerger) |
|
public void |
mergeChildrenByKeys(MNode overrideNode, java.lang.String childNodesName, groovy.lang.Closure childMerger, java.lang.String keyAttributeNames) |
|
public void |
mergeNodeWithChildKey(MNode overrideNode, java.lang.String childNodesName, java.lang.String keyAttributeName, groovy.lang.Closure childMerger) Merge attributes and child nodes from overrideNode into this node, matching on childNodesName and optionally the value of the attribute in each named by keyAttributeName. |
|
public void |
mergeSingleChild(MNode overrideNode, java.lang.String childNodeName) Merge a single child node with the given name from overrideNode if it has a child with that name. |
|
public static MNode |
parse(ResourceReference rr) |
|
public static MNode |
parse(java.lang.String location, java.io.InputStream is) Parse from an InputStream and close the stream |
|
public static MNode |
parse(java.io.File fl) |
|
public static MNode |
parse(java.lang.String location, org.xml.sax.InputSource isrc) |
|
public static MNode |
parseRootOnly(ResourceReference rr) |
|
public static MNode |
parseRootOnly(java.lang.String location, org.xml.sax.InputSource isrc) |
|
public static MNode |
parseText(java.lang.String location, java.lang.String text) |
|
public void |
remove(int index) Remove the child at the given index |
|
public boolean |
remove(java.lang.String name) Remove children matching the node/element name |
|
public boolean |
remove(groovy.lang.Closure<java.lang.Boolean> condition) Remove children where Closure evaluates to true |
|
public boolean |
removeAll() Remove all children |
|
public MNode |
replace(int index, MNode child) |
|
public MNode |
replace(int index, java.lang.String name, java.util.Map<java.lang.String, java.lang.String> attributes) |
|
public MNode |
setFileLocation(java.lang.String location) |
|
public void |
setName(java.lang.String name) |
|
public void |
setSystemExpandAttributes(boolean b) |
|
public int |
size() |
|
public java.lang.String |
toString() |
|
public TemplateCollectionModel |
values() |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Append nodes to end of current child nodes, optionally clone
Append child nodes at given index, optionally clone
Get child at index, will throw an exception if index out of bounds
Search all descendants for nodes matching any of the names, return a Map with a List for each name with nodes found or empty List if no nodes found
Get the first child node
Get the first child node with the given name
Groovy specific method for square brace syntax
If name starts with an ampersand (@) then get an attribute, otherwise get a list of child nodes with the given name.
Merge attributes and child nodes from overrideNode into this node, matching on childNodesName and optionally the value of the attribute in each named by keyAttributeName. Always copies/overwrites attributes from override child node, and merges their child nodes using childMerger or if null the default merge of removing all children under the child of this node and appending copies of the children of the override child node.
Merge a single child node with the given name from overrideNode if it has a child with that name. If this node has a child with the same name copies/overwrites attributes from the overrideNode's child and if overrideNode's child has children the children of this node's child will be replaced by them. Otherwise appends a copy of the override child as a child of the current node.
Parse from an InputStream and close the stream
Remove the child at the given index
Remove children matching the node/element name
Remove children where Closure evaluates to true
Remove all children