Java XML QName Get getQNameComparator()

Here you can find the source of getQNameComparator()

Description

Get a new Comparator comparing QName s.

License

Open Source License

Return

the .

Declaration

public static Comparator<QName> getQNameComparator() 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013, 2014, 2015 QPark Consulting S.a r.l. This program and the
 * accompanying materials are made available under the terms of the Eclipse
 * Public License v1.0. The Eclipse Public License is available at
 * http://www.eclipse.org/legal/epl-v10.html.
 ******************************************************************************/

import java.util.Comparator;

import javax.xml.namespace.QName;

public class Main {
    /**/*from  w w  w.j a  v a  2 s .  c om*/
     * Get a new {@link Comparator} comparing {@link QName}s.
     *
     * @return the {@link Comparator}.
     */
    public static Comparator<QName> getQNameComparator() {
        final Comparator<QName> comparator = (o1, o2) -> {
            if (o1 == o2) {
                return 0;
            } else if (o2 == null) {
                return -1;
            } else if (o1 == null) {
                return 1;
            } else {
                return o1.toString().compareTo(o2.toString());
            }
        };
        return comparator;
    }
}

Related

  1. getQName(String qname)
  2. getQName(String text, String defaultNamespace, NamespaceContext context)
  3. getQName(String value, Node node)
  4. getQNameAttribute(Map attributes, QName qName)
  5. getQNameAttribute(Node n, String namespace, String attributeName)
  6. getQNameConstant(QName name)
  7. getQNameForNode(Node node)
  8. getQNameFromSerialzedForm(String qNameAsString)
  9. getQNameFromString(Element element, String qnameAsString)