Here you can find the source of contains(final QName[] qnames, final QName qname, final String defaultNamespace)
public static boolean contains(final QName[] qnames, final QName qname, final String defaultNamespace)
//package com.java2s; /****************************************************************************** * Copyright (c) 2015 Oracle/*from ww w. j a va2 s . c o m*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Konstantin Komissarchik - initial implementation and ongoing maintenance ******************************************************************************/ import javax.xml.namespace.QName; public class Main { public static boolean contains(final QName[] qnames, final QName qname, final String defaultNamespace) { for (QName a : qnames) { if (equal(a, qname, defaultNamespace)) { return true; } } return false; } public static boolean equal(final QName a, final QName b, final String defaultNamespace) { if (a.getLocalPart().equals(b.getLocalPart())) { String nsa = a.getNamespaceURI(); String nsb = b.getNamespaceURI(); if (nsa == null || nsa.length() == 0) { nsa = defaultNamespace; } if (nsb == null || nsb.length() == 0) { nsb = defaultNamespace; } return nsa.equals(nsb); } return false; } }