Search in sources :

Example 1 with CaseType

use of org.apache.cxf.binding.corba.wsdl.CaseType in project cxf by apache.

the class CorbaUnionListener method determineDescriminatorValue.

private String determineDescriminatorValue(Unionbranch branch) {
    String descriminatorValue;
    // Determine the value of the discriminator.
    List<CaseType> branchCases = branch.getCase();
    if (!branchCases.isEmpty()) {
        CaseType caseLabel = branchCases.get(0);
        descriminatorValue = caseLabel.getLabel();
    } else {
        // This represents the default case.
        descriminatorValue = ((CorbaUnionHandler) handler).createDefaultDiscriminatorLabel();
    }
    return descriminatorValue;
}
Also used : CaseType(org.apache.cxf.binding.corba.wsdl.CaseType)

Example 2 with CaseType

use of org.apache.cxf.binding.corba.wsdl.CaseType in project cxf by apache.

the class WSDLTypes method processUnionBranches.

public static Union processUnionBranches(Union corbaUnion, List<MemberType> fields, List<String> caselist) {
    int caseIndex = 0;
    for (int i = 0; i < fields.size(); i++) {
        MemberType field = fields.get(i);
        Unionbranch branch = new Unionbranch();
        branch.setName(field.getName());
        branch.setIdltype(field.getIdltype());
        if (field.isSetQualified() && field.isQualified()) {
            branch.setQualified(true);
        }
        branch.setDefault(false);
        CaseType c = new CaseType();
        c.setLabel(caselist.get(caseIndex));
        caseIndex++;
        branch.getCase().add(c);
        corbaUnion.getUnionbranch().add(branch);
    }
    return corbaUnion;
}
Also used : MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) CaseType(org.apache.cxf.binding.corba.wsdl.CaseType) Unionbranch(org.apache.cxf.binding.corba.wsdl.Unionbranch)

Example 3 with CaseType

use of org.apache.cxf.binding.corba.wsdl.CaseType in project cxf by apache.

the class UnionVisitor method createCase.

private void createCase(AST caseNode, Unionbranch unionBranch) {
    AST node = caseNode.getFirstChild();
    if (node != null) {
        if (node.getType() == IDLTokenTypes.LITERAL_case) {
            // corba:case
            CaseType caseType = new CaseType();
            caseType.setLabel(node.getNextSibling().toString());
            unionBranch.getCase().add(caseType);
            // recursive call
            createCase(node, unionBranch);
        } else {
            // corba:case
            CaseType caseType = new CaseType();
            caseType.setLabel(node.toString());
            unionBranch.getCase().add(caseType);
        }
    }
}
Also used : AST(antlr.collections.AST) CaseType(org.apache.cxf.binding.corba.wsdl.CaseType)

Example 4 with CaseType

use of org.apache.cxf.binding.corba.wsdl.CaseType in project cxf by apache.

the class WSDLToIDLAction method createUnion.

private IdlType createUnion(Union u, IdlScopeBase scope, String local) throws Exception {
    boolean undefinedCircular = false;
    IdlType disc = findType(u.getDiscriminator());
    IdlUnion union = IdlUnion.create(scope, local, disc);
    scope.holdForScope(union);
    for (Unionbranch ub : u.getUnionbranch()) {
        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);
        for (CaseType cs : ub.getCase()) {
            b.addCase(cs.getLabel());
        }
        if (!undefinedCircular && !(bt instanceof IdlSequence)) {
            String mlocal = qname.getLocalPart();
            String[] mname = unscopeName(mlocal);
            undefinedCircular = null != root.lookup(mname, true);
        }
        union.addBranch(b);
    }
    if (undefinedCircular) {
        scope.parkHeld();
    } else {
        scope.promoteHeldToScope();
        if (union.isCircular()) {
            // resolving this union closed a recursion
            scope.flush();
        }
    }
    return union;
}
Also used : IdlUnionBranch(org.apache.cxf.tools.corba.common.idltypes.IdlUnionBranch) IdlSequence(org.apache.cxf.tools.corba.common.idltypes.IdlSequence) CaseType(org.apache.cxf.binding.corba.wsdl.CaseType) QName(javax.xml.namespace.QName) IdlString(org.apache.cxf.tools.corba.common.idltypes.IdlString) IdlType(org.apache.cxf.tools.corba.common.idltypes.IdlType) IdlUnion(org.apache.cxf.tools.corba.common.idltypes.IdlUnion) Unionbranch(org.apache.cxf.binding.corba.wsdl.Unionbranch)

