Package org.apache.cxf.binding.corba.wsdl

Examples of org.apache.cxf.binding.corba.wsdl.Union


            WSDLToIDLAction idlgen = new WSDLToIDLAction();
            idlgen.setBindingName("NillableCORBABinding");
            idlgen.setOutputFile("nillable.idl");
            idlgen.generateIDL(model);
           
            Union un = (Union)mapType.getStructOrExceptionOrUnion().get(2);
            assertEquals("Name is incorrect for Union Type", "long_nil",
                         un.getName());
            assertEquals("Type is incorrect for Union Type", "PEl",
                         un.getType().getLocalPart());
            Unionbranch unbranch = un.getUnionbranch().get(0);
            assertEquals("Name is incorrect for UnionBranch Type", "value",
                         unbranch.getName());
            assertEquals("Type is incorrect for UnionBranch Type", "long",
                         unbranch.getIdltype().getLocalPart());
View Full Code Here


        disc.setValue(enumerators.get(enumIndex).getValue());
    }

    public void readUnion(CorbaObjectHandler obj) throws CorbaBindingException {
        CorbaUnionHandler unionHandler = (CorbaUnionHandler)obj;
        Union unionType = (Union)unionHandler.getType();
        List<Unionbranch> branches = unionType.getUnionbranch();
        CorbaObjectHandler discriminator = unionHandler.getDiscriminator();
        if (branches.size() > 0) {
            String discLabel = null;
            if (discriminator.getTypeCodeKind().value() == TCKind._tk_enum) {
                CorbaEnumHandler disc = (CorbaEnumHandler) discriminator;
View Full Code Here

    protected MemberType processComplexContentStructChoice(XmlSchemaChoice choice,
                                                     QName schematypeName, QName defaultName)
        throws Exception {
        QName choicename = createQNameTargetNamespace(schematypeName.getLocalPart() + "ChoiceType");
        Union choiceunion = createUnion(choicename, choice,
                                        defaultName, schematypeName);

        String repoId = REPO_STRING + choiceunion.getQName().getLocalPart().replace('.', '/')
            + IDL_VERSION;
        choiceunion.setRepositoryID(repoId);

        MemberType choicemem = new MemberType();
        choicemem.setName(choiceunion.getQName().getLocalPart() + "_f");
        choicemem.setIdltype(createQNameCorbaNamespace(choiceunion.getQName().getLocalPart()));

        if ((choiceunion != null) && (!isDuplicate(choiceunion))) {
            typeMappingType.getStructOrExceptionOrUnion().add(choiceunion);
        }
View Full Code Here

    protected CorbaTypeImpl createNillableUnion(QName name,
                                                QName schemaType,
                                                QName membertype,
                                                boolean isQualified) {

        Union nilUnion = new Union();
        nilUnion.setName(name.getLocalPart());
        nilUnion.setType(schemaType);
        nilUnion.setQName(name);
        nilUnion.setDiscriminator(CorbaConstants.NT_CORBA_BOOLEAN);
        String id = REPO_STRING + nilUnion.getQName().getLocalPart().replace('.', '/') + IDL_VERSION;
        nilUnion.setRepositoryID(id);

        Unionbranch branch = new Unionbranch();
        branch.setName("value");
        branch.setIdltype(membertype);
        branch.setDefault(false);
        if (isQualified) {
            branch.setQualified(true);
        }
        CaseType caseType = new CaseType();
        caseType.setLabel("TRUE");
        branch.getCase().add(caseType);
        nilUnion.getUnionbranch().add(branch);
        nilUnion.setNillable(true);
        return nilUnion;
    }
View Full Code Here

                           maxOccurs, minOccurs, anonymous);
    }

    private CorbaTypeImpl processOMGUnion(XmlSchemaComplexType complex, QName defaultName) throws Exception {
        QName name;
        Union corbaUnion = null;
        QName schematypeName = checkPrefix(complex.getQName());

        if (schematypeName == null) {
            schematypeName = defaultName;
            name = createQNameCorbaNamespace(defaultName.getLocalPart() + "Type");
        } else {
            name = createQNameCorbaNamespace(schematypeName.getLocalPart());
        }

        corbaUnion = new Union();
        corbaUnion.setName(name.getLocalPart());
        corbaUnion.setQName(name);
        String id = REPO_STRING + name.getLocalPart().replace('.', '/') + IDL_VERSION;
        corbaUnion.setRepositoryID(id);
        corbaUnion.setType(schematypeName);

        XmlSchemaSequence stype = (XmlSchemaSequence)complex.getParticle();
        Iterator it = stype.getItems().iterator();
        XmlSchemaParticle st1 = (XmlSchemaParticle)it.next();
        XmlSchemaParticle st2 = (XmlSchemaParticle)it.next();
        XmlSchemaElement discEl = null;
        XmlSchemaChoice choice = null;

        if (st1 instanceof XmlSchemaElement) {
            discEl = (XmlSchemaElement)st1;
            choice = (XmlSchemaChoice)st2;
        } else {
            discEl = (XmlSchemaElement)st2;
            choice = (XmlSchemaChoice)st1;
        }

        CorbaTypeImpl disctype = convertSchemaToCorbaType(discEl.getSchemaType(), discEl.getQName(), discEl
            .getSchemaType(), null, false);
        corbaUnion.setDiscriminator(disctype.getQName());

        List fields = processContainerAsMembers(choice, defaultName, schematypeName);

        List<String> caselist = new ArrayList<String>();
View Full Code Here

    protected Union createUnion(QName name, XmlSchemaChoice choice, QName defaultName,
                                QName schematypeName)
        throws Exception {

        Union corbaUnion = null;
        if (recursionMap.get(name) instanceof Union) {
            corbaUnion = (Union)recursionMap.get(name);
            if (corbaUnion != null) {
                return corbaUnion;
            }
        }

        corbaUnion = new Union();
        corbaUnion.setName(name.getLocalPart());
        corbaUnion.setQName(name);
        corbaUnion.setType(schematypeName);
        String id = REPO_STRING + name.getLocalPart().replace('.', '/') + IDL_VERSION;
        corbaUnion.setRepositoryID(id);

        //Set Integer as Discriminator
        corbaUnion.setDiscriminator(CorbaConstants.NT_CORBA_LONG);

        // add to the list of possible recursive types
        recursionMap.put(name, corbaUnion);

        List fields = processContainerAsMembers(choice, defaultName, schematypeName);
View Full Code Here

            WSDLToIDLAction idlgen = new WSDLToIDLAction();
            idlgen.setBindingName("NillableCORBABinding");
            idlgen.setOutputFile("nillable.idl");
            idlgen.generateIDL(model);
           
            Union un = (Union)mapType.getStructOrExceptionOrUnion().get(2);
            assertEquals("Name is incorrect for Union Type", "long_nil",
                         un.getName());
            assertEquals("Type is incorrect for Union Type", "PEl",
                         un.getType().getLocalPart());
            Unionbranch unbranch = un.getUnionbranch().get(0);
            assertEquals("Name is incorrect for UnionBranch Type", "value",
                         unbranch.getName());
            assertEquals("Type is incorrect for UnionBranch Type", "long",
                         unbranch.getIdltype().getLocalPart());
View Full Code Here

    public static TypeCode getUnionTypeCode(ORB orb,
                                            Object obj,
                                            CorbaTypeMap typeMap,
                                            Stack<QName> seenTypes) {
        Union unionType = (Union)obj;

        if (seenTypes.contains(new QName(unionType.getName()))) {
            return orb.create_recursive_tc(unionType.getRepositoryID());
        } else {
            seenTypes.push(new QName(unionType.getName()));

            TypeCode discTC = getTypeCode(orb, unionType.getDiscriminator(), typeMap, seenTypes);
            Map<String, UnionMember> members = new LinkedHashMap<String, UnionMember>();
            List<Unionbranch> branches = unionType.getUnionbranch();
            for (Iterator<Unionbranch> branchIter = branches.iterator(); branchIter.hasNext();) {
                Unionbranch branch = branchIter.next();
                List<CaseType> cases = branch.getCase();
                for (Iterator<CaseType> caseIter = cases.iterator(); caseIter.hasNext();) {
                    CaseType cs = caseIter.next();
                    if (!members.containsKey(cs.getLabel())) {
                        UnionMember member = new UnionMember();
                        member.name = branch.getName();
                        member.type = getTypeCode(orb, branch.getIdltype(), typeMap, seenTypes);
                        member.label = orb.create_any();
                        // We need to insert the labels in a way that depends on the type of the
                        // discriminator.  According to the CORBA specification, the following types
                        // are permissable as discriminator types:
                        //    * signed & unsigned short
                        //    * signed & unsigned long
                        //    * signed & unsigned long long
                        //    * char
                        //    * boolean
                        //    * enum
                        switch (discTC.kind().value()) {
                        case TCKind._tk_short:
                            member.label.insert_short(Short.parseShort(cs.getLabel()));
                            break;
                        case TCKind._tk_ushort:
                            member.label.insert_ushort(Short.parseShort(cs.getLabel()));
                            break;
                        case TCKind._tk_long:
                            member.label.insert_long(Integer.parseInt(cs.getLabel()));
                            break;
                        case TCKind._tk_ulong:
                            member.label.insert_ulong(Integer.parseInt(cs.getLabel()));
                            break;
                        case TCKind._tk_longlong:
                            member.label.insert_longlong(Long.parseLong(cs.getLabel()));
                            break;
                        case TCKind._tk_ulonglong:
                            member.label.insert_ulonglong(Long.parseLong(cs.getLabel()));
                            break;
                        case TCKind._tk_char:
                            member.label.insert_char(cs.getLabel().charAt(0));
                            break;
                        case TCKind._tk_boolean:
                            member.label.insert_boolean(Boolean.parseBoolean(cs.getLabel()));
                            break;
                        case TCKind._tk_enum:
                            org.omg.CORBA.portable.OutputStream out =
                                member.label.create_output_stream();
                            Enum enumVal = (Enum)getCorbaType(unionType.getDiscriminator(), typeMap);
                            List<Enumerator> enumerators = enumVal.getEnumerator();
                            for (int i = 0; i < enumerators.size(); ++i) {
                                Enumerator e = enumerators.get(i);
                                if (e.getValue().equals(cs.getLabel())) {
                                    out.write_long(i);
                                }
                            }
                            member.label.read_value(out.create_input_stream(), discTC);
                            break;
                        default:
                            throw new CorbaBindingException("Unsupported discriminator type");
                        }
                        // Some orbs are strict on how the case labels are stored for
                        // each member.  So we can't
                        // simply insert the labels as strings
                        members.put(cs.getLabel(), member);
                    }
                }
            }
            seenTypes.pop();
            return orb.create_union_tc(unionType.getRepositoryID(),
                                       getTypeCodeName(unionType.getName()),
                                       discTC,
                                       (UnionMember[])members.values().toArray(
                                           new UnionMember[members.size()]));
        }
    }
View Full Code Here

    protected MemberType processComplexContentStructChoice(XmlSchemaChoice choice,
                                                     QName schematypeName, QName defaultName)
        throws Exception {
        QName choicename = createQNameTargetNamespace(schematypeName.getLocalPart() + "ChoiceType");
        Union choiceunion = createUnion(choicename, choice,
                                        defaultName, schematypeName);

        String repoId = REPO_STRING + choiceunion.getQName().getLocalPart().replace('.', '/')
            + IDL_VERSION;
        choiceunion.setRepositoryID(repoId);

        MemberType choicemem = new MemberType();
        choicemem.setName(choiceunion.getQName().getLocalPart() + "_f");
        choicemem.setIdltype(createQNameCorbaNamespace(choiceunion.getQName().getLocalPart()));

        if ((choiceunion != null) && (!isDuplicate(choiceunion))) {
            typeMappingType.getStructOrExceptionOrUnion().add(choiceunion);
        }
View Full Code Here

    protected CorbaTypeImpl createNillableUnion(QName name,
                                                QName schemaType,
                                                QName membertype,
                                                boolean isQualified) {

        Union nilUnion = new Union();
        nilUnion.setName(name.getLocalPart());
        nilUnion.setType(schemaType);
        nilUnion.setQName(name);
        nilUnion.setDiscriminator(CorbaConstants.NT_CORBA_BOOLEAN);
        String id = REPO_STRING + nilUnion.getQName().getLocalPart().replace('.', '/') + IDL_VERSION;
        nilUnion.setRepositoryID(id);

        Unionbranch branch = new Unionbranch();
        branch.setName("value");
        branch.setIdltype(membertype);
        branch.setDefault(false);
        if (isQualified) {
            branch.setQualified(true);
        }
        CaseType caseType = new CaseType();
        caseType.setLabel("TRUE");
        branch.getCase().add(caseType);
        nilUnion.getUnionbranch().add(branch);
        nilUnion.setNillable(true);
        return nilUnion;
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.binding.corba.wsdl.Union

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.