01: /*
02: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
03: *
04: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
05: *
06: * The contents of this file are subject to the terms of either the GNU
07: * General Public License Version 2 only ("GPL") or the Common Development
08: * and Distribution License("CDDL") (collectively, the "License"). You
09: * may not use this file except in compliance with the License. You can obtain
10: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
11: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
12: * language governing permissions and limitations under the License.
13: *
14: * When distributing the software, include this License Header Notice in each
15: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
16: * Sun designates this particular file as subject to the "Classpath" exception
17: * as provided by Sun in the GPL Version 2 section of the License file that
18: * accompanied this code. If applicable, add the following below the License
19: * Header, with the fields enclosed by brackets [] replaced by your own
20: * identifying information: "Portions Copyrighted [year]
21: * [name of copyright owner]"
22: *
23: * Contributor(s):
24: *
25: * If you wish your version of this file to be governed by only the CDDL or
26: * only the GPL Version 2, indicate your decision by adding "[Contributor]
27: * elects to include this software in this distribution under the [CDDL or GPL
28: * Version 2] license." If you don't indicate a single choice of license, a
29: * recipient has the option to distribute your version of this file under
30: * either the CDDL, the GPL Version 2 or to extend the choice of license to
31: * its licensees as provided above. However, if you add GPL Version 2 code
32: * and therefore, elected the GPL Version 2 license, then the option applies
33: * only if the new code is made subject to such option by the copyright
34: * holder.
35: */
36: package com.sun.tools.xjc.reader.xmlschema.ct;
37:
38: import com.sun.tools.xjc.ErrorReceiver;
39: import com.sun.tools.xjc.reader.Ring;
40: import com.sun.tools.xjc.reader.xmlschema.BGMBuilder;
41: import com.sun.tools.xjc.reader.xmlschema.BindGreen;
42: import com.sun.tools.xjc.reader.xmlschema.ClassSelector;
43: import com.sun.tools.xjc.reader.xmlschema.SimpleTypeBuilder;
44: import com.sun.xml.xsom.XSComplexType;
45: import com.sun.xml.xsom.XSSchemaSet;
46:
47: /**
48: * Builds a field expression from a complex type.
49: *
50: * Depending on a "kind" of complex type, the binding is
51: * quite different. For example, how a complex type is bound
52: * when it is extended from another complex type is very
53: * different from how it's bound when it has, say, mixed content model.
54: *
55: * Each different algorithm of binding a complex type is implemented
56: * as an implementation of this interface.
57: *
58: * @author
59: * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
60: */
61: abstract class CTBuilder {
62: /**
63: * Returns true if this owner can handle the given complex type.
64: */
65: abstract boolean isApplicable(XSComplexType ct);
66:
67: /**
68: * Binds the given complex type. This method will be called
69: * only when the <code>isApplicable</code> method returns true.
70: */
71: abstract void build(XSComplexType ct);
72:
73: protected final ComplexTypeFieldBuilder builder = Ring
74: .get(ComplexTypeFieldBuilder.class);
75: protected final ClassSelector selector = Ring
76: .get(ClassSelector.class);
77: protected final SimpleTypeBuilder simpleTypeBuilder = Ring
78: .get(SimpleTypeBuilder.class);
79: protected final ErrorReceiver errorReceiver = Ring
80: .get(ErrorReceiver.class);
81: protected final BindGreen green = Ring.get(BindGreen.class);
82: protected final XSSchemaSet schemas = Ring.get(XSSchemaSet.class);
83: protected final BGMBuilder bgmBuilder = Ring.get(BGMBuilder.class);
84: }
|