Example 5 with CaseType

use of org.apache.cxf.binding.corba.wsdl.CaseType in project cxf by apache.

the class CorbaObjectReader method readUnion.

public void readUnion(CorbaUnionHandler unionHandler) throws CorbaBindingException {
    Union unionType = (Union) unionHandler.getType();
    List<Unionbranch> branches = unionType.getUnionbranch();
    CorbaObjectHandler discriminator = unionHandler.getDiscriminator();
    if (!branches.isEmpty()) {
        final String discLabel;
        if (discriminator.getTypeCodeKind().value() == TCKind._tk_enum) {
            CorbaEnumHandler disc = (CorbaEnumHandler) discriminator;
            readEnumDiscriminator(unionHandler, disc);
            discLabel = disc.getValue();
        } else {
            read(discriminator);
            discLabel = ((CorbaPrimitiveHandler) discriminator).getDataFromValue();
        }
        // Now find the label in the union to get the right case
        Unionbranch defaultBranch = null;
        boolean caseFound = false;
        for (Iterator<Unionbranch> branchIter = branches.iterator(); branchIter.hasNext(); ) {
            Unionbranch branch = branchIter.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().equalsIgnoreCase(discLabel)) {
                    CorbaObjectHandler branchObj = unionHandler.getBranchByName(branch.getName());
                    this.read(branchObj);
                    unionHandler.setValue(branch.getName(), branchObj);
                    caseFound = true;
                    break;
                }
            }
            if (caseFound) {
                break;
            }
        }
        // found the default case.
        if (!caseFound && defaultBranch != null) {
            CorbaObjectHandler branchObj = unionHandler.getBranchByName(defaultBranch.getName());
            this.read(branchObj);
            unionHandler.setValue(defaultBranch.getName(), branchObj);
        }
    }
}
Also used : CaseType(org.apache.cxf.binding.corba.wsdl.CaseType) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) CorbaEnumHandler(org.apache.cxf.binding.corba.types.CorbaEnumHandler) Union(org.apache.cxf.binding.corba.wsdl.Union) Unionbranch(org.apache.cxf.binding.corba.wsdl.Unionbranch)

Aggregations

CaseType (org.apache.cxf.binding.corba.wsdl.CaseType)7 Unionbranch (org.apache.cxf.binding.corba.wsdl.Unionbranch)5 Union (org.apache.cxf.binding.corba.wsdl.Union)3 QName (javax.xml.namespace.QName)2 AST (antlr.collections.AST)1 LinkedHashMap (java.util.LinkedHashMap)1 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)1 CorbaEnumHandler (org.apache.cxf.binding.corba.types.CorbaEnumHandler)1 CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)1 Enum (org.apache.cxf.binding.corba.wsdl.Enum)1 Enumerator (org.apache.cxf.binding.corba.wsdl.Enumerator)1 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)1 IdlSequence (org.apache.cxf.tools.corba.common.idltypes.IdlSequence)1 IdlString (org.apache.cxf.tools.corba.common.idltypes.IdlString)1 IdlType (org.apache.cxf.tools.corba.common.idltypes.IdlType)1 IdlUnion (org.apache.cxf.tools.corba.common.idltypes.IdlUnion)1 IdlUnionBranch (org.apache.cxf.tools.corba.common.idltypes.IdlUnionBranch)1 TypeCode (org.omg.CORBA.TypeCode)1 UnionMember (org.omg.CORBA.UnionMember)1