01: /*
02: * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun in the LICENSE file that accompanied this code.
10: *
11: * This code is distributed in the hope that it will be useful, but WITHOUT
12: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14: * version 2 for more details (a copy is included in the LICENSE file that
15: * accompanied this code).
16: *
17: * You should have received a copy of the GNU General Public License version
18: * 2 along with this work; if not, write to the Free Software Foundation,
19: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20: *
21: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25:
26: package com.sun.xml.internal.rngom.nc;
27:
28: import com.sun.xml.internal.rngom.ast.builder.Annotations;
29: import com.sun.xml.internal.rngom.ast.builder.BuildException;
30: import com.sun.xml.internal.rngom.ast.builder.CommentList;
31: import com.sun.xml.internal.rngom.ast.builder.NameClassBuilder;
32: import com.sun.xml.internal.rngom.ast.om.Location;
33: import com.sun.xml.internal.rngom.ast.om.ParsedElementAnnotation;
34:
35: import java.util.List;
36:
37: /**
38: *
39: * @author
40: * Kohsuke Kawaguchi (kk@kohsuke.org)
41: */
42: public class NameClassBuilderImpl<E extends ParsedElementAnnotation, L extends Location, A extends Annotations<E, L, CL>, CL extends CommentList<L>>
43: implements NameClassBuilder<NameClass, E, L, A, CL> {
44:
45: public NameClass makeChoice(List<NameClass> nameClasses, L loc,
46: A anno) {
47: NameClass result = nameClasses.get(0);
48: for (int i = 1; i < nameClasses.size(); i++)
49: result = new ChoiceNameClass(result, nameClasses.get(i));
50: return result;
51: }
52:
53: public NameClass makeName(String ns, String localName,
54: String prefix, L loc, A anno) {
55: return new SimpleNameClass(ns, localName);
56: }
57:
58: public NameClass makeNsName(String ns, L loc, A anno) {
59: return new NsNameClass(ns);
60: }
61:
62: public NameClass makeNsName(String ns, NameClass except, L loc,
63: A anno) {
64: return new NsNameExceptNameClass(ns, except);
65: }
66:
67: public NameClass makeAnyName(L loc, A anno) {
68: return NameClass.ANY;
69: }
70:
71: public NameClass makeAnyName(NameClass except, L loc, A anno) {
72: return new AnyNameExceptNameClass(except);
73: }
74:
75: public NameClass makeErrorNameClass() {
76: return NameClass.NULL;
77: }
78:
79: public NameClass annotate(NameClass nc, A anno)
80: throws BuildException {
81: return nc;
82: }
83:
84: public NameClass annotateAfter(NameClass nc, E e)
85: throws BuildException {
86: return nc;
87: }
88:
89: public NameClass commentAfter(NameClass nc, CL comments)
90: throws BuildException {
91: return nc;
92: }
93:
94: }
|