KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.thaiopensource.relaxng.impl;
2
3 import com.thaiopensource.datatype.Datatype2;
4 import org.relaxng.datatype.Datatype;
5
6 class DataPattern extends StringPattern {
7   private final Datatype dt;
8
9   DataPattern(Datatype dt) {
10     super(combineHashCode(DATA_HASH_CODE, dt.hashCode()));
11     this.dt = dt;
12   }
13
14   boolean samePattern(Pattern other) {
15     if (other.getClass() != this.getClass())
16       return false;
17     return dt.equals(((DataPattern)other).dt);
18   }
19
20   void accept(PatternVisitor visitor) {
21     visitor.visitData(dt);
22   }
23
24   Object JavaDoc apply(PatternFunction f) {
25     return f.caseData(this);
26   }
27
28   Datatype getDatatype() {
29     return dt;
30   }
31
32   boolean allowsAnyString() {
33     return dt instanceof Datatype2 && ((Datatype2)dt).alwaysValid();
34   }
35
36   void checkRestrictions(int context, DuplicateAttributeDetector dad, Alphabet alpha)
37     throws RestrictionViolationException {
38     switch (context) {
39     case START_CONTEXT:
40       throw new RestrictionViolationException("start_contains_data");
41     }
42   }
43 }
44
Popular Tags