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.bindinfo;
027:
028: import javax.xml.bind.annotation.XmlAttribute;
029: import javax.xml.bind.annotation.XmlElement;
030: import javax.xml.bind.annotation.XmlRootElement;
031: import javax.xml.namespace.QName;
032:
033: import com.sun.tools.internal.xjc.reader.Const;
034: import com.sun.xml.internal.bind.api.impl.NameConverter;
035:
036: import org.xml.sax.Locator;
037:
038: /**
039: * Class declaration.
040: *
041: * This customization turns arbitrary schema component into a Java
042: * content interface.
043: *
044: * <p>
045: * This customization is acknowledged by the ClassSelector.
046: *
047: * @author
048: * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
049: */
050: @XmlRootElement(name="class")
051: public final class BIClass extends AbstractDeclarationImpl {
052:
053: public BIClass(Locator loc, String _className, String _implClass,
054: String _javadoc) {
055: super (loc);
056: this .className = _className;
057: this .javadoc = _javadoc;
058: this .userSpecifiedImplClass = _implClass;
059: }
060:
061: protected BIClass() {
062: }
063:
064: @XmlAttribute(name="name")
065: private String className;
066:
067: /**
068: * Gets the specified class name, or null if not specified.
069: *
070: * @return
071: * Returns a class name. The caller should <em>NOT</em>
072: * apply XML-to-Java name conversion to the name
073: * returned from this method.
074: */
075: public String getClassName() {
076: if (className == null)
077: return null;
078:
079: BIGlobalBinding gb = getBuilder().getGlobalBinding();
080: NameConverter nc = getBuilder().model.getNameConverter();
081:
082: if (gb.isJavaNamingConventionEnabled())
083: return nc.toClassName(className);
084: else
085: // don't change it
086: return className;
087: }
088:
089: @XmlAttribute(name="implClass")
090: private String userSpecifiedImplClass;
091:
092: /**
093: * Gets the fully qualified name of the
094: * user-specified implementation class, if any.
095: * Or null.
096: */
097: public String getUserSpecifiedImplClass() {
098: return userSpecifiedImplClass;
099: }
100:
101: @XmlElement
102: private String javadoc;
103:
104: /**
105: * Gets the javadoc comment specified in the customization.
106: * Can be null if none is specified.
107: */
108: public String getJavadoc() {
109: return javadoc;
110: }
111:
112: public QName getName() {
113: return NAME;
114: }
115:
116: /** Name of this declaration. */
117: public static final QName NAME = new QName(Const.JAXB_NSURI,
118: "class");
119: }
|