Java XML QName contains(final QName[] qnames, final QName qname, final String defaultNamespace)

Here you can find the source of contains(final QName[] qnames, final QName qname, final String defaultNamespace)

Description

contains

License

Open Source License

Declaration

public static boolean contains(final QName[] qnames, final QName qname, final String defaultNamespace) 

Method Source Code

//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;
    }
}

Related

  1. addTypeQname(QName elemntNameSpace, List propertyQnameValueList, PropertyDescriptor propDesc, QName beanName, boolean processingDocLitBare)
  2. compareQName(QName qname, Node node)
  3. compareRelation(QName a, QName b)
  4. compareWithOutNamespace(QName value, QName tagName)
  5. concatAttributes(List startElements, QName attrName)
  6. convertQNameListToNamespaceToLocalNameList( List list)
  7. convertQNameToFullname(QName qn)
  8. convertToQName(String source, String nameSpaceuri)
  9. copyQName(QName inName)

  10. HOME | Copyright © www.java2s.com 2016