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

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


    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<MemberType> fields = processContainerAsMembers(choice, defaultName, schematypeName);
View Full Code Here


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

    public void readUnion(CorbaUnionHandler unionHandler) throws CorbaBindingException {
        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

    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,
                                       members.values().toArray(
                                           new UnionMember[members.size()]));
        }
    }
View Full Code Here

            stream.write_fixed(fixedHandler.getValue().movePointRight(scale));
        }
    }

    public void writeUnion(CorbaObjectHandler obj) throws CorbaBindingException {
        Union unionType = (Union) obj.getType();       
        List<Unionbranch> branches = unionType.getUnionbranch();
        if (branches.size() > 0) {            
            CorbaObjectHandler discriminator = ((CorbaUnionHandler)obj).getDiscriminator();
            this.write(discriminator);
            CorbaObjectHandler unionValue = ((CorbaUnionHandler)obj).getValue();
            if (unionValue != null) {
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,
                                       members.values().toArray(
                                           new UnionMember[members.size()]));
        }
    }
View Full Code Here

        long scale = fixedHandler.getScale();
        stream.write_fixed(fixedHandler.getValue().movePointRight((int)scale));
    }

    public void writeUnion(CorbaObjectHandler obj) throws CorbaBindingException {
        Union unionType = (Union) obj.getType();       
        List<Unionbranch> branches = unionType.getUnionbranch();
        if (branches.size() > 0) {            
            CorbaObjectHandler discriminator = ((CorbaUnionHandler)obj).getDiscriminator();
            this.write(discriminator);
            CorbaObjectHandler unionValue = ((CorbaUnionHandler)obj).getValue();
            if (unionValue != null) {
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

    public static void initializeUnionHandler(ORB orb,
                                              CorbaObjectHandler obj,
                                              CorbaTypeMap typeMap,
                                              ServiceInfo serviceInfo,
                                              Map<QName, CorbaObjectHandler> seenTypes) {
        Union unionType = (Union)obj.getType();
        // First handle the discriminator
        CorbaObjectHandler discObj = initializeObjectHandler(orb,
                                                             new QName("discriminator"),
                                                             unionType.getDiscriminator(),
                                                             typeMap,
                                                             serviceInfo,
                                                             seenTypes);
        ((CorbaUnionHandler)obj).setDiscriminator(discObj);
        QName typeName = unionType.getType();

        seenTypes.put(obj.getIdlType(), obj);

        // Now handle all of the branches
        List<Unionbranch> unionBranches = unionType.getUnionbranch();
        for (int i = 0; i < unionBranches.size(); i++) {
            Unionbranch branch = unionBranches.get(i);
            QName branchName;
            if (branch.isSetQualified() && branch.isQualified() && (typeName != null)) {
                branchName = new QName(typeName.getNamespaceURI(), branch.getName());
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

    public static void initializeUnionHandler(ORB orb,
                                              CorbaObjectHandler obj,
                                              CorbaTypeMap typeMap,
                                              ServiceInfo serviceInfo,
                                              Map<QName, CorbaObjectHandler> seenTypes) {
        Union unionType = (Union)obj.getType();
        // First handle the discriminator
        CorbaObjectHandler discObj = initializeObjectHandler(orb,
                                                             new QName("discriminator"),
                                                             unionType.getDiscriminator(),
                                                             typeMap,
                                                             serviceInfo,
                                                             seenTypes);
        ((CorbaUnionHandler)obj).setDiscriminator(discObj);
        QName typeName = unionType.getType();

        seenTypes.put(obj.getIdlType(), obj);

        // Now handle all of the branches
        List<Unionbranch> unionBranches = unionType.getUnionbranch();
        for (int i = 0; i < unionBranches.size(); i++) {
            Unionbranch branch = unionBranches.get(i);
            QName branchName;
            if (branch.isSetQualified() && branch.isQualified() && (typeName != null)) {
                branchName = new QName(typeName.getNamespaceURI(), branch.getName());
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.