Commit | Line | Data |
---|---|---|
6e0043cc FT |
1 | package jrw.sp; |
2 | ||
3 | public class Name { | |
4 | public final Namespace ns; | |
5 | public final String local; | |
6 | ||
7 | public Name(Namespace ns, String local) { | |
8 | if(local == null) | |
9 | throw(new NullPointerException()); | |
10 | this.ns = ns; | |
11 | this.local = local; | |
12 | } | |
13 | ||
14 | public Name(String local) { | |
15 | this(null, local); | |
16 | } | |
17 | ||
18 | public int hashCode() { | |
19 | return(System.identityHashCode(ns) + local.hashCode()); | |
20 | } | |
21 | ||
22 | private boolean equals(Name that) { | |
23 | return((this.ns == that.ns) && this.local.equals(that.local)); | |
24 | } | |
25 | ||
26 | public boolean equals(Object x) { | |
27 | return((x instanceof Name) && equals((Name)x)); | |
28 | } | |
29 | ||
30 | public String toString() { | |
31 | return((ns == null) ? local : (ns.prefabb + ":" + local)); | |
32 | } | |
33 | } |