Search in sources :

Example 1 with Enumerator

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

the class CorbaObjectReader method readEnum.

// -- complex types --
public void readEnum(CorbaObjectHandler obj) throws CorbaBindingException {
    int enumIndex = stream.read_long();
    Enum enumType = (Enum) obj.getType();
    List<Enumerator> enumerators = enumType.getEnumerator();
    CorbaEnumHandler enumObj = (CorbaEnumHandler) obj;
    enumObj.setValue(enumerators.get(enumIndex).getValue());
}
Also used : Enum(org.apache.cxf.binding.corba.wsdl.Enum) Enumerator(org.apache.cxf.binding.corba.wsdl.Enumerator) CorbaEnumHandler(org.apache.cxf.binding.corba.types.CorbaEnumHandler)

Example 2 with Enumerator

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

the class CorbaObjectReader method readEnumDiscriminator.

public void readEnumDiscriminator(CorbaUnionHandler unionHandler, CorbaEnumHandler disc) throws CorbaBindingException {
    int enumIndex = stream.read_long();
    Enum enumType = (Enum) disc.getType();
    List<Enumerator> enumerators = enumType.getEnumerator();
    if (enumIndex == Integer.MAX_VALUE) {
        enumIndex = unionHandler.getDefaultIndex();
    }
    disc.setValue(enumerators.get(enumIndex).getValue());
}
Also used : Enum(org.apache.cxf.binding.corba.wsdl.Enum) Enumerator(org.apache.cxf.binding.corba.wsdl.Enumerator)

Example 3 with Enumerator

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

the class CorbaEnumHandler method setValue.

public void setValue(String val) {
    value = val;
    Enum enumType = (Enum) this.type;
    List<Enumerator> enumerators = enumType.getEnumerator();
    index = -1;
    for (int i = 0; i < enumerators.size(); ++i) {
        Enumerator e = enumerators.get(i);
        if (e.getValue().equals(val)) {
            index = i;
            break;
        }
    }
}
Also used : Enum(org.apache.cxf.binding.corba.wsdl.Enum) Enumerator(org.apache.cxf.binding.corba.wsdl.Enumerator)

Example 4 with Enumerator

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

the class CorbaEnumHandlerTest method testCorbaEnumHandler.

@Test
public void testCorbaEnumHandler() {
    Enum enumType = new Enum();
    enumType.setName("EnumType");
    enumType.setRepositoryID("IDL:EnumType:1.0");
    Enumerator enumerator0 = new Enumerator();
    enumerator0.setValue("ENUM0");
    Enumerator enumerator1 = new Enumerator();
    enumerator1.setValue("ENUM1");
    Enumerator enumerator2 = new Enumerator();
    enumerator2.setValue("ENUM2");
    enumType.getEnumerator().add(enumerator0);
    enumType.getEnumerator().add(enumerator1);
    enumType.getEnumerator().add(enumerator2);
    QName enumName = new QName("EnumType");
    QName enumIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "EnumType", CorbaConstants.NP_WSDL_CORBA);
    String[] members = new String[3];
    members[0] = enumerator0.getValue();
    members[1] = enumerator1.getValue();
    members[2] = enumerator2.getValue();
    TypeCode enumTC = orb.create_enum_tc(enumType.getRepositoryID(), enumType.getName(), members);
    CorbaEnumHandler obj = new CorbaEnumHandler(enumName, enumIdlType, enumTC, enumType);
    assertNotNull(obj);
    obj.setValue(members[1]);
    assertEquals(obj.getValue(), enumerator1.getValue());
    assertTrue(obj.getIndex() == 1);
}
Also used : Enum(org.apache.cxf.binding.corba.wsdl.Enum) Enumerator(org.apache.cxf.binding.corba.wsdl.Enumerator) TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 5 with Enumerator

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

the class WSDLToCorbaHelper method processOMGUnion.

