本文整理汇总了Java中elemental.dom.NodeList.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java NodeList.getLength方法的具体用法?Java NodeList.getLength怎么用?Java NodeList.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elemental.dom.NodeList
的用法示例。
在下文中一共展示了NodeList.getLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printStructure
import elemental.dom.NodeList; //导入方法依赖的package包/类
private void printStructure(Element element) {
console.log("<" + element.getNodeName());
NamedNodeMap attributes = element.getAttributes();
if (attributes != null) {
for (int x = 0; x < attributes.length(); x++) {
Node attr = attributes.item(x);
console.log(" " + attr.getNodeName() + "=" + attr.getNodeValue());
}
}
console.log(">");
if (element.getTextContent() != null) {
console.log(element.getTextContent());
}
NodeList children = element.getChildNodes();
for (int x = 0; x < children.getLength(); x++) {
printStructure((Element) children.at(x));
}
console.log("</" + element.getNodeName() + ">");
}
示例2: rightArrowPressed
import elemental.dom.NodeList; //导入方法依赖的package包/类
/**
* Handles pressing the Right arrow button. Does nothing when user selected a file. Expands a
* folder if the user has selected one. Selects the first child if the folder is already selected
* and expanded.
*/
public void rightArrowPressed() {
if (getModel().getRoot() == null
|| getSelectionModel().getSelectedNodes().isEmpty()
|| getModel().dataAdapter.getChildren(getModel().getRoot()).isEmpty()) {
return;
}
D selected = getSelectionModel().getSelectedNodes().get(0);
TreeNodeElement<D> selectedTreeNodeElement =
getModel().dataAdapter.getRenderedTreeNode(selected);
if (selectedTreeNodeElement.hasChildrenContainer()) {
if (selectedTreeNodeElement.isOpen()) {
// Select the first child
NodeList children = selectedTreeNodeElement.getChildrenContainer().getChildNodes();
if (children.getLength() > 0) {
TreeNodeElement<D> firstChild = (TreeNodeElement<D>) children.item(0);
selectSingleNode(firstChild);
}
} else {
// Open the folder
expandNode(selectedTreeNodeElement, true, true);
}
}
}
示例3: getVisibleTreeNodes
import elemental.dom.NodeList; //导入方法依赖的package包/类
/**
* Gathers all visible nodes of subtree.
*
* @param node subtree parent
* @return array containing all visible nodes of subtree
*/
public List<TreeNodeElement<D>> getVisibleTreeNodes(TreeNodeElement<D> node) {
List<TreeNodeElement<D>> nodes = new ArrayList<>();
nodes.add(node);
if (node.isOpen() && node.hasChildNodes()) {
NodeList children = node.getChildrenContainer().getChildNodes();
for (int ci = 0; ci < children.getLength(); ci++) {
TreeNodeElement<D> child = (TreeNodeElement<D>) children.item(ci);
nodes.addAll(getVisibleTreeNodes(child));
}
}
return nodes;
}
示例4: removeStaleInfoPopups
import elemental.dom.NodeList; //导入方法依赖的package包/类
private static void removeStaleInfoPopups(final String markerClass) {
final Document documentElement = Elements.getDocument();
final NodeList markersToRemove = documentElement.getElementsByClassName(markerClass);
for (int i = 0; i < markersToRemove.getLength(); i++) {
final Node childToRemove = markersToRemove.item(i);
final Node parent = childToRemove.getParentNode();
if (parent != null) {
parent.removeChild(childToRemove);
}
}
}