001: /*
002: * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.tools.internal.xjc.reader.xmlschema;
027:
028: import com.sun.tools.internal.xjc.model.CClassInfo;
029: import com.sun.tools.internal.xjc.model.CPropertyInfo;
030: import com.sun.tools.internal.xjc.model.CTypeInfo;
031: import com.sun.tools.internal.xjc.model.TypeUse;
032: import com.sun.tools.internal.xjc.reader.Ring;
033: import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIProperty;
034: import com.sun.xml.internal.xsom.XSAnnotation;
035: import com.sun.xml.internal.xsom.XSComponent;
036: import com.sun.xml.internal.xsom.XSFacet;
037: import com.sun.xml.internal.xsom.XSIdentityConstraint;
038: import com.sun.xml.internal.xsom.XSNotation;
039: import com.sun.xml.internal.xsom.XSSchema;
040: import com.sun.xml.internal.xsom.XSSimpleType;
041: import com.sun.xml.internal.xsom.XSXPath;
042: import com.sun.xml.internal.xsom.visitor.XSVisitor;
043:
044: /**
045: * @author Kohsuke Kawaguchi
046: */
047: abstract class ColorBinder extends BindingComponent implements
048: XSVisitor {
049: protected final BGMBuilder builder = Ring.get(BGMBuilder.class);
050: protected final ClassSelector selector = getClassSelector();
051:
052: protected final CClassInfo getCurrentBean() {
053: return selector.getCurrentBean();
054: }
055:
056: protected final XSComponent getCurrentRoot() {
057: return selector.getCurrentRoot();
058: }
059:
060: protected CTypeInfo boundToType(XSComponent sc) {
061: if (sc == selector.getCurrentRoot())
062: return null;
063: return selector.bindToType(sc);
064: }
065:
066: protected final void createSimpleTypeProperty(XSSimpleType type,
067: String propName) {
068: BIProperty prop = BIProperty.getCustomization(type);
069:
070: SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class);
071: // since we are building the simple type here, use buildDef
072: CPropertyInfo p = prop.createValueProperty(propName, false,
073: type, stb.buildDef(type));
074: getCurrentBean().addProperty(p);
075: }
076:
077: public final void annotation(XSAnnotation xsAnnotation) {
078: throw new IllegalStateException();
079: }
080:
081: public final void schema(XSSchema xsSchema) {
082: throw new IllegalStateException();
083: }
084:
085: public final void facet(XSFacet xsFacet) {
086: throw new IllegalStateException();
087: }
088:
089: public final void notation(XSNotation xsNotation) {
090: throw new IllegalStateException();
091: }
092:
093: public final void identityConstraint(
094: XSIdentityConstraint xsIdentityConstraint) {
095: throw new IllegalStateException();
096: }
097:
098: public final void xpath(XSXPath xsxPath) {
099: throw new IllegalStateException();
100: }
101: }
|