Here you can find the source of getCurrentListPosition(Node refNode, NodeList list)
Parameter | Description |
---|---|
refNode | the element to get the index for |
list | the NodeList to search |
public static int getCurrentListPosition(Node refNode, NodeList list)
//package com.java2s; /*/* w w w . jav a 2s .c o m*/ * Copyright (c) 2012. betterFORM Project - http://www.betterform.de * Licensed under the terms of BSD License */ import org.w3c.dom.*; public class Main { /** * returns an element's position in the given NodeList * * @param refNode the element to get the index for * @param list the NodeList to search * @return the position starting with 1, or -1 if refNode was null */ public static int getCurrentListPosition(Node refNode, NodeList list) { if (refNode == null) { return -1; } int counter = 1; for (int n = 0; n < list.getLength(); n++, counter++) { if (list.item(n) == refNode) { return counter; } } return -1; } }