Java Code Examples for org.w3c.dom.Document#ELEMENT_NODE

The following examples show how to use org.w3c.dom.Document#ELEMENT_NODE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PXDOMStyleAdapter.java    From pixate-freestyle-android with Apache License 2.0 6 votes vote down vote up
private Object getSiblingAt(Node node, int offset, boolean skipNonElement) {
    Object result = null;
    int indexInParent = getIndexInParent(node);
    if (indexInParent != -1) {
        int siblingIndex = indexInParent + offset;
        NodeList siblings = node.getParentNode().getChildNodes();
        // Get the sibling at the offset. In case it's out of
        // bounds, return null.
        while (result == null) {
            if (siblingIndex >= 0 && siblingIndex < siblings.getLength()) {
                Node sibling = siblings.item(siblingIndex);
                if (skipNonElement && sibling.getNodeType() != Document.ELEMENT_NODE) {
                    // skip the non-element node
                    siblingIndex += (offset < 0) ? -1 : 1;
                } else {
                    result = sibling;
                    break;
                }
            } else {
                // out of bounds
                break;
            }
        }
    }
    return result;
}
 
Example 2
Source File: ConfigLoader.java    From feeyo-hlsserver with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unused")
private static List<Node> getChildNodes(Node theNode, String childElName) {
	LinkedList<Node> nodes = new LinkedList<Node>();
	NodeList childs = theNode.getChildNodes();
	for (int j = 0; j < childs.getLength(); j++) {
		if (childs.item(j).getNodeType() == Document.ELEMENT_NODE && childs.item(j).getNodeName().equals(childElName)) {
			nodes.add(childs.item(j));
		}
	}
	return nodes;
}
 
Example 3
Source File: AbstractConfigLoader.java    From feeyo-redisproxy with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected static List<Node> getChildNodes(Node theNode, String childElName) {
	LinkedList<Node> nodes = new LinkedList<Node>();
	NodeList childs = theNode.getChildNodes();
	for (int j = 0; j < childs.getLength(); j++) {
		if (childs.item(j).getNodeType() == Document.ELEMENT_NODE && childs.item(j).getNodeName().equals(childElName)) {
			nodes.add(childs.item(j));
		}
	}
	return nodes;
}
 
Example 4
Source File: KafkaConfigLoader.java    From feeyo-redisproxy with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
static List<Node> getChildNodes(Node theNode, String childElName) {
	LinkedList<Node> nodes = new LinkedList<Node>();
	NodeList childs = theNode.getChildNodes();
	for (int j = 0; j < childs.getLength(); j++) {
		if (childs.item(j).getNodeType() == Document.ELEMENT_NODE && childs.item(j).getNodeName().equals(childElName)) {
			nodes.add(childs.item(j));
		}
	}
	return nodes;
}
 
Example 5
Source File: MergeDocuments.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the nodes in actionArgs as children nodes to editNode.
 *
 * @param editNode   The node on which children will be added.
 * @param actionArgs The nodes to add.
 */
private void nodeAdd(Node editNode, NodeList actionArgs) {
    // got through and add each new node to the root
    for (int k = 0; k < actionArgs.getLength(); k++) {
        Node n = actionArgs.item(k);

        if (n.getNodeType() == Document.ELEMENT_NODE) {
            editNode.appendChild(editNode.getOwnerDocument().adoptNode(n.cloneNode(true)));
        }
    }
}