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 TextPattern extends Pattern {
07: TextPattern() {
08: super (true, MIXED_CONTENT_TYPE, TEXT_HASH_CODE);
09: }
10:
11: boolean samePattern(Pattern other) {
12: return other instanceof TextPattern;
13: }
14:
15: public void accept(PatternVisitor visitor) {
16: visitor.visitText();
17: }
18:
19: public Object apply(PatternFunction f) {
20: return f.caseText(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_text");
29: case START_CONTEXT:
30: throw new RestrictionViolationException(
31: "start_contains_text");
32: case LIST_CONTEXT:
33: throw new RestrictionViolationException(
34: "list_contains_text");
35: }
36: }
37:
38: }
|