com.sun.xml.ws.model.WrapperParameter Maven / Gradle / Ivy
/*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the license at
* https://glassfish.dev.java.net/public/CDDLv1.0.html.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at https://glassfish.dev.java.net/public/CDDLv1.0.html.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* you own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* Copyright 2006 Sun Microsystems Inc. All Rights Reserved
*/
package com.sun.xml.ws.model;
import com.sun.xml.bind.api.CompositeStructure;
import com.sun.xml.bind.api.TypeReference;
import com.sun.xml.ws.api.model.JavaMethod;
import com.sun.xml.ws.api.model.ParameterBinding;
import javax.jws.WebParam.Mode;
import java.util.ArrayList;
import java.util.List;
/**
* {@link ParameterImpl} that represents a wrapper,
* which is a parameter that consists of multiple nested {@link ParameterImpl}s
* within, which together form a body part.
*
*
* Java method parameters represented by nested {@link ParameterImpl}s will be
* packed into a "wrapper bean" and it becomes the {@link ParameterImpl} for the
* body.
*
*
* This parameter is only used for the {@link ParameterBinding#BODY} binding.
* Other parameters that bind to other parts (such as headers or unbound)
* will show up directly under {@link JavaMethod}.
*
* @author Vivek Pandey
*/
public class WrapperParameter extends ParameterImpl {
protected final List wrapperChildren = new ArrayList();
// TODO: wrapper parameter doesn't use 'typeRef' --- it only uses tag name.
public WrapperParameter(JavaMethodImpl parent, TypeReference typeRef, Mode mode, int index) {
super(parent, typeRef, mode, index);
}
/**
*
* @deprecated
* Why are you calling a method that always return true?
*/
@Override
public boolean isWrapperStyle() {
return true;
}
/**
* @return Returns the wrapperChildren.
*/
public List getWrapperChildren() {
return wrapperChildren;
}
/**
* Adds a new child parameter.
*
* @param wrapperChild
*/
public void addWrapperChild(ParameterImpl wrapperChild) {
wrapperChildren.add(wrapperChild);
// must bind to body. see class javadoc
assert wrapperChild.getBinding()== ParameterBinding.BODY;
}
public void clear(){
wrapperChildren.clear();
}
@Override
void fillTypes(List types) {
super.fillTypes(types);
if(getParent().getBinding().isRpcLit()) {
// for rpc/lit, we need to individually marshal/unmarshal wrapped values,
// so their TypeReference needs to be collected
assert getTypeReference().type==CompositeStructure.class;
for (ParameterImpl p : wrapperChildren)
p.fillTypes(types);
}
}
}