01: package org.kohsuke.rngom.nc;
02:
03: import javax.xml.namespace.QName;
04:
05: public class ChoiceNameClass extends NameClass {
06:
07: private final NameClass nameClass1;
08: private final NameClass nameClass2;
09:
10: public ChoiceNameClass(NameClass nameClass1, NameClass nameClass2) {
11: this .nameClass1 = nameClass1;
12: this .nameClass2 = nameClass2;
13: }
14:
15: public boolean contains(QName name) {
16: return (nameClass1.contains(name) || nameClass2.contains(name));
17: }
18:
19: public int containsSpecificity(QName name) {
20: return Math.max(nameClass1.containsSpecificity(name),
21: nameClass2.containsSpecificity(name));
22: }
23:
24: public int hashCode() {
25: return nameClass1.hashCode() ^ nameClass2.hashCode();
26: }
27:
28: public boolean equals(Object obj) {
29: if (obj == null || !(obj instanceof ChoiceNameClass))
30: return false;
31: ChoiceNameClass other = (ChoiceNameClass) obj;
32: return (nameClass1.equals(other.nameClass1) && nameClass2
33: .equals(other.nameClass2));
34: }
35:
36: public <V> V accept(NameClassVisitor<V> visitor) {
37: return visitor.visitChoice(nameClass1, nameClass2);
38: }
39:
40: public boolean isOpen() {
41: return nameClass1.isOpen() || nameClass2.isOpen();
42: }
43: }
|