test_class.file: vault-core/src/test/java/org/apache/jackrabbit/vault/util/QNameComparatorTest.java
test_class.identifier: QNameComparatorTest
test_case.body: @Test
      public void testCompare() {
          List<QName> names = new LinkedList<>();
          QName name1 = new QName("localonly");
          names.add(name1);
          QName name2 = new QName(XMLConstants.XML_NS_URI, "xhtml", XMLConstants.XML_NS_PREFIX);
          names.add(name2);
          QName name3 = new QName(NamespaceRegistry.NAMESPACE_JCR, "UpperCase", NamespaceRegistry.PREFIX_JCR);
          names.add(name3);
          QName name4 = new QName(NamespaceRegistry.NAMESPACE_JCR, "primaryType", NamespaceRegistry.PREFIX_JCR);
          names.add(name4);
          QName name5 = new QName(NamespaceRegistry.NAMESPACE_JCR, "PrimaryType", NamespaceRegistry.PREFIX_JCR);
          names.add(name5);
          Collections.sort(names, new QNameComparator());
          
          Assert.assertThat(names, Matchers.contains(name2, name5, name4, name3, name1));
      }
test_case.class_method_signature: QNameComparatorTest.testCompare()
test_case.full_signature: @Test public void testCompare()
test_case.identifier: testCompare
test_case.invocations: add add add add add sort assertThat contains
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCompare()
focal_class.declarator: INSTANCE = new QNameComparator()
focal_class.modifier: public static final
focal_class.original_string: public static final QNameComparator INSTANCE = new QNameComparator();
focal_class.type: QNameComparator
focal_class.var_name: INSTANCE
focal_class.declarator: LESS_THAN = -1
focal_class.modifier: private static final
focal_class.original_string: private static final int LESS_THAN = -1;
focal_class.type: int
focal_class.var_name: LESS_THAN
focal_class.declarator: EQUAL = 0
focal_class.modifier: private static final
focal_class.original_string: private static final int EQUAL = 0;
focal_class.type: int
focal_class.var_name: EQUAL
focal_class.declarator: GREATER_THAN = 1
focal_class.modifier: private static final
focal_class.original_string: private static final int GREATER_THAN = 1;
focal_class.type: int
focal_class.var_name: GREATER_THAN
focal_class.file: vault-core/src/main/java/org/apache/jackrabbit/vault/util/QNameComparator.java
focal_class.identifier: QNameComparator
focal_class.interfaces: implements Comparator<QName>
focal_class.class_method_signature: QNameComparator.compare(final QName o1, final QName o2)
focal_class.full_signature: @Override public int compare(final QName o1, final QName o2)
focal_class.identifier: compare
focal_class.modifiers: @Override public
focal_class.parameters: (final QName o1, final QName o2)
focal_class.return: int
focal_class.signature: int compare(final QName o1, final QName o2)
focal_method.body: @Override
      public int compare(final QName o1, final QName o2) {
          // first namespace declarations
          final boolean isXmlNs1 = o1.getPrefix().equalsIgnoreCase(XMLConstants.XML_NS_PREFIX);
          final boolean isXmlNs2 = o2.getPrefix().equalsIgnoreCase(XMLConstants.XML_NS_PREFIX);
          if (isXmlNs1 && !isXmlNs2) {
              return LESS_THAN;
          } else if (!isXmlNs1 && isXmlNs2) {
              return GREATER_THAN;
          }
          // prefixed attributes before non-prefixed ones...
          if (!o1.getPrefix().equalsIgnoreCase(XMLConstants.DEFAULT_NS_PREFIX) && o2.getPrefix().equalsIgnoreCase(XMLConstants.DEFAULT_NS_PREFIX)) {
              return LESS_THAN;
          } else if (o1.getPrefix().equalsIgnoreCase(XMLConstants.DEFAULT_NS_PREFIX) && !o2.getPrefix().equalsIgnoreCase(XMLConstants.DEFAULT_NS_PREFIX)) {
              return GREATER_THAN;
          } else {
              // order first by prefix, then by local name
              String lowerCaseQName1 = o1.getPrefix().toLowerCase(Locale.ROOT) + o1.getLocalPart().toLowerCase(Locale.ROOT);
              String lowerCaseQName2 = o2.getPrefix().toLowerCase(Locale.ROOT) + o2.getLocalPart().toLowerCase(Locale.ROOT);
              final int c = lowerCaseQName1.compareTo(lowerCaseQName2);
              // if the lowercase versions are equal, they could differ in case (see JCRVLT-334)
              if (c == EQUAL) {
                  String qName1 = o1.getPrefix() + o1.getLocalPart();
                  String qName2 = o2.getPrefix() + o2.getLocalPart();
                  return qName1.compareTo(qName2);
              }
              return c;
          }
      }
focal_method.class_method_signature: QNameComparator.compare(final QName o1, final QName o2)
focal_method.full_signature: @Override public int compare(final QName o1, final QName o2)
focal_method.identifier: compare
focal_method.invocations: equalsIgnoreCase getPrefix equalsIgnoreCase getPrefix equalsIgnoreCase getPrefix equalsIgnoreCase getPrefix equalsIgnoreCase getPrefix equalsIgnoreCase getPrefix toLowerCase getPrefix toLowerCase getLocalPart toLowerCase getPrefix toLowerCase getLocalPart compareTo getPrefix getLocalPart getPrefix getLocalPart compareTo
focal_method.modifiers: @Override public
focal_method.parameters: (final QName o1, final QName o2)
focal_method.return: int
focal_method.signature: int compare(final QName o1, final QName o2)