01: package org.kohsuke.rngom.nc;
02:
03: import org.kohsuke.rngom.ast.builder.Annotations;
04: import org.kohsuke.rngom.ast.builder.BuildException;
05: import org.kohsuke.rngom.ast.builder.CommentList;
06: import org.kohsuke.rngom.ast.builder.NameClassBuilder;
07: import org.kohsuke.rngom.ast.om.Location;
08: import org.kohsuke.rngom.ast.om.ParsedElementAnnotation;
09:
10: import java.util.List;
11:
12: /**
13: *
14: * @author
15: * Kohsuke Kawaguchi (kk@kohsuke.org)
16: */
17: public class NameClassBuilderImpl<E extends ParsedElementAnnotation, L extends Location, A extends Annotations<E, L, CL>, CL extends CommentList<L>>
18: implements NameClassBuilder<NameClass, E, L, A, CL> {
19:
20: public NameClass makeChoice(List<NameClass> nameClasses, L loc,
21: A anno) {
22: NameClass result = nameClasses.get(0);
23: for (int i = 1; i < nameClasses.size(); i++)
24: result = new ChoiceNameClass(result, nameClasses.get(i));
25: return result;
26: }
27:
28: public NameClass makeName(String ns, String localName,
29: String prefix, L loc, A anno) {
30: return new SimpleNameClass(ns, localName);
31: }
32:
33: public NameClass makeNsName(String ns, L loc, A anno) {
34: return new NsNameClass(ns);
35: }
36:
37: public NameClass makeNsName(String ns, NameClass except, L loc,
38: A anno) {
39: return new NsNameExceptNameClass(ns, except);
40: }
41:
42: public NameClass makeAnyName(L loc, A anno) {
43: return NameClass.ANY;
44: }
45:
46: public NameClass makeAnyName(NameClass except, L loc, A anno) {
47: return new AnyNameExceptNameClass(except);
48: }
49:
50: public NameClass makeErrorNameClass() {
51: return NameClass.NULL;
52: }
53:
54: public NameClass annotate(NameClass nc, A anno)
55: throws BuildException {
56: return nc;
57: }
58:
59: public NameClass annotateAfter(NameClass nc, E e)
60: throws BuildException {
61: return nc;
62: }
63:
64: public NameClass commentAfter(NameClass nc, CL comments)
65: throws BuildException {
66: return nc;
67: }
68:
69: }
|