Here you can find the source of size(final NodeList nodeList)
Parameter | Description |
---|---|
nodeList | the NodeList |
public final static int size(final NodeList nodeList)
//package com.java2s; /**//w w w . ja v a 2s . c o m * The contents of this file are subject to the Regenstrief Public License * Version 1.0 (the "License"); you may not use this file except in compliance with the License. * Please contact Regenstrief Institute if you would like to obtain a copy of the license. * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * Copyright (C) Regenstrief Institute. All Rights Reserved. */ import org.w3c.dom.*; public class Main { /** * Retrieves the number of Nodes in the NodeList * * @param nodeList the NodeList * @return the number of Nodes **/ public final static int size(final NodeList nodeList) { return nodeList == null ? 0 : nodeList.getLength(); } /** * Retrieves the number of Nodes in the NamedNodeMap * * @param nodeMap the NamedNodeMap * @return the number of Nodes **/ public final static int size(final NamedNodeMap nodeMap) { return nodeMap == null ? 0 : nodeMap.getLength(); } /** * Retrieves the number of Nodes in the tree rooted at the given Node * * @param node the root Node * @return the number of Nodes **/ public final static int size(final Node node) { if (node == null) { return 0; } final NodeList children = node.getChildNodes(); int size = 1; for (int i = 0, n = size(children); i < n; i++) { size += size(children.item(i)); } return size; } }