Examples of Unionbranch


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

            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());

            File f = new File("typeInherit.idl");
            assertTrue("typeInherit.idl should be generated", f.exists());
        } finally {
            new File("typeInherit.idl").deleteOnExit();
View Full Code Here

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

    public Union processUnionBranches(Union corbaUnion, List fields, List<String> caselist) {
        int caseIndex = 0;

        for (int i = 0; i < fields.size(); i++) {
            MemberType field = (MemberType)fields.get(i);
            Unionbranch branch = new Unionbranch();
            branch.setName(field.getName());
            branch.setIdltype(field.getIdltype());
            branch.setDefault(false);                        

            CaseType c = new CaseType();
            c.setLabel((String)caselist.get(caseIndex));
            caseIndex++;
            branch.getCase().add(c);
            corbaUnion.getUnionbranch().add(branch);
        }
        return corbaUnion;
    }   
View Full Code Here

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

           
            // xmlschema:element
            XmlSchemaElement element = new XmlSchemaElement();

            // corba:unionbranch
            Unionbranch unionBranch = new Unionbranch();

            if (caseNode.getType() == IDLTokenTypes.LITERAL_default) {
                // default:
                unionBranch.setDefault(true);
               
                typeNode = caseNode.getFirstChild();
                nameNode = typeNode.getNextSibling();
            } else {
                // case:
                createCase(caseNode, unionBranch);
               
                labelNode = caseNode.getFirstChild();
                if (labelNode.getType() == IDLTokenTypes.LITERAL_case) {
                    labelNode = labelNode.getNextSibling();
                }
               
                typeNode = labelNode.getNextSibling();
                nameNode = typeNode.getNextSibling();
            }
           
            // xmlschema:element
            element.setName(nameNode.toString());
            XmlSchemaType type = TypesUtils.findType(schemas, schema, typeNode);
            element.setSchemaTypeName(type.getQName());
            choice.getItems().add(element);
           
           
            // corba:unionbranch
            unionBranch.setName(nameNode.toString());
            QName idlType = TypesUtils.findCorbaType(typeMap, type.getQName()).getQName();
            unionBranch.setIdltype(idlType);
            corbaUnion.getUnionbranch().add(unionBranch);
           
           
            caseNode = caseNode.getNextSibling();
        }
View Full Code Here

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

        ((CorbaUnionHandler)obj).setDiscriminator(discObj);
       
        // 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(name.getNamespaceURI(), branch.getName());
            QName branchIdlType = branch.getIdltype();
            CorbaObjectHandler branchObj =
                initializeObjectHandler(orb, branchName, branchIdlType, typeMaps);
            ((CorbaUnionHandler)obj).addCase(branchObj);
        }
    }
View Full Code Here

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

        // 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) {
                defaultIndex = index;
            } else {
                for (Iterator<CaseType> casesIter = branchCases.iterator(); casesIter.hasNext();) {
                    CaseType ct = casesIter.next();
View Full Code Here

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

        NodeList unionChildNodes = node.getChildNodes();
        for (int i = 0; i < unionChildNodes.getLength(); ++i) {
            Node currentNode = unionChildNodes.item(i);
           
            if (currentNode.getNodeName().equals("corba:unionbranch")) {
                Unionbranch branch = getUnionBranch(currentNode, def);
                unionType.getUnionbranch().add(branch);
            }
        }
       
        return unionType;
View Full Code Here

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

       
        return unionType;
    }
   
    public Unionbranch getUnionBranch(Node node, Definition def) {
        Unionbranch branchType = new Unionbranch();
        NamedNodeMap branchAttributes = node.getAttributes();
       
        for (int i = 0; i < branchAttributes.getLength(); ++i) {
            if (branchAttributes.item(i).getNodeName().equals("name")) {
                branchType.setName(branchAttributes.item(i).getNodeValue());
            } else if (branchAttributes.item(i).getNodeName().equals("idltype")) {
                String idlType = branchAttributes.item(i).getNodeValue();
                int seperatorIndex = idlType.indexOf(':');
                String prefix = idlType.substring(0, seperatorIndex);
                String localPart = idlType.substring(seperatorIndex + 1, idlType.length());
                branchType.setIdltype(new QName(def.getNamespace(prefix), localPart, prefix));
            } else if (branchAttributes.item(i).getNodeName().equals("default")) {
                Boolean defaultValue = new Boolean(branchAttributes.item(i).getNodeValue());
                branchType.setDefault(defaultValue);
            }
        }
       
        NodeList branchChildNodes = node.getChildNodes();
        for (int i = 0; i < branchChildNodes.getLength(); ++i) {
            Node currentNode = branchChildNodes.item(i);
           
            if (currentNode.getNodeName().equals("corba:case")) {
                CaseType caseType = new CaseType();
                NamedNodeMap caseAttributes = currentNode.getAttributes();
               
                for (int j = 0; j < caseAttributes.getLength(); ++j) {
                    if (caseAttributes.item(j).getNodeName().equals("label")) {
                        caseType.setLabel(caseAttributes.item(j).getNodeValue());
                    }
                }
                branchType.getCase().add(caseType);
            }
        }
       
        return branchType;
    }
View Full Code Here

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

            // Build the entire union with all branches, etc.  Then read info from the XML Event Reader
            StartElement branchElement = reader.peek().asStartElement();
            String branchName = branchElement.getName().getLocalPart();
            List<Unionbranch> branches = unionType.getUnionbranch();
            for (Iterator<Unionbranch> iter = branches.iterator(); iter.hasNext();) {
                Unionbranch branch = iter.next();
                CorbaObjectHandler branchObj = null;
                if (branch.getName().equals(branchName)) {
                    branchObj = readObjectFromStax(reader, branch.getIdltype(), 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);
                    obj.setDiscriminator(discObj);

                    // Determine the value of the discriminator. 
                    List<CaseType> branchCases = branch.getCase();
                    String discValue = null;
                    if (branchCases.size() != 0) {
                        // This represents a union case.  Set the discriminator based on the first
                        // label value associated with the branch (since we don't have this information)
                        // from the Stax representation of the Celtix object).
                        CaseType caseLabel = branchCases.get(0);
                        discValue = caseLabel.getLabel();
                    } else {
                        // This represents the default case.  Since Celtix does not provide a
                        // discriminator value, we'll create one.
                        discValue = obj.createDefaultDiscriminatorLabel();
                    }
                    obj.setDiscriminatorValueFromData(discValue);
                    obj.setValue(branchName, branchObj);
                } else {
                    // Create an object holder with no value
                    branchObj = CorbaHandlerUtils.createTypeHandler(orb, new QName(branch.getName()),
                                                                    branch.getIdltype(), typeMaps);
                }
                obj.addCase(branchObj);
            }
            reader.nextEvent().asEndElement();
        } catch (java.lang.Exception ex) {
View Full Code Here

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

        nilUnion.setQName(name);
        nilUnion.setDiscriminator(CorbaConstants.NT_CORBA_BOOLEAN);
        String id = repoString + nilUnion.getQName().getLocalPart().replace('.', '/') + idlversion;
        nilUnion.setRepositoryID(id);

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

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

        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;
            if (ub.isSetDefault()) {
                isDefault = ub.isDefault();
            }
            IdlUnionBranch b = IdlUnionBranch.create(union, ub.getName(), bt, isDefault);

            Iterator it2 = ub.getCase().iterator();
            while (it2.hasNext()) {               
                b.addCase(((CaseType)it2.next()).getLabel());
            }

            // Ensure that this union will not  be written until all of its circular members are
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.