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

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


        }
    }
   
    public static void initializeUnionHandler(ORB orb, CorbaObjectHandler obj,
                                              QName name, List<CorbaTypeMap> typeMaps) {
        Union unionType = (Union)obj.getType();
        // First handle the discriminator
        CorbaObjectHandler discObj = initializeObjectHandler(orb,
                                                             new QName("discriminator"),
                                                             unionType.getDiscriminator(),
                                                             typeMaps);
        ((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 =
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

                mappingType.getStructOrExceptionOrUnion().add(exceptType);
            } else if (currentNode.getNodeName().equals("corba:fixed")) {
                Fixed fixedType = getFixedDefinition(currentNode, def);
                mappingType.getStructOrExceptionOrUnion().add(fixedType);
            } else if (currentNode.getNodeName().equals("corba:union")) {
                Union unionType = getUnionDefinition(currentNode, def);
                mappingType.getStructOrExceptionOrUnion().add(unionType);
            } else if (currentNode.getNodeName().equals("corba:alias")) {
                Alias aliasType = getAliasDefinition(currentNode, def);
                mappingType.getStructOrExceptionOrUnion().add(aliasType);
            } else if (currentNode.getNodeName().equals("corba:array")) {
View Full Code Here

        }
        return fixedType;
    }

    public Union getUnionDefinition(Node node, Definition def) {
        Union unionType = new Union();
        NamedNodeMap unionAttributes = node.getAttributes();

        for (int i = 0; i < unionAttributes.getLength(); ++i) {
            if (unionAttributes.item(i).getNodeName().equals("name")) {
                unionType.setName(unionAttributes.item(i).getNodeValue());
            } else if (unionAttributes.item(i).getNodeName().equals("repositoryID")) {
                unionType.setRepositoryID(unionAttributes.item(i).getNodeValue());
            } else if (unionAttributes.item(i).getNodeName().equals("discriminator")) {
                String idlType = unionAttributes.item(i).getNodeValue();
                int seperatorIndex = idlType.indexOf(':');
                String prefix = idlType.substring(0, seperatorIndex);
                String localPart = idlType.substring(seperatorIndex + 1, idlType.length());
                unionType.setDiscriminator(new QName(def.getNamespace(prefix), localPart, prefix));
            }
        }

        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

        throws CorbaBindingException {
        CorbaUnionHandler obj = null;
        CorbaTypeImpl typeDefinition = CorbaUtils.getCorbaType(idlType, typeMaps);
       
        try {
            Union unionType = (Union)typeDefinition;
            StartElement unionStartEl = reader.nextEvent().asStartElement();
            obj = new CorbaUnionHandler(unionStartEl.getName(), idlType, tc, unionType);

            // Read the discriminator value from the reader.  We can't rely on the value from
            // Stax since it may be a default value if the caller has forgotten to explicitly
            // set the discriminator in their union class.  This could cause all sorts of
            // problems when we try create the CORBA union.  For now, we'll just read and ignore.
            // TODO: Revisit this if we want to make this assumption.
            reader.nextEvent().asStartElement().getName();
            reader.nextEvent().asCharacters();
            reader.nextEvent().asEndElement();
           
            // 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;
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 = repoString + choiceunion.getQName().getLocalPart().replace('.', '/')
            + idlversion;
        choiceunion.setRepositoryID(repoId);                               
       
        MemberType choicemem = new MemberType();
        choicemem.setName(choiceunion.getQName().getLocalPart() + "_f");
        choicemem.setIdltype(createQNameCorbaNamespace(choiceunion.getQName().getLocalPart()));         
       
        if (!isDuplicate(choiceunion)) {
            choiceunion.setQName(null);
            typeMappingType.getStructOrExceptionOrUnion().add(choiceunion);
        }
       
        return choicemem;
    }
View Full Code Here

           
       
   
    private CorbaTypeImpl createNillableUnion(QName name, QName schemaType, QName membertype) {       
       
        Union nilUnion = new Union();
        nilUnion.setName(name.getLocalPart());
        nilUnion.setType(schemaType);
        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

                           checkPrefix(typeName), 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 = createQNameTargetNamespace(defaultName.getLocalPart() + "Type");
        } else {
            name = createQNameTargetNamespace(schematypeName.getLocalPart());
        }

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

        XmlSchemaSequence stype = (XmlSchemaSequence)complex.getParticle();
        Iterator it = stype.getItems().getIterator();
        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(), 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 = new Union();
        corbaUnion.setName(name.getLocalPart());
        corbaUnion.setQName(name);       
        corbaUnion.setType(schematypeName);
        String id = repoString + name.getLocalPart().replace('.', '/') + idlversion;
        corbaUnion.setRepositoryID(id);

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

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

        //Choose an Integer as a Discriminator
        List<String> caselist = new ArrayList<String>();       
View Full Code Here

        return result;       
    }
   
    private IdlType createUnion(CorbaTypeImpl ctype, IdlScopeBase scope, String local) {
        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

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.