KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thaiopensource > relaxng > impl > DataExceptPattern


1 package com.thaiopensource.relaxng.impl;
2
3 import org.relaxng.datatype.Datatype;
4 import org.xml.sax.Locator JavaDoc;
5
6 class DataExceptPattern extends DataPattern {
7   private final Pattern except;
8   private final Locator JavaDoc loc;
9
10   DataExceptPattern(Datatype dt, Pattern except, Locator JavaDoc loc) {
11     super(dt);
12     this.except = except;
13     this.loc = loc;
14   }
15
16   boolean samePattern(Pattern other) {
17     if (!super.samePattern(other))
18       return false;
19     return except.samePattern(((DataExceptPattern)other).except);
20   }
21
22   void accept(PatternVisitor visitor) {
23     visitor.visitDataExcept(getDatatype(), except);
24   }
25
26   Object JavaDoc apply(PatternFunction f) {
27     return f.caseDataExcept(this);
28   }
29
30   void checkRestrictions(int context, DuplicateAttributeDetector dad, Alphabet alpha)
31     throws RestrictionViolationException {
32     super.checkRestrictions(context, dad, alpha);
33     try {
34       except.checkRestrictions(DATA_EXCEPT_CONTEXT, null, null);
35     }
36     catch (RestrictionViolationException e) {
37       e.maybeSetLocator(loc);
38       throw e;
39     }
40   }
41
42   Pattern getExcept() {
43     return except;
44   }
45 }
46
Popular Tags