Examples of CorbaUnionHandler


Examples of org.apache.yoko.bindings.corba.types.CorbaUnionHandler

        return obj;
    }
   
    public void writeUnionToStax(CorbaObjectHandler obj, XMLEventWriter writer, XMLEventFactory factory)
        throws XMLStreamException {
        CorbaUnionHandler unionHandler = (CorbaUnionHandler)obj;
        CorbaObjectHandler discValue = unionHandler.getDiscriminator();
        writeObjectToStax(discValue, writer, factory, true);
        CorbaObjectHandler unionValue = unionHandler.getValue();
        writeObjectToStax(unionValue, writer, factory, true);
    }
View Full Code Here

Examples of org.apache.yoko.bindings.corba.types.CorbaUnionHandler

        java.math.BigDecimal fixedValue = stream.read_fixed().movePointLeft((int)scale);
        fixedHandler.setValue(fixedValue);
    }

    public void readUnion(CorbaObjectHandler obj) throws CorbaBindingException {
        CorbaUnionHandler unionHandler = (CorbaUnionHandler)obj;       
        CorbaObjectHandler discriminator = unionHandler.getDiscriminator();
       
        this.read(discriminator);
       
        String discLabel = null;
        if (discriminator.getTypeCodeKind().value() == TCKind._tk_enum) {
            discLabel = ((CorbaEnumHandler)discriminator).getValue();
        } else {
            discLabel = ((CorbaPrimitiveHandler)discriminator).getValueData();
        }
       
        // Now find the label in the union to get the right case
        Union unionType = (Union)unionHandler.getType();
        List<Unionbranch> branches = unionType.getUnionbranch();
        Unionbranch defaultBranch = null;
        boolean caseFound = false;
        for (Iterator<Unionbranch> iter = branches.iterator(); iter.hasNext();) {
            Unionbranch branch = iter.next();
            if (branch.isSetDefault() && branch.isDefault()) {
                defaultBranch = branch;
            }
            List<CaseType> cases = branch.getCase();
            for (Iterator<CaseType> caseIter = cases.iterator(); caseIter.hasNext();) {
                CaseType c = caseIter.next();
                if (c.getLabel().equals(discLabel)) {
                    CorbaObjectHandler branchObj = unionHandler.getBranchByName(branch.getName());
                    this.read(branchObj);
                    unionHandler.setValue(branch.getName(), branchObj);
                    caseFound = true;
                    break;
                }
            }
            if (caseFound) {
                break;
            }
        }
       
        // If we never find a case that matches the value of the discriminiator, then we must have
        // found the default case.
        if (!caseFound && defaultBranch != null) {
            CorbaObjectHandler branchObj = unionHandler.getBranchByName(defaultBranch.getName());
            this.read(branchObj);
            unionHandler.setValue(defaultBranch.getName(), branchObj);
        }
    }
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.