01: package org.kohsuke.rngom.parse.host;
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:
11: /**
12: *
13: * @author
14: * Kohsuke Kawaguchi (kk@kohsuke.org)
15: */
16: final class DataPatternBuilderHost extends Base implements
17: DataPatternBuilder {
18: final DataPatternBuilder lhs;
19: final DataPatternBuilder rhs;
20:
21: DataPatternBuilderHost(DataPatternBuilder lhs,
22: DataPatternBuilder rhs) {
23: this .lhs = lhs;
24: this .rhs = rhs;
25: }
26:
27: public void addParam(String name, String value, Context context,
28: String ns, Location _loc, Annotations _anno)
29: throws BuildException {
30: LocationHost loc = cast(_loc);
31: AnnotationsHost anno = cast(_anno);
32:
33: lhs.addParam(name, value, context, ns, loc.lhs, anno.lhs);
34: rhs.addParam(name, value, context, ns, loc.rhs, anno.rhs);
35: }
36:
37: public void annotation(ParsedElementAnnotation _ea) {
38: ParsedElementAnnotationHost ea = (ParsedElementAnnotationHost) _ea;
39:
40: lhs.annotation(ea.lhs);
41: rhs.annotation(ea.rhs);
42: }
43:
44: public ParsedPattern makePattern(Location _loc, Annotations _anno)
45: throws BuildException {
46: LocationHost loc = cast(_loc);
47: AnnotationsHost anno = cast(_anno);
48:
49: return new ParsedPatternHost(
50: lhs.makePattern(loc.lhs, anno.lhs), rhs.makePattern(
51: loc.rhs, anno.rhs));
52: }
53:
54: public ParsedPattern makePattern(ParsedPattern _except,
55: Location _loc, Annotations _anno) throws BuildException {
56: ParsedPatternHost except = (ParsedPatternHost) _except;
57: LocationHost loc = cast(_loc);
58: AnnotationsHost anno = cast(_anno);
59:
60: return new ParsedPatternHost(lhs.makePattern(except.lhs,
61: loc.lhs, anno.lhs), rhs.makePattern(except.rhs,
62: loc.rhs, anno.rhs));
63: }
64: }
|