KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.thaiopensource.relaxng.impl;
2
3 class EndTagDerivFunction extends AbstractPatternFunction {
4   private final ValidatorPatternBuilder builder;
5
6   EndTagDerivFunction(ValidatorPatternBuilder builder) {
7     this.builder = builder;
8   }
9
10   public Object JavaDoc caseOther(Pattern p) {
11     return builder.makeNotAllowed();
12   }
13
14   public Object JavaDoc caseChoice(ChoicePattern p) {
15     return builder.makeChoice(memoApply(p.getOperand1()),
16                   memoApply(p.getOperand2()));
17   }
18
19   public Object JavaDoc caseAfter(AfterPattern p) {
20     if (p.getOperand1().isNullable())
21       return p.getOperand2();
22     else
23       return builder.makeNotAllowed();
24   }
25
26   final private Pattern memoApply(Pattern p) {
27     return apply(builder.getPatternMemo(p)).getPattern();
28   }
29
30   private PatternMemo apply(PatternMemo memo) {
31     return memo.endTagDeriv(this);
32   }
33 }
34
Popular Tags