private CorbaType processOMGUnion(XmlSchemaComplexType complex, QName defaultName) throws Exception {
    QName name;
    QName schematypeName = checkPrefix(complex.getQName());
    if (schematypeName == null) {
        schematypeName = defaultName;
        name = createQNameCorbaNamespace(defaultName.getLocalPart() + "Type");
    } else {
        name = createQNameCorbaNamespace(schematypeName.getLocalPart());
    }
    Union corbaUnion = new Union();
    corbaUnion.setName(name.getLocalPart());
    corbaUnion.setQName(name);
    String id = REPO_STRING + name.getLocalPart().replace('.', '/') + IDL_VERSION;
    corbaUnion.setRepositoryID(id);
    corbaUnion.setType(schematypeName);
    XmlSchemaSequence stype = (XmlSchemaSequence) complex.getParticle();
    Iterator<XmlSchemaSequenceMember> it = stype.getItems().iterator();
    XmlSchemaParticle st1 = (XmlSchemaParticle) it.next();
    XmlSchemaParticle st2 = (XmlSchemaParticle) it.next();
    final XmlSchemaElement discEl;
    final XmlSchemaChoice choice;
    if (st1 instanceof XmlSchemaElement) {
        discEl = (XmlSchemaElement) st1;
        choice = (XmlSchemaChoice) st2;
    } else {
        discEl = (XmlSchemaElement) st2;
        choice = (XmlSchemaChoice) st1;
    }
    CorbaType disctype = convertSchemaToCorbaType(discEl.getSchemaType(), discEl.getQName(), discEl.getSchemaType(), null, false);
    corbaUnion.setDiscriminator(disctype.getQName());
    List<MemberType> fields = processContainerAsMembers(choice, defaultName, schematypeName);
    List<String> caselist = new ArrayList<>();
    if (disctype instanceof Enum) {
        Enum corbaenum = (Enum) disctype;
        Iterator<Enumerator> iterator = corbaenum.getEnumerator().iterator();
        while (iterator.hasNext()) {
            Enumerator enumerator = iterator.next();
            caselist.add(enumerator.getValue());
        }
    } else if (SUPPORTEDDISTYPES.contains(disctype.getQName().getLocalPart())) {
        if ("long".equals(disctype.getQName().getLocalPart()) || "short".equals(disctype.getQName().getLocalPart())) {
            for (int i = 0; i < fields.size(); i++) {
                caselist.add(Integer.toString(i));
            }
        } else if ("char".equals(disctype.getQName().getLocalPart())) {
            for (int i = 0; i < fields.size(); i++) {
                caselist.add(Integer.toString(i));
            }
        } else if ("boolean".equals(disctype.getQName().getLocalPart())) {
            if (fields.size() == 2) {
                caselist.add("TRUE");
                caselist.add("FALSE");
            } else if (fields.size() == 1) {
                caselist.add("TRUE");
            } else {
                String msg = "Discriminator Type does not match number of Choices in Union:" + name;
                LOG.log(Level.WARNING, msg);
            }
        }
    }
    WSDLTypes.processUnionBranches(corbaUnion, fields, caselist);
    return corbaUnion;
}
Also used : Enum(org.apache.cxf.binding.corba.wsdl.Enum) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) ArrayList(java.util.ArrayList) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) Union(org.apache.cxf.binding.corba.wsdl.Union) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) Enumerator(org.apache.cxf.binding.corba.wsdl.Enumerator) XmlSchemaSequenceMember(org.apache.ws.commons.schema.XmlSchemaSequenceMember) XmlSchemaChoice(org.apache.ws.commons.schema.XmlSchemaChoice)

Aggregations

Enumerator (org.apache.cxf.binding.corba.wsdl.Enumerator)13 Enum (org.apache.cxf.binding.corba.wsdl.Enum)12 QName (javax.xml.namespace.QName)6 TypeCode (org.omg.CORBA.TypeCode)4 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)3 Union (org.apache.cxf.binding.corba.wsdl.Union)3 CorbaEnumHandler (org.apache.cxf.binding.corba.types.CorbaEnumHandler)2 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)2 XmlSchemaEnumerationFacet (org.apache.ws.commons.schema.XmlSchemaEnumerationFacet)2 Test (org.junit.Test)2 AST (antlr.collections.AST)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Alias (org.apache.cxf.binding.corba.wsdl.Alias)1 Array (org.apache.cxf.binding.corba.wsdl.Array)1 CaseType (org.apache.cxf.binding.corba.wsdl.CaseType)1 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)1 Exception (org.apache.cxf.binding.corba.wsdl.Exception)1 Fixed (org.apache.cxf.binding.corba.wsdl.Fixed)1