/** * @param node a node * @param parent the GPathResult prior to the application of the expression creating this GPathResult * @param namespacePrefix the namespace prefix if any * @param namespaceTagHints the known tag to namespace mappings */ public NodeChild(final Node node, final GPathResult parent, final String namespacePrefix, final Map<String, String> namespaceTagHints) { super(parent, node.name(), namespacePrefix, namespaceTagHints); this.node = node; ((NamespaceAwareHashMap)this.node.attributes()).setNamespaceTagHints(namespaceTagHints); }
public Object next() { initNextNode(); try { return this.nextNode; } finally { this.nextNode = getNextNode(this.iter); } }
public void doCall(Object[] args) { final GroovyObject delegate = (GroovyObject)getDelegate(); final GPathResult thisObject = (GPathResult)getThisObject(); Node node = (Node)thisObject.getAt(0); List children = node.children(); for (Object child : children) { delegate.getProperty("mkp"); if (child instanceof Node) { delegate.invokeMethod("yield", new Object[]{new NodeChild((Node) child, thisObject, "*", null)}); } else { delegate.invokeMethod("yield", new Object[]{child}); } } } };
public Writer writeTo(final Writer out) throws IOException { final Iterator iter = nodeIterator(); while (iter.hasNext()) { ((Node) iter.next()).writeTo(out); } return out; }
protected void replaceBody(final Object newValue) { final Iterator iter = iterator(); while (iter.hasNext()) { final NodeChild result = (NodeChild) iter.next(); result.replaceBody(newValue); } }
protected void appendNode(final Object newValue) { final Iterator iter = iterator(); while (iter.hasNext()) { final NodeChild result = (NodeChild) iter.next(); result.appendNode(newValue); } } }
/** * Returns true if the GPathResult is empty, i.e. if, and only if, <code>size()</code> is 0. * * @return true if the GPathResult is empty */ public boolean isEmpty() { return size() == 0; }
/** * Returns a map containing all attributes of the Node of this NodeChild. * @return a map containing all attributes */ public Map attributes() { return this.node.attributes(); }
/** * Returns an empty <code>Iterator</code>. * @return an empty <code>Iterator</code> */ public Iterator childNodes() { return iterator(); }
/** * Overloads the left shift operator to provide an easy way to * lazily append Objects to this GPathResult. * * @param newValue the Object to append * @return <code>this</code> */ public Object leftShift(final Object newValue) { appendNode(newValue); return this; }
@Override public void setAttribute(final Object object, final String attribute, final Object newValue) { GPathResult.this.setProperty("@" + attribute, newValue); } };
public Object next() { try { return this.nextElementNodes; } finally { this.nextElementNodes = getNextElementNodes(); } }
/** * Returns the children of this GPathResult as a GPathResult object. * * @return the children of this GPathResult */ public GPathResult children() { return new NodeChildren(this, this.namespaceTagHints); }
/** * Returns the text of this GPathResult. * * @return the GPathResult, converted to a <code>String</code> */ public String toString() { return text(); }
public Object next() { try { return this.next; } finally { this.next = getNextByDepth(); } }
public Object next() { try { return this.next; } finally { this.next = getNextByBreadth(); } }
/** * Returns the list of any direct String nodes of this NodeChild. * * @return the list of String values from this node * @since 2.3.0 */ public List<String> localText() { return this.node.localText(); }
/** * Returns as GPathResult with the parent nodes of the current GPathResult * * @return the parents GPathResult or <code>this</code> for the root */ public GPathResult parent() { return new NodeParents(this, this.namespaceTagHints); }
/** * Returns an empty iterator. * @return an empty iterator */ public Iterator nodeIterator() { return iterator(); }