01: package org.kohsuke.rngom.digested;
02:
03: /**
04: * @author Kohsuke Kawaguchi (kk@kohsuke.org)
05: */
06: public class DPatternWalker implements DPatternVisitor<Void> {
07: public Void onAttribute(DAttributePattern p) {
08: return onXmlToken(p);
09: }
10:
11: protected Void onXmlToken(DXmlTokenPattern p) {
12: return onUnary(p);
13: }
14:
15: public Void onChoice(DChoicePattern p) {
16: return onContainer(p);
17: }
18:
19: protected Void onContainer(DContainerPattern p) {
20: for (DPattern c = p.firstChild(); c != null; c = c.next)
21: c.accept(this );
22: return null;
23: }
24:
25: public Void onData(DDataPattern p) {
26: return null;
27: }
28:
29: public Void onElement(DElementPattern p) {
30: return onXmlToken(p);
31: }
32:
33: public Void onEmpty(DEmptyPattern p) {
34: return null;
35: }
36:
37: public Void onGrammar(DGrammarPattern p) {
38: return p.getStart().accept(this );
39: }
40:
41: public Void onGroup(DGroupPattern p) {
42: return onContainer(p);
43: }
44:
45: public Void onInterleave(DInterleavePattern p) {
46: return onContainer(p);
47: }
48:
49: public Void onList(DListPattern p) {
50: return onUnary(p);
51: }
52:
53: public Void onMixed(DMixedPattern p) {
54: return onUnary(p);
55: }
56:
57: public Void onNotAllowed(DNotAllowedPattern p) {
58: return null;
59: }
60:
61: public Void onOneOrMore(DOneOrMorePattern p) {
62: return onUnary(p);
63: }
64:
65: public Void onOptional(DOptionalPattern p) {
66: return onUnary(p);
67: }
68:
69: public Void onRef(DRefPattern p) {
70: return p.getTarget().getPattern().accept(this );
71: }
72:
73: public Void onText(DTextPattern p) {
74: return null;
75: }
76:
77: public Void onValue(DValuePattern p) {
78: return null;
79: }
80:
81: public Void onZeroOrMore(DZeroOrMorePattern p) {
82: return onUnary(p);
83: }
84:
85: protected Void onUnary(DUnaryPattern p) {
86: return p.getChild().accept(this);
87: }
88: }
|