1 package com.thaiopensource.relaxng.impl; 2 3 import com.thaiopensource.xml.util.Name; 4 5 class ChoiceNameClass implements NameClass { 6 7 private final NameClass nameClass1; 8 private final NameClass nameClass2; 9 10 ChoiceNameClass(NameClass nameClass1, NameClass nameClass2) { 11 this.nameClass1 = nameClass1; 12 this.nameClass2 = nameClass2; 13 } 14 15 public boolean contains(Name name) { 16 return (nameClass1.contains(name) 17 || nameClass2.contains(name)); 18 } 19 20 public int containsSpecificity(Name name) { 21 return Math.max(nameClass1.containsSpecificity(name), 22 nameClass2.containsSpecificity(name)); 23 } 24 25 public int hashCode() { 26 return nameClass1.hashCode() ^ nameClass2.hashCode(); 27 } 28 29 public boolean equals(Object obj) { 30 if (obj == null || !(obj instanceof ChoiceNameClass)) 31 return false; 32 ChoiceNameClass other = (ChoiceNameClass)obj; 33 return (nameClass1.equals(other.nameClass1) 34 && nameClass2.equals(other.nameClass2)); 35 } 36 37 public void accept(NameClassVisitor visitor) { 38 visitor.visitChoice(nameClass1, nameClass2); 39 } 40 41 public boolean isOpen() { 42 return nameClass1.isOpen() || nameClass2.isOpen(); 43 } 44 } 45 | Popular Tags |