@Test public void testCompareTo() { final EName a1 = new EName("http: final EName b1 = new EName("http: final EName a2 = new EName("", "a"); final EName b2 = new EName("", "b"); List<EName> eNames = new ArrayList<>(); eNames.add(b1); eNames.add(a1); eNames.add(b2); eNames.add(a2); Collections.sort(eNames); assertEquals(a2, eNames.get(0)); assertEquals(b2, eNames.get(1)); assertEquals(a1, eNames.get(2)); assertEquals(b1, eNames.get(3)); }
@Override public int compareTo(EName o) { final int r = getNamespaceURI().compareTo(o.getNamespaceURI()); if (r == 0) { return getLocalName().compareTo(o.getLocalName()); } else { return r; } }
EName implements Serializable, Comparable<EName> { @Override public int compareTo(EName o) { final int r = getNamespaceURI().compareTo(o.getNamespaceURI()); if (r == 0) { return getLocalName().compareTo(o.getLocalName()); } else { return r; } } }
EName implements Serializable, Comparable<EName> { @Override public int compareTo(EName o) { final int r = getNamespaceURI().compareTo(o.getNamespaceURI()); if (r == 0) { return getLocalName().compareTo(o.getLocalName()); } else { return r; } } EName(String namespaceURI, String localName); }
EName implements Serializable, Comparable<EName> { @Override public int compareTo(EName o) { final int r = getNamespaceURI().compareTo(o.getNamespaceURI()); if (r == 0) { return getLocalName().compareTo(o.getLocalName()); } else { return r; } } EName(String namespaceURI, String localName); static EName mk(String namespaceURI, String localName); static EName mk(String localName); String getNamespaceURI(); String getLocalName(); boolean hasNamespace(); @Override int hashCode(); @Override boolean equals(Object that); @Override String toString(); @Override int compareTo(EName o); static EName fromString(String strEName, String defaultNameSpace); static EName fromString(String strEName); }
EName implements Serializable, Comparable<EName> { @Override public int compareTo(EName o) { final int r = getNamespaceURI().compareTo(o.getNamespaceURI()); if (r == 0) { return getLocalName().compareTo(o.getLocalName()); } else { return r; } } EName(String namespaceURI, String localName); static EName mk(String namespaceURI, String localName); static EName mk(String localName); String getNamespaceURI(); String getLocalName(); boolean hasNamespace(); @Override int hashCode(); @Override boolean equals(Object that); @Override String toString(); @Override int compareTo(EName o); static EName fromString(String strEName, String defaultNameSpace); static EName fromString(String strEName);  }