01: package org.kohsuke.rngom.binary;
02:
03: import org.kohsuke.rngom.binary.visitor.PatternFunction;
04: import org.kohsuke.rngom.binary.visitor.PatternVisitor;
05: import org.relaxng.datatype.Datatype;
06: import org.xml.sax.Locator;
07:
08: public class DataExceptPattern extends DataPattern {
09: private Pattern except;
10: private Locator loc;
11:
12: DataExceptPattern(Datatype dt, Pattern except, Locator loc) {
13: super (dt);
14: this .except = except;
15: this .loc = loc;
16: }
17:
18: boolean samePattern(Pattern other) {
19: if (!super .samePattern(other))
20: return false;
21: return except.samePattern(((DataExceptPattern) other).except);
22: }
23:
24: public void accept(PatternVisitor visitor) {
25: visitor.visitDataExcept(getDatatype(), except);
26: }
27:
28: public Object apply(PatternFunction f) {
29: return f.caseDataExcept(this );
30: }
31:
32: void checkRestrictions(int context, DuplicateAttributeDetector dad,
33: Alphabet alpha) throws RestrictionViolationException {
34: super .checkRestrictions(context, dad, alpha);
35: try {
36: except.checkRestrictions(DATA_EXCEPT_CONTEXT, null, null);
37: } catch (RestrictionViolationException e) {
38: e.maybeSetLocator(loc);
39: throw e;
40: }
41: }
42:
43: Pattern getExcept() {
44: return except;
45: }
46: }
|