Search in sources :

Example 1 with Sequence

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

the class CorbaObjectWriterTest method testWriteSequence.

@Test
public void testWriteSequence() {
    String[] data = { "one", "one", "two", "three", "five", "eight", "thirteen", "twenty-one" };
    // create an sequence of strings
    QName stringIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA);
    QName seqIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "sequence", CorbaConstants.NP_WSDL_CORBA);
    Sequence seqType = new Sequence();
    seqType.setBound(data.length);
    seqType.setElemtype(stringIdlType);
    // name and respoitory ID of the sequence are not needed for this test
    // build the object holder for a sequence.
    TypeCode seqTC = orb.create_sequence_tc(data.length, orb.get_primitive_tc(TCKind.tk_string));
    CorbaSequenceHandler obj = new CorbaSequenceHandler(new QName("Seq"), seqIdlType, seqTC, seqType);
    for (int i = 0; i < data.length; ++i) {
        CorbaPrimitiveHandler nestedObj = new CorbaPrimitiveHandler(new QName("item"), stringIdlType, orb.get_primitive_tc(TCKind.tk_string), null);
        nestedObj.setValueFromData(data[i]);
        obj.addElement(nestedObj);
    }
    OutputStream oStream = orb.create_output_stream();
    CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
    writer.writeSequence(obj);
    InputStream iStream = oStream.create_input_stream();
    int length = iStream.read_long();
    for (int i = 0; i < length; ++i) {
        String val = iStream.read_string();
        assertTrue(val.equals(data[i]));
    }
}
Also used : CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) InputStream(org.omg.CORBA.portable.InputStream) CorbaSequenceHandler(org.apache.cxf.binding.corba.types.CorbaSequenceHandler) OutputStream(org.omg.CORBA.portable.OutputStream) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) Test(org.junit.Test)

Example 2 with Sequence

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

the class CorbaSequenceHandlerTest method testCorbaSequenceHandler.

@Test
public void testCorbaSequenceHandler() {
    objName = new QName("object");
    objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "sequenceType", CorbaConstants.NP_WSDL_CORBA);
    objTypeCode = orb.create_sequence_tc(5, orb.get_primitive_tc(TCKind.tk_long));
    Sequence sequenceType = new Sequence();
    sequenceType.setName("sequenceType");
    sequenceType.setElemtype(CorbaConstants.NT_CORBA_LONG);
    sequenceType.setBound(5);
    sequenceType.setRepositoryID("IDL:SequenceType:1.0");
    obj = new CorbaSequenceHandler(objName, objIdlType, objTypeCode, sequenceType);
    assertNotNull(obj);
    int[] sequenceData = { 2, 4, 6, 8, 10 };
    for (int i = 0; i < sequenceData.length; ++i) {
        QName elName = new QName("item");
        QName elIdlType = CorbaConstants.NT_CORBA_LONG;
        TypeCode elTC = orb.get_primitive_tc(TCKind.tk_long);
        CorbaPrimitiveHandler el = new CorbaPrimitiveHandler(elName, elIdlType, elTC, null);
        el.setValue(Integer.valueOf(sequenceData[i]));
        obj.addElement(el);
    }
    QName nameResult = obj.getName();
    assertNotNull(nameResult);
    assertTrue(objName.equals(nameResult));
    QName idlTypeResult = obj.getIdlType();
    assertNotNull(idlTypeResult);
    assertTrue(idlTypeResult.equals(objIdlType));
    TypeCode tcResult = obj.getTypeCode();
    assertNotNull(tcResult);
    assertTrue(tcResult.kind().value() == objTypeCode.kind().value());
    Object objDefResult = obj.getType();
    assertNotNull(objDefResult);
    assertTrue(objDefResult instanceof Sequence);
    int countResult = obj.getNumberOfElements();
    for (int i = 0; i < countResult; ++i) {
        CorbaObjectHandler elResult = obj.getElement(i);
        assertNotNull(elResult);
    }
}
Also used : TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) Test(org.junit.Test)

Example 3 with Sequence

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

the class WSDLTypes method mapToSequence.

