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.xml.ws.model;
037:
038: import com.sun.xml.bind.api.CompositeStructure;
039: import com.sun.xml.bind.api.TypeReference;
040: import com.sun.xml.ws.api.model.JavaMethod;
041: import com.sun.xml.ws.api.model.ParameterBinding;
042:
043: import javax.jws.WebParam.Mode;
044: import java.util.ArrayList;
045: import java.util.List;
046:
047: /**
048: * {@link ParameterImpl} that represents a wrapper,
049: * which is a parameter that consists of multiple nested {@link ParameterImpl}s
050: * within, which together form a body part.
051: *
052: * <p>
053: * Java method parameters represented by nested {@link ParameterImpl}s will be
054: * packed into a "wrapper bean" and it becomes the {@link ParameterImpl} for the
055: * body.
056: *
057: * <p>
058: * This parameter is only used for the {@link ParameterBinding#BODY} binding.
059: * Other parameters that bind to other parts (such as headers or unbound)
060: * will show up directly under {@link JavaMethod}.
061: *
062: * @author Vivek Pandey
063: */
064: public class WrapperParameter extends ParameterImpl {
065: protected final List<ParameterImpl> wrapperChildren = new ArrayList<ParameterImpl>();
066:
067: // TODO: wrapper parameter doesn't use 'typeRef' --- it only uses tag name.
068: public WrapperParameter(JavaMethodImpl parent,
069: TypeReference typeRef, Mode mode, int index) {
070: super (parent, typeRef, mode, index);
071: }
072:
073: /**
074: *
075: * @deprecated
076: * Why are you calling a method that always return true?
077: */
078: @Override
079: public boolean isWrapperStyle() {
080: return true;
081: }
082:
083: /**
084: * @return Returns the wrapperChildren.
085: */
086: public List<ParameterImpl> getWrapperChildren() {
087: return wrapperChildren;
088: }
089:
090: /**
091: * Adds a new child parameter.
092: *
093: * @param wrapperChild
094: */
095: public void addWrapperChild(ParameterImpl wrapperChild) {
096: wrapperChildren.add(wrapperChild);
097: // must bind to body. see class javadoc
098: assert wrapperChild.getBinding() == ParameterBinding.BODY;
099: }
100:
101: public void clear() {
102: wrapperChildren.clear();
103: }
104:
105: @Override
106: void fillTypes(List<TypeReference> types) {
107: super .fillTypes(types);
108: if (getParent().getBinding().isRpcLit()) {
109: // for rpc/lit, we need to individually marshal/unmarshal wrapped values,
110: // so their TypeReference needs to be collected
111: assert getTypeReference().type == CompositeStructure.class;
112: for (ParameterImpl p : wrapperChildren)
113: p.fillTypes(types);
114: }
115: }
116: }
|