001: /*
002: * Portions 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: package com.sun.tools.internal.ws.processor.model.jaxb;
026:
027: import com.sun.tools.internal.ws.processor.model.AbstractType;
028: import com.sun.tools.internal.ws.processor.model.java.JavaType;
029: import com.sun.tools.internal.xjc.api.TypeAndAnnotation;
030: import com.sun.codemodel.internal.JType;
031:
032: import javax.xml.namespace.QName;
033: import java.util.ArrayList;
034: import java.util.List;
035:
036: /**
037: * Top-level binding between JAXB generated Java type
038: * and XML Schema element declaration.
039: *
040: * @author
041: * Vivek Pandey
042: */
043: public class JAXBType extends AbstractType {
044: public JAXBType(JAXBType jaxbType) {
045: setName(jaxbType.getName());
046: this .jaxbMapping = jaxbType.getJaxbMapping();
047: this .jaxbModel = jaxbType.getJaxbModel();
048: init();
049: }
050:
051: public JAXBType() {
052: }
053:
054: public JAXBType(QName name, JavaType type) {
055: super (name, type);
056: }
057:
058: public JAXBType(QName name, JavaType type, JAXBMapping jaxbMapping,
059: JAXBModel jaxbModel) {
060: super (name, type);
061: this .jaxbMapping = jaxbMapping;
062: this .jaxbModel = jaxbModel;
063: init();
064: }
065:
066: public void accept(JAXBTypeVisitor visitor) throws Exception {
067: visitor.visit(this );
068: }
069:
070: private void init() {
071: if (jaxbMapping != null)
072: wrapperChildren = jaxbMapping.getWrapperStyleDrilldown();
073: else
074: wrapperChildren = new ArrayList<JAXBProperty>();
075: }
076:
077: public boolean isUnwrappable() {
078: return getJaxbMapping().getWrapperStyleDrilldown() != null;
079: }
080:
081: public boolean hasWrapperChildren() {
082: return (getWrapperChildren().size() > 0) ? true : false;
083: }
084:
085: public boolean isLiteralType() {
086: return true;
087: }
088:
089: public List<JAXBProperty> getWrapperChildren() {
090: return wrapperChildren;
091: }
092:
093: public void setWrapperChildren(List<JAXBProperty> children) {
094: wrapperChildren = children;
095: }
096:
097: public JAXBMapping getJaxbMapping() {
098: return jaxbMapping;
099: }
100:
101: public void setJaxbMapping(JAXBMapping jaxbMapping) {
102: this .jaxbMapping = jaxbMapping;
103: init();
104: }
105:
106: public void setUnwrapped(boolean unwrapped) {
107: this .unwrapped = unwrapped;
108: }
109:
110: public boolean isUnwrapped() {
111: return unwrapped;
112: }
113:
114: private JAXBMapping jaxbMapping;
115:
116: public JAXBModel getJaxbModel() {
117: return jaxbModel;
118: }
119:
120: public void setJaxbModel(JAXBModel jaxbModel) {
121: this .jaxbModel = jaxbModel;
122: }
123:
124: private JAXBModel jaxbModel;
125: private boolean unwrapped = false;
126: private List<JAXBProperty> wrapperChildren;
127: }
|