public static CorbaType mapToSequence(QName name, QName schematypeName, QName arrayType, QName elName, int bound, boolean anonymous) {
    CorbaType corbaTypeImpl = null;
    // schematypeName = checkPrefix(schematypeName);
    if (!anonymous) {
        // Create a Sequence
        Sequence corbaSeq = new Sequence();
        corbaSeq.setName(name.getLocalPart());
        corbaSeq.setQName(name);
        corbaSeq.setType(schematypeName);
        corbaSeq.setElemtype(arrayType);
        corbaSeq.setElemname(elName);
        corbaSeq.setBound(bound);
        corbaSeq.setRepositoryID(WSDLToCorbaHelper.REPO_STRING + name.getLocalPart().replace('.', '/') + WSDLToCorbaHelper.IDL_VERSION);
        corbaTypeImpl = corbaSeq;
    } else {
        // Create a Anonymous Sequence
        Anonsequence corbaSeq = new Anonsequence();
        corbaSeq.setName(name.getLocalPart());
        corbaSeq.setQName(name);
        corbaSeq.setType(schematypeName);
        corbaSeq.setElemtype(arrayType);
        corbaSeq.setElemname(elName);
        corbaSeq.setBound(bound);
        corbaTypeImpl = corbaSeq;
    }
    return corbaTypeImpl;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence)

Example 4 with Sequence

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

the class WSDLToCorbaBindingTest method assertMixedArraysMappingDifficultSequences.

/**
 * @param typeMap
 */
private void assertMixedArraysMappingDifficultSequences(CorbaTypeMap typeMap) {
    String corbaTm = "http://schemas.apache.org/idl/anon.idl/corba/typemap/";
    // p9 is unwrapped, so there's "MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequenceArray" type
    // registered and "MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence" as type of the element
    // which is Struct
    Sequence p9 = (Sequence) typeMap.getType("MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequenceArray");
    assertEquals(new QName("", "p9-anonymous-unwrapped-non-primitive-sequence"), p9.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence"), p9.getElemtype());
    assertFalse(p9.isQualified());
    assertFalse(p9.isWrapped());
    Struct p9item = (Struct) typeMap.getType("MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence");
    assertEquals(1, p9item.getMember().size());
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p9item.getMember().get(0).getIdltype());
    assertEquals("item", p9item.getMember().get(0).getName());
    Sequence p9q = (Sequence) typeMap.getType("MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence-qArray");
    assertEquals(new QName("http://schemas.apache.org/idltypes/anon.idl", "p9-anonymous-unwrapped-non-primitive-sequence-q"), p9q.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence-q"), p9q.getElemtype());
    assertTrue(p9q.isQualified());
    assertFalse(p9q.isWrapped());
    Struct p9qitem = (Struct) typeMap.getType("MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence-q");
    assertEquals(1, p9qitem.getMember().size());
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p9qitem.getMember().get(0).getIdltype());
    assertEquals("item", p9qitem.getMember().get(0).getName());
    // p10 is wrapped, so there's no "MixedArrayType.p10-anonymous-wrapped-non-primitive-sequenceArray"
    Anonsequence p10 = (Anonsequence) typeMap.getType("MixedArrayType.p10-anonymous-wrapped-non-primitive-sequenceType");
    assertEquals(new QName("", "item"), p10.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p10-anonymous-wrapped-non-primitive-sequence.item"), p10.getElemtype());
    assertFalse(p10.isQualified());
    assertTrue(p10.isWrapped());
    Struct p10item = (Struct) typeMap.getType("MixedArrayType.p10-anonymous-wrapped-non-primitive-sequence.item");
    assertEquals(p10item.getMember().size(), 1);
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p10item.getMember().get(0).getIdltype());
    assertEquals("item", p10item.getMember().get(0).getName());
    assertFalse(p10item.getMember().get(0).isSetQualified());
    Anonsequence p10q = (Anonsequence) typeMap.getType("MixedArrayType.p10-anonymous-wrapped-non-primitive-sequence-qType");
    assertEquals(new QName("http://schemas.apache.org/idltypes/anon.idl", "item"), p10q.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p10-anonymous-wrapped-non-primitive-sequence-q.item"), p10q.getElemtype());
    assertTrue(p10q.isQualified());
    assertTrue(p10q.isWrapped());
    Struct p10qitem = (Struct) typeMap.getType("MixedArrayType.p10-anonymous-wrapped-non-primitive-sequence-q.item");
    assertEquals(p10qitem.getMember().size(), 1);
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p10qitem.getMember().get(0).getIdltype());
    assertEquals("item", p10qitem.getMember().get(0).getName());
    assertTrue(p10qitem.getMember().get(0).isQualified());
}
Also used : QName(javax.xml.namespace.QName) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence) Struct(org.apache.cxf.binding.corba.wsdl.Struct)

