Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   *
   * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
   *
   * The contents of this file are subject to the terms of either the GNU
   * General Public License Version 2 only ("GPL") or the Common Development
   * and Distribution License("CDDL") (collectively, the "License").  You
   * may not use this file except in compliance with the License.  You can
  * obtain a copy of the License at
  * http://glassfish.java.net/public/CDDL+GPL_1_1.html
  * or packager/legal/LICENSE.txt.  See the License for the specific
  * language governing permissions and limitations under the License.
  *
  * When distributing the software, include this License Header Notice in each
  * file and include the License file at packager/legal/LICENSE.txt.
  *
  * GPL Classpath Exception:
  * Oracle designates this particular file as subject to the "Classpath"
  * exception as provided by Oracle in the GPL Version 2 section of the License
  * file that accompanied this code.
  *
  * Modifications:
  * If applicable, add the following below the License Header, with the fields
  * enclosed by brackets [] replaced by your own identifying information:
  * "Portions Copyright [year] [name of copyright owner]"
  *
  * Contributor(s):
  * If you wish your version of this file to be governed by only the CDDL or
  * only the GPL Version 2, indicate your decision by adding "[Contributor]
  * elects to include this software in this distribution under the [CDDL or GPL
  * Version 2] license."  If you don't indicate a single choice of license, a
  * recipient has the option to distribute your version of this file under
  * either the CDDL, the GPL Version 2 or to extend the choice of license to
  * its licensees as provided above.  However, if you add GPL Version 2 code
  * and therefore, elected the GPL Version 2 license, then the option applies
  * only if the new code is made subject to such option by the copyright
  * holder.
  */
 
 package com.sun.tools.ws.processor.modeler.wsdl;
 
 
 import java.util.List;

Utilities to be used by WSDLModeler

