001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036: package com.sun.tools.xjc.reader.xmlschema.bindinfo;
037:
038: import javax.xml.bind.annotation.XmlAttribute;
039: import javax.xml.bind.annotation.XmlElement;
040: import javax.xml.bind.annotation.XmlRootElement;
041: import javax.xml.namespace.QName;
042:
043: import com.sun.tools.xjc.reader.Const;
044: import com.sun.xml.bind.api.impl.NameConverter;
045: import com.sun.istack.Nullable;
046:
047: /**
048: * Class declaration.
049: *
050: * This customization turns arbitrary schema component into a Java
051: * content interface.
052: *
053: * <p>
054: * This customization is acknowledged by the ClassSelector.
055: *
056: * @author
057: * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
058: */
059: @XmlRootElement(name="class")
060: public final class BIClass extends AbstractDeclarationImpl {
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: * (Not a fully qualified name.)
070: *
071: * @return
072: * Returns a class name. The caller should <em>NOT</em>
073: * apply XML-to-Java name conversion to the name
074: * returned from this method.
075: */
076: public @Nullable
077: String getClassName() {
078: if (className == null)
079: return null;
080:
081: BIGlobalBinding gb = getBuilder().getGlobalBinding();
082: NameConverter nc = getBuilder().model.getNameConverter();
083:
084: if (gb.isJavaNamingConventionEnabled())
085: return nc.toClassName(className);
086: else
087: // don't change it
088: return className;
089: }
090:
091: @XmlAttribute(name="implClass")
092: private String userSpecifiedImplClass;
093:
094: /**
095: * Gets the fully qualified name of the
096: * user-specified implementation class, if any.
097: * Or null.
098: */
099: public String getUserSpecifiedImplClass() {
100: return userSpecifiedImplClass;
101: }
102:
103: @XmlAttribute(name="ref")
104: private String ref;
105:
106: /**
107: * Reference to the existing class, or null.
108: * Fully qualified name.
109: *
110: * <p>
111: * Caller needs to perform error check on this.
112: */
113: public String getExistingClassRef() {
114: return ref;
115: }
116:
117: @XmlElement
118: private String javadoc;
119:
120: /**
121: * Gets the javadoc comment specified in the customization.
122: * Can be null if none is specified.
123: */
124: public String getJavadoc() {
125: return javadoc;
126: }
127:
128: public QName getName() {
129: return NAME;
130: }
131:
132: public void setParent(BindInfo p) {
133: super .setParent(p);
134: // if this specifies a reference to external class,
135: // then it's OK even if noone actually refers this class.
136: if (ref != null)
137: markAsAcknowledged();
138: }
139:
140: /** Name of this declaration. */
141: public static final QName NAME = new QName(Const.JAXB_NSURI,
142: "class");
143: }
|