01: package org.kohsuke.rngom.digested;
02:
03: import org.kohsuke.rngom.ast.builder.Annotations;
04: import org.kohsuke.rngom.ast.builder.BuildException;
05: import org.kohsuke.rngom.ast.builder.DataPatternBuilder;
06: import org.kohsuke.rngom.ast.om.Location;
07: import org.kohsuke.rngom.ast.om.ParsedElementAnnotation;
08: import org.kohsuke.rngom.ast.om.ParsedPattern;
09: import org.kohsuke.rngom.parse.Context;
10: import org.xml.sax.Locator;
11:
12: /**
13: * @author Kohsuke Kawaguchi (kk@kohsuke.org)
14: */
15: final class DataPatternBuilderImpl implements DataPatternBuilder {
16:
17: private final DDataPattern p;
18:
19: public DataPatternBuilderImpl(String datatypeLibrary, String type,
20: Location loc) {
21: p = new DDataPattern();
22: p.location = (Locator) loc;
23: p.datatypeLibrary = datatypeLibrary;
24: p.type = type;
25: }
26:
27: public void addParam(String name, String value, Context context,
28: String ns, Location loc, Annotations anno)
29: throws BuildException {
30: p.params.add(p.new Param(name, value, context.copy(), ns, loc,
31: (Annotation) anno));
32: }
33:
34: public void annotation(ParsedElementAnnotation ea) {
35: // TODO
36: }
37:
38: public ParsedPattern makePattern(Location loc, Annotations anno)
39: throws BuildException {
40: return makePattern(null, loc, anno);
41: }
42:
43: public ParsedPattern makePattern(ParsedPattern except,
44: Location loc, Annotations anno) throws BuildException {
45: p.except = (DPattern) except;
46: if (anno != null)
47: p.annotation = ((Annotation) anno).getResult();
48: return p;
49: }
50: }
|