01: package org.kohsuke.rngom.binary;
02:
03: import org.kohsuke.rngom.binary.visitor.PatternFunction;
04: import org.kohsuke.rngom.binary.visitor.PatternVisitor;
05:
06: public class EmptyPattern extends Pattern {
07: EmptyPattern() {
08: super (true, EMPTY_CONTENT_TYPE, EMPTY_HASH_CODE);
09: }
10:
11: boolean samePattern(Pattern other) {
12: return other instanceof EmptyPattern;
13: }
14:
15: public void accept(PatternVisitor visitor) {
16: visitor.visitEmpty();
17: }
18:
19: public Object apply(PatternFunction f) {
20: return f.caseEmpty(this );
21: }
22:
23: void checkRestrictions(int context, DuplicateAttributeDetector dad,
24: Alphabet alpha) throws RestrictionViolationException {
25: switch (context) {
26: case DATA_EXCEPT_CONTEXT:
27: throw new RestrictionViolationException(
28: "data_except_contains_empty");
29: case START_CONTEXT:
30: throw new RestrictionViolationException(
31: "start_contains_empty");
32: }
33: }
34: }
|