KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.thaiopensource.relaxng.impl;
2
3 import com.thaiopensource.xml.util.Name;
4
5 class StartAttributeDerivFunction extends StartTagOpenDerivFunction {
6   StartAttributeDerivFunction(Name name, ValidatorPatternBuilder builder) {
7     super(name, builder);
8   }
9
10   public Object JavaDoc caseElement(ElementPattern p) {
11     return getPatternBuilder().makeNotAllowed();
12   }
13
14   public Object JavaDoc caseGroup(GroupPattern p) {
15     final Pattern p1 = p.getOperand1();
16     final Pattern p2 = p.getOperand2();
17     return getPatternBuilder().makeChoice(
18                       memoApply(p1).applyForPattern(new ApplyAfterFunction(getPatternBuilder()) {
19                           Pattern apply(Pattern x) {
20                         return getPatternBuilder().makeGroup(x, p2);
21                           }
22                         }),
23                       memoApply(p2).applyForPattern(new ApplyAfterFunction(getPatternBuilder()) {
24                           Pattern apply(Pattern x) {
25                         return getPatternBuilder().makeGroup(p1, x);
26                           }
27                                             }));
28   }
29
30   public Object JavaDoc caseAttribute(AttributePattern p) {
31     if (!p.getNameClass().contains(getName()))
32       return getPatternBuilder().makeNotAllowed();
33     return getPatternBuilder().makeAfter(p.getContent(),
34                      getPatternBuilder().makeEmpty());
35   }
36
37   PatternMemo apply(PatternMemo memo) {
38     return memo.startAttributeDeriv(this);
39   }
40 }
41
Popular Tags