Example 5 with Sequence

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

the class DeclaratorVisitor method visitNewTypes.

private void visitNewTypes(Scope newScope) {
    CorbaType nextCorbaType = null;
    XmlSchemaType nextSchemaType = null;
    CorbaType oldCorbaType = getCorbaType();
    QName newQname = new QName(getCorbaType().getQName().getNamespaceURI(), newScope.toString());
    if (oldCorbaType instanceof Alias) {
        // Alias
        // 
        Alias oldAlias = (Alias) oldCorbaType;
        Alias alias = new Alias();
        alias.setQName(newQname);
        alias.setBasetype(oldAlias.getBasetype());
        alias.setType(oldAlias.getType());
        alias.setRepositoryID(newScope.toIDLRepositoryID());
        nextCorbaType = alias;
    } else if (oldCorbaType instanceof Sequence) {
        // Sequence
        // 
        nextSchemaType = duplicateXmlSchemaComplexType(newScope);
        Sequence oldSequence = (Sequence) oldCorbaType;
        Sequence newSequence = new Sequence();
        newSequence.setQName(newQname);
        newSequence.setType(nextSchemaType.getQName());
        newSequence.setElemtype(oldSequence.getElemtype());
        newSequence.setElemname(oldSequence.getElemname());
        newSequence.setBound(oldSequence.getBound());
        newSequence.setRepositoryID(newScope.toIDLRepositoryID());
        nextCorbaType = newSequence;
    } else if (oldCorbaType instanceof Fixed) {
        // Fixed
        // 
        nextSchemaType = duplicateXmlSchemaSimpleType(newScope);
        Fixed oldFixed = (Fixed) getCorbaType();
        Fixed newFixed = new Fixed();
        newFixed.setQName(newQname);
        newFixed.setDigits(oldFixed.getDigits());
        newFixed.setScale(oldFixed.getScale());
        newFixed.setType(oldFixed.getType());
        newFixed.setRepositoryID(newScope.toIDLRepositoryID());
        nextCorbaType = newFixed;
    } else {
        System.err.println("[DeclaratorVisitor: Unexpected CORBA type error!]");
        System.exit(1);
    }
    if (nextCorbaType != null) {
        typeMap.getStructOrExceptionOrUnion().add(nextCorbaType);
    }
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) Alias(org.apache.cxf.binding.corba.wsdl.Alias) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) Fixed(org.apache.cxf.binding.corba.wsdl.Fixed)

Aggregations

Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)15 QName (javax.xml.namespace.QName)12 Anonsequence (org.apache.cxf.binding.corba.wsdl.Anonsequence)7 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)6 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)5 Alias (org.apache.cxf.binding.corba.wsdl.Alias)4 TypeCode (org.omg.CORBA.TypeCode)4 Array (org.apache.cxf.binding.corba.wsdl.Array)3 Fixed (org.apache.cxf.binding.corba.wsdl.Fixed)3 Struct (org.apache.cxf.binding.corba.wsdl.Struct)3 Test (org.junit.Test)3 CorbaPrimitiveHandler (org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler)2 CorbaSequenceHandler (org.apache.cxf.binding.corba.types.CorbaSequenceHandler)2 Anonarray (org.apache.cxf.binding.corba.wsdl.Anonarray)2 Enum (org.apache.cxf.binding.corba.wsdl.Enum)2 Union (org.apache.cxf.binding.corba.wsdl.Union)2 List (java.util.List)1 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)1 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)1 Anonfixed (org.apache.cxf.binding.corba.wsdl.Anonfixed)1