01: package com.sun.xml.xsom.impl;
02:
03: import java.util.Comparator;
04:
05: /**
06: * UName.
07: *
08: * @author Kohsuke Kawaguchi (kk@kohsuke.org)
09: */
10: public final class UName {
11: /**
12: * @param _nsUri
13: * Use "" to indicate the no namespace.
14: */
15: public UName(String _nsUri, String _localName, String _qname) {
16: if (_nsUri == null || _localName == null || _qname == null) {
17: throw new NullPointerException(_nsUri + " " + _localName
18: + " " + _qname);
19: }
20: this .nsUri = _nsUri.intern();
21: this .localName = _localName.intern();
22: this .qname = _qname.intern();
23: }
24:
25: public UName(String nsUri, String localName) {
26: this (nsUri, localName, localName);
27: }
28:
29: private final String nsUri;
30: private final String localName;
31: private final String qname;
32:
33: public String getName() {
34: return localName;
35: }
36:
37: public String getNamespaceURI() {
38: return nsUri;
39: }
40:
41: public String getQualifiedName() {
42: return qname;
43: }
44:
45: /**
46: * Compares {@link UName}s by their names.
47: */
48: public static final Comparator comparator = new Comparator() {
49: public int compare(Object o1, Object o2) {
50: UName lhs = (UName) o1;
51: UName rhs = (UName) o2;
52: int r = lhs.nsUri.compareTo(rhs.nsUri);
53: if (r != 0)
54: return r;
55: return lhs.localName.compareTo(rhs.localName);
56: }
57: };
58: }
|