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.model;
027:
028: import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
029: import javax.xml.namespace.QName;
030:
031: import com.sun.tools.internal.xjc.model.nav.NClass;
032: import com.sun.tools.internal.xjc.model.nav.NType;
033: import com.sun.xml.internal.bind.v2.model.core.PropertyInfo;
034: import com.sun.xml.internal.bind.v2.model.core.TypeRef;
035: import com.sun.xml.internal.bind.v2.runtime.RuntimeUtil;
036: import com.sun.xml.internal.xsom.XmlString;
037:
038: /**
039: * {@link TypeRef} for XJC.
040: *
041: * TODO: do we need the source schema component support here?
042: *
043: * @author Kohsuke Kawaguchi
044: */
045: public final class CTypeRef implements TypeRef<NType, NClass> {
046: /**
047: * In-memory type.
048: *
049: * This is the type used when
050: */
051: @XmlJavaTypeAdapter(RuntimeUtil.ToStringAdapter.class)
052: private final CNonElement type;
053:
054: private final QName elementName;
055:
056: private final boolean nillable;
057: public final XmlString defaultValue;
058:
059: public CTypeRef(CNonElement type, QName elementName,
060: boolean nillable, XmlString defaultValue) {
061: assert type != null;
062: assert elementName != null;
063:
064: this .type = type;
065: this .elementName = elementName;
066: this .nillable = nillable;
067: this .defaultValue = defaultValue;
068: }
069:
070: public CNonElement getTarget() {
071: return type;
072: }
073:
074: public QName getTagName() {
075: return elementName;
076: }
077:
078: public boolean isNillable() {
079: return nillable;
080: }
081:
082: /**
083: * Inside XJC, use {@link #defaultValue} that has context information.
084: * This method is to override the one defined in the runtime model.
085: *
086: * @see #defaultValue
087: */
088: public String getDefaultValue() {
089: if (defaultValue != null)
090: return defaultValue.value;
091: else
092: return null;
093: }
094:
095: public boolean isLeaf() {
096: // TODO: implement this method later
097: throw new UnsupportedOperationException();
098: }
099:
100: public PropertyInfo<NType, NClass> getSource() {
101: // TODO: implement this method later
102: throw new UnsupportedOperationException();
103: }
104: }
|