use of jodd.lagarto.dom.Node in project jodd by oblac.
the class Jerry method contents.
/**
* Get the children of each element in the set of matched elements,
* including text and comment nodes.
*/
public Jerry contents() {
List<Node> result = new NodeList(nodes.length);
if (nodes.length > 0) {
for (Node node : nodes) {
Node[] contents = node.getChildNodes();
Collections.addAll(result, contents);
}
}
return new Jerry(this, result);
}
use of jodd.lagarto.dom.Node in project jodd by oblac.
the class Jerry method eq.
/**
* Reduces the set of matched elements to the one at the specified index.
*/
public Jerry eq(int value) {
List<Node> result = new NodeList(1);
int matchingIndex = value >= 0 ? value : nodes.length + value;
if (nodes.length > 0) {
int index = 0;
for (Node node : nodes) {
if (index == matchingIndex) {
result.add(node);
break;
}
index++;
}
}
return new Jerry(this, result);
}
use of jodd.lagarto.dom.Node in project jodd by oblac.
the class Jerry method not.
/**
* Removes elements from the set of matched elements.
*/
public Jerry not(String cssSelector) {
Node[] notNodes = root().find(cssSelector).nodes;
List<Node> result = new NodeList(nodes.length);
if (nodes.length > 0) {
for (Node node : nodes) {
if (!ArraysUtil.contains(notNodes, node)) {
result.add(node);
}
}
}
return new Jerry(this, result);
}
use of jodd.lagarto.dom.Node in project jodd by oblac.
the class Jerry method each.
/**
* Iterates over a jQuery object, executing a function for
* each matched element.
* @see #eachNode(JerryNodeFunction)
*/
public Jerry each(JerryFunction function) {
for (int i = 0; i < nodes.length; i++) {
Node node = nodes[i];
Jerry $this = new Jerry(this, node);
Boolean result = function.onNode($this, i);
if (result != null && result == Boolean.FALSE) {
break;
}
}
return this;
}
use of jodd.lagarto.dom.Node in project jodd by oblac.
the class Jerry method nextAll.
/**
* Get all following siblings of each element in the set of matched
* elements, optionally filtered by a selector.
*/
public Jerry nextAll() {
List<Node> result = new NodeList(nodes.length);
if (nodes.length > 0) {
for (Node node : nodes) {
Node currentSiblingElement = node.getNextSiblingElement();
while (currentSiblingElement != null) {
result.add(currentSiblingElement);
currentSiblingElement = currentSiblingElement.getNextSiblingElement();
}
}
}
return new Jerry(this, result);
}
Aggregations