001 package com.thaiopensource.relaxng.impl;
002
003 import org.relaxng.datatype.Datatype;
004 import org.xml.sax.Locator;
005
006 class DataExceptPattern extends DataPattern {
007 private final Pattern except;
008 private final Locator loc;
009
010 DataExceptPattern(Datatype dt, Pattern except, Locator loc) {
011 super(dt);
012 this.except = except;
013 this.loc = loc;
014 }
015
016 boolean samePattern(Pattern other) {
017 if (!super.samePattern(other))
018 return false;
019 return except.samePattern(((DataExceptPattern)other).except);
020 }
021
022 void accept(PatternVisitor visitor) {
023 visitor.visitDataExcept(getDatatype(), except);
024 }
025
026 Object apply(PatternFunction f) {
027 return f.caseDataExcept(this);
028 }
029
030 void checkRestrictions(int context, DuplicateAttributeDetector dad, Alphabet alpha)
031 throws RestrictionViolationException {
032 super.checkRestrictions(context, dad, alpha);
033 try {
034 except.checkRestrictions(DATA_EXCEPT_CONTEXT, null, null);
035 }
036 catch (RestrictionViolationException e) {
037 e.maybeSetLocator(loc);
038 throw e;
039 }
040 }
041
042 Pattern getExcept() {
043 return except;
044 }
045 }