Here you can find the source of isEmpty(NodeList nl)
public static boolean isEmpty(NodeList nl)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; import java.util.Collection; import java.util.Map; import org.w3c.dom.NodeList; public class Main { /** Test if array is null or empty. */ public static boolean isEmpty(byte[] ba) { return ba == null || ba.length == 0; }/*w ww.ja v a 2s .co m*/ /** Test if array is null or empty. */ public static boolean isEmpty(Object[] oa) { return oa == null || oa.length == 0; } /** Test if string is null or empty. */ public static boolean isEmpty(CharSequence s) { return s == null || s.length() == 0; } /** Test if string is null or empty. */ public static boolean isEmpty(Appendable s) { int length = -1; if (s != null) { Method m = null; Class<? extends Appendable> sclass = s.getClass(); try { m = sclass.getMethod("size"); } catch (NoSuchMethodException e1) { try { m = sclass.getMethod("length"); } catch (NoSuchMethodException e2) { try { m = sclass.getMethod("getLength"); } catch (NoSuchMethodException e3) { } } } if (m != null) { try { length = (Integer) m.invoke(s); } catch (Exception e) { } } } return s == null || length == 0; } /** Test if node list is null or empty. */ public static boolean isEmpty(NodeList nl) { return nl == null || nl.getLength() == 0; } /** Test if map is null or empty. */ public static boolean isEmpty(Map<?, ?> m) { return m == null || m.size() == 0; } /** Test if collection is null or empty. */ public static boolean isEmpty(Collection<?> c) { return c == null || c.size() == 0; } }