Package org.apache.schemas.yoko.bindings.corba

Examples of org.apache.schemas.yoko.bindings.corba.Union


        return result;       
    }
   
    private IdlType createUnion(CorbaTypeImpl ctype, IdlScopeBase scope,
                                String local) throws Exception {
        Union u = (Union)ctype;
        boolean undefinedCircular = false;
        IdlType disc = findType(u.getDiscriminator());
        IdlUnion union = IdlUnion.create(scope, local, disc);
        scope.holdForScope(union);

        Iterator it = u.getUnionbranch().iterator();
        while (it.hasNext()) {
            Unionbranch ub = (Unionbranch)it.next();
            QName qname = ub.getIdltype();
            IdlType bt = findType(qname);
            boolean isDefault = false;
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

            assertEquals("Name is incorrect for AnonString Type", "attrib2Type",
                         str.getName());
            assertEquals("Type is incorrect for AnonString Type", "string",
                         str.getType().getLocalPart());           

            Union un = (Union)mapType.getStructOrExceptionOrUnion().get(7);
            assertEquals("Name is incorrect for Union Type", "attrib2Type_nil",
                         un.getName());
            assertEquals("Type is incorrect for Union Type", "attrib2",
                         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", "attrib2Type",
                         unbranch.getIdltype().getLocalPart());
View Full Code Here

    public CorbaUnionHandler(QName unionName, QName unionIdlType, TypeCode unionTC, Object unionType) {
        super(unionName, unionIdlType, unionTC, unionType);
       
        // Build a list of labels.  This will be used to generate a discriminator value for the
        // default case (since we are not provided with one from the Stax stream of the Celtix object)
        Union union = (Union)unionType;
        List<Unionbranch> branches = union.getUnionbranch();
        int index = 0;
        for (Iterator<Unionbranch> branchesIter = branches.iterator(); branchesIter.hasNext();) {
            Unionbranch branch = branchesIter.next();
            List<CaseType> branchCases = branch.getCase();
            if (branchCases.size() == 0) {
View Full Code Here

                                              CorbaObjectHandler obj,
                                              QName name,
                                              XmlSchemaObject schemaType,
                                              List<CorbaTypeMap> typeMaps,
                                              ServiceInfo serviceInfo) {
        Union unionType = (Union)obj.getType();
        // First handle the discriminator
        CorbaObjectHandler discObj = initializeObjectHandler(orb,
                                                             new QName("discriminator"),
                                                             unionType.getDiscriminator(),
                                                             typeMaps,
                                                             serviceInfo);
        ((CorbaUnionHandler)obj).setDiscriminator(discObj);
        boolean isAttr = false;
        boolean isElementNil = false;
        XmlSchemaObject stype = schemaType;
        QName qname = name;
        if (schemaType instanceof XmlSchemaAttribute) {
            XmlSchemaAttribute attr = (XmlSchemaAttribute) schemaType;
            if (attr.getQName() != null) {
                qname = attr.getQName();
            }
            isAttr = true;
        } else if (schemaType instanceof XmlSchemaElement) {
            XmlSchemaElement el = (XmlSchemaElement) schemaType;
            if (el.isNillable()) {
                //should not write the start Element.
                isElementNil = true;
            }
            if (el.getQName() != null) {
                qname = el.getQName();
            }
            stype = el.getSchemaType();
            if (stype == null) {
                stype = CorbaUtils.getXmlSchemaType(serviceInfo, el.getRefName());
            }
        }
        String nsURI = getNamespaceURI(serviceInfo, qname);
        // Now handle all of the branches
        List<Unionbranch> unionBranches = unionType.getUnionbranch();
        for (Iterator<Unionbranch> iter = unionBranches.iterator(); iter.hasNext();) {
            Unionbranch branch = iter.next();
            QName branchName = new QName(nsURI, branch.getName());
            QName branchIdlType = branch.getIdltype();
            CorbaObjectHandler branchObj =
View Full Code Here

        choice.setMaxOccurs(1);
        sequence.getItems().add(choice);
       
       
        // corba:union
        Union corbaUnion = new Union();
        corbaUnion.setQName(new QName(typeMap.getTargetNamespace(), unionScope.toString()));
        corbaUnion.setRepositoryID(unionScope.toIDLRepositoryID());
        corbaUnion.setType(unionSchemaComplexType.getQName());
        corbaUnion.setDiscriminator(ctype.getQName());
       
        processCaseNodes(caseNode, unionScope, choice, corbaUnion);

        // add schemaType
        schema.getItems().add(unionSchemaComplexType);
View Full Code Here

                                                                      QName name,
                                                                      QName idlType,
                                                                      TypeCode tc,
                                                                      XmlSchemaObject schemaType)
        throws CorbaBindingException {
        Union unionType = (Union) CorbaUtils.getCorbaType(idlType, typeMaps);
        CorbaUnionHandler obj = new CorbaUnionHandler(name, idlType, tc, unionType);
        CorbaPrimitiveHandler discObj =
            new CorbaPrimitiveHandler(new QName("discriminator"),
                                      unionType.getDiscriminator(),
                                      orb.get_primitive_tc(TCKind.from_int(TCKind._tk_boolean)),
                                      null);

        //only one union branch for a attribute / element nillable types.
        List<Unionbranch> branches = unionType.getUnionbranch();
        try {
            XMLEvent evt = reader.peek();
            if (schemaType instanceof XmlSchemaAttribute) {
                CorbaPrimitiveHandler value = getAttributeValue(evt, name, branches.get(0).getIdltype());
                if (value != null) {
View Full Code Here

                                                    XmlSchemaObject schemaType)
        throws CorbaBindingException {
        CorbaUnionHandler obj = null;
        try {
            XmlSchemaChoice choiceType = (XmlSchemaChoice) schemaType;
            Union unionType = (Union) CorbaUtils.getCorbaType(idlType, typeMaps);
            QName elName = reader.nextEvent().asStartElement().getName();
            obj = new CorbaUnionHandler(elName, idlType, tc, unionType);
            // Build the entire union with all branches, etc.  Then read info from the XML Event Reader
            String branchName = null;
            XMLEvent evt = reader.peek();
            if (evt.isStartElement()) {
                StartElement branchElement = evt.asStartElement();
                branchName = branchElement.getName().getLocalPart();
            }
            List<Unionbranch> branches = unionType.getUnionbranch();
            XmlSchemaObjectCollection items = choiceType.getItems();               
            for (int i = 0; i < branches.size(); i++) {
                Unionbranch branch = branches.get(i);
                CorbaObjectHandler branchObj = null;
                if (branch.getName().equals(branchName)) {
                    branchObj = readObjectFromStax(reader, branch.getIdltype(), items.getItem(i), true);
                    // We also need to set the discriminator since this is the branch with the actual
                    // union value
                    CorbaObjectHandler discObj =
                        CorbaHandlerUtils.createTypeHandler(orb,
                                                            new QName("discriminator"),
                                                            unionType.getDiscriminator(),
                                                            typeMaps,
                                                            serviceInfo);
                    obj.setDiscriminator(discObj);
                   
                    // Determine the value of the discriminator. 
View Full Code Here

    public void testReadWriteUnionStruct() {       
        QName objName = new QName("object");
        QName objIdlType = new QName(staxTestNamespaceURI, "TestUnion", staxTestPrefix);
        CorbaTypeImpl type = CorbaUtils.getCorbaType(objIdlType, staxObject.getTypeMaps());
        assertTrue(type instanceof Union);
        Union unionType = (Union)type;
        TypeCode objTypeCode = CorbaUtils.getTypeCode(orb, objIdlType, staxObject.getTypeMaps());
        CorbaUnionHandler obj = new CorbaUnionHandler(objName, objIdlType, objTypeCode, unionType);
        assertNotNull(obj);
       
        Character unionValue = new Character('u');
        TypeCode unionValueTC = CorbaUtils.getTypeCode(orb, CorbaConstants.NT_CORBA_WCHAR,
                                                       staxObject.getTypeMaps());
        CorbaPrimitiveHandler unionValueObj = new CorbaPrimitiveHandler(new QName("case12"),
                                                                        CorbaConstants.NT_CORBA_WCHAR,
                                                                        unionValueTC,
                                                                        null);
        unionValueObj.setValue(unionValue);
        Short discriminatorValue = new Short((short)1);
        TypeCode discriminatorTC = CorbaUtils.getTypeCode(orb, unionType.getDiscriminator(),
                                                          staxObject.getTypeMaps());
        CorbaPrimitiveHandler discriminator = new CorbaPrimitiveHandler(new QName("discriminator"),
                                                                       unionType.getDiscriminator(),
                                                                       discriminatorTC,
                                                                       null);
        discriminator.setValue(discriminatorValue);

        obj.setDiscriminator(discriminator);
View Full Code Here

        fixedHandler.setValue(fixedValue);
    }

    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) {
            this.read(discriminator);
            String discLabel = null;
            if (discriminator.getTypeCodeKind().value() == TCKind._tk_enum) {
View Full Code Here

TOP

Related Classes of org.apache.schemas.yoko.bindings.corba.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.