Author(s):
Vivek Pandey
 
 class ModelerUtils {

    
This method should be called incase of wrapper style operations. This is equivalent to wrapper style schema component or JAXB Mapping object.

Parameters:
jaxbType JAXBType from which a JAXBStructured type will be created.
Returns:
returns JAXBStructured type
 
     public static JAXBStructuredType createJAXBStructureType(JAXBType jaxbType) {
         JAXBStructuredType type = new JAXBStructuredType(jaxbType);
         type.setName(jaxbType.getName());
         type.setJavaType(jaxbType.getJavaType());
         return type;
     }

    
This method uses JAXBStructured type (wrapper style operations) and unwraps it to create list of parameters.

Parameters:
jaxbType instance of JAXBType, could be JAXBStructured type.
block The Block (body/Header/Attachment) to which the created Parameter belong.
Returns:
list of Parameters
 
     public static List<ParametercreateUnwrappedParameters(JAXBType jaxbType,
             Block block) {
         List<ParameterparamList = new ArrayList<Parameter>();
        JAXBStructuredType type = null;
        if (!(jaxbType instanceof JAXBStructuredType))
            type = createJAXBStructureType(jaxbType);
        else
            type = (JAXBStructuredTypejaxbType;
        JavaStructureType jst = new JavaStructureType(jaxbType.getJavaType()
                .getRealName(), truetype);
        type.setJavaType(jst);
        block.setType(type);
        List memberList = jaxbType.getWrapperChildren();
        Iterator props = memberList.iterator();
        while (props.hasNext()) {
            JAXBProperty prop = (JAXBPropertyprops.next();
            paramList.add(createUnwrappedParameter(propjaxbTypeblocktype,
                    jst));
        }
        return paramList;
    }

    

Parameters:
prop
jaxbType
block
Returns:
unwrapped parameter
    private static Parameter createUnwrappedParameter(JAXBProperty prop,
            JAXBType jaxbTypeBlock blockJAXBStructuredType type,
            JavaStructureType jst) {
        QName elementName = prop.getElementName();
        JavaType javaType = new JavaSimpleType(prop.getType());
        JAXBElementMember eType = new JAXBElementMember(elementNamejaxbType);
        JavaStructureMember jsm = new JavaStructureMember(elementName
                .getLocalPart(), javaTypeeType);
        eType.setJavaStructureMember(jsm);
        jst.add(jsm);
        eType.setProperty(prop);
        type.add(eType);
        JAXBType t = new JAXBType(elementNamejavaTypejaxbType
                .getJaxbMapping(), jaxbType.getJaxbModel());
        t.setUnwrapped(true);
        Parameter parameter = createParameter(elementName.getLocalPart(), tblock);
        parameter.setEmbedded(true);
        return parameter;
    }
    public static List<ParametercreateRpcLitParameters(Message messageBlock blockS2JJAXBModel jaxbModelErrorReceiverFilter errReceiver){
        RpcLitStructure rpcStruct = (RpcLitStructure)block.getType();
        List<Parameterparameters = new ArrayList<Parameter>();
        for(MessagePart part : message.getParts()){
            if(!ModelerUtils.isBoundToSOAPBody(part))
                continue;
            QName name = part.getDescriptor();
            TypeAndAnnotation typeAndAnn = jaxbModel.getJavaType(name);
            if(typeAndAnn == null){
                String msgQName = "{"+message.getDefining().getTargetNamespaceURI()+"}"+message.getName();
                errReceiver.error(part.getLocator(), ModelerMessages.WSDLMODELER_RPCLIT_UNKOWNSCHEMATYPE(name.toString(),
                        part.getName(), msgQName));
                throw new AbortException();
            }
            String type = typeAndAnn.getTypeClass().fullName();
            type = ClassNameInfo.getGenericClass(type);
            RpcLitMember param = new RpcLitMember(new QName(""part.getName()), type);
            JavaType javaType = new JavaSimpleType(new JAXBTypeAndAnnotation(typeAndAnn));
            param.setJavaType(javaType);
            rpcStruct.addRpcLitMember(param);
            Parameter parameter = ModelerUtils.createParameter(part.getName(), paramblock);
            parameter.setEmbedded(true);
            parameters.add(parameter);
        }
        return parameters;
    }

    
Called for non-wrapper style operations. It returns a Parameter constructed using the JAXBType and the Block.

Parameters:
partName typically wsdl:part or any name to be given to the parameter
jaxbType type of Parameter
block Block to which the parameter belongs to
Returns:
Parameter created.
    public static Parameter createParameter(String partNameAbstractType jaxbType,
            Block block) {
        Parameter parameter = new Parameter(partNameblock.getEntity());
                partName);
        parameter.setEmbedded(false);
        parameter.setType(jaxbType);        
        parameter.setTypeName(jaxbType.getJavaType().getType().getName());
        parameter.setBlock(block);
        return parameter;
    }

    
Get Parameter from the list of parameters.

Parameters:
paramName
parameters
Returns:
the Parameter with name paramName from parameters
    public static Parameter getParameter(String paramNameList<Parameterparameters){
        if(parameters == null)
            return null;
        for(Parameter paramparameters){
            //if(param.getName().equals("_return") && paramName.equals("return") || param.getName().equals(paramName)) {
            if(param.getName().equals(paramName)){
                return param;
            }
        }
        return null;
    }

    
Compares two JAXBStructures.

Parameters:
struct1
struct2
Returns:
true if struct1 and struct2 are equivalent.
    public static boolean isEquivalentLiteralStructures(
        JAXBStructuredType struct1,
        JAXBStructuredType struct2) {
        if (struct1.getElementMembersCount() != struct2.getElementMembersCount())
            return false;
        Iterator members = struct1.getElementMembers();
        JAXBElementMember member1;
        JavaStructureMember javaMember1javaMember2;
        for (int i = 0; members.hasNext(); i++) {
            member1 = (JAXBElementMember)members.next();
            javaMember1 = member1.getJavaStructureMember();
            javaMember2 =
                ((JavaStructureType)struct2.getJavaType()).getMemberByName(
                    member1.getJavaStructureMember().getName());
            if (javaMember2.getConstructorPos() != i
                || !javaMember1.getType().equals(javaMember2.getType())) {
                return false;
            }
        }
        return false;
    }
    public static QName getRawTypeName(Parameter parameter) {
        String name = parameter.getName();
        if (parameter.getType() instanceof JAXBType) {
            JAXBType jt = (JAXBType)parameter.getType();
            if (jt.isUnwrappable()) {
                List<JAXBPropertyprops = jt.getWrapperChildren();
                for(JAXBProperty propprops) {
                    if (prop.getName().equals(name)) {
                        return prop.getRawTypeName();
                    }
                }
            }
        }
        return null;
    }

    

Parameters:
part
Returns:
true if part is bound to Mime content
    public static boolean isBoundToMimeContent(MessagePart part) {
        if((part != null) && part.getBindingExtensibilityElementKind() == .)
            return true;
        return false;
    }

    

Parameters:
part
Returns:
true if part is bound to SOAPBody
    public static boolean isBoundToSOAPBody(MessagePart part) {
        if((part != null) && part.getBindingExtensibilityElementKind() == .)
            return true;
        return false;
    }

    

Parameters:
part
Returns:
true if part is bound to SOAPHeader
    public static boolean isBoundToSOAPHeader(MessagePart part) {
        if((part != null) && part.getBindingExtensibilityElementKind() == .)
            return true;
        return false;
    }
    public static boolean isUnbound(MessagePart part) {
        if((part != null) && part.getBindingExtensibilityElementKind() == .)
            return true;
        return false;
    }
New to GrepCode? Check out our FAQ X