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

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


        } else {       
            seqName = createQNameCorbaNamespace(schemaTypeName.getLocalPart() + "SequenceStruct");
        }
       
        schemaTypeName = checkPrefix(schemaTypeName);
        Struct struct = new Struct();      
        struct.setName(seqName.getLocalPart());
        struct.setQName(seqName);
        struct.setRepositoryID(REPO_STRING + seqName.getLocalPart().replace('.', '/') + IDL_VERSION);
        struct.setType(schemaTypeName);
       
        List members = processContainerAsMembers(seq, defaultName, schemaTypeName);
        for (Iterator iterator = members.iterator(); iterator.hasNext();) {
            MemberType memberType = (MemberType)iterator.next();
            struct.getMember().add(memberType);           
        }       
       
        type = struct;
                             
        if (!"1".equals(seq.getMaxOccurs()) || !"1".equals(seq.getMinOccurs())) {
            QName name = createQNameTargetNamespace(type.getQName().getLocalPart() + "Array");           
            CorbaTypeImpl atype = createArray(name, type.getQName(), type.getQName(),
                                           seq.getMaxOccurs(), seq.getMinOccurs(), false);
           
            if (atype != null) {
                atype.setQName(null);              
                if (!isDuplicate(atype)) {
                    typeMappingType.getStructOrExceptionOrUnion().add(atype);              
                }
            }
        }
       
        if ((type instanceof Struct) && (struct.getMember().size() == 0)) {
            String msgStr = "Cannot create CORBA Struct" + struct.getName()
                            + "from container with no members";
            org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(
                                      msgStr, LOG);
            throw new Exception(msg.toString());
        }       
View Full Code Here


   
   
    protected CorbaTypeImpl processAllType(XmlSchemaAll seq, QName defaultName,
                                           QName schematypeName) throws Exception {
        QName allName = null;
        Struct type = null;

        if (schematypeName == null) {
            allName = createQNameCorbaNamespace(defaultName.getLocalPart() + "AllStruct");
        } else {
            allName = createQNameCorbaNamespace(schematypeName.getLocalPart() + "AllStruct");
        }

        type = new Struct();
        type.setName(allName.getLocalPart());
        type.setQName(allName);
        type.setType(schematypeName);
       
        List members = processContainerAsMembers(seq, defaultName, schematypeName);
        for (Iterator iterator = members.iterator(); iterator.hasNext();) {
            MemberType memberType = (MemberType)iterator.next();
            type.getMember().add(memberType);
        }
               
        String repoId = REPO_STRING + type.getQName().getLocalPart().replace('.', '/') + IDL_VERSION;
        type.setRepositoryID(repoId);
        return type;
    }
View Full Code Here

   
       
    private CorbaTypeImpl processStruct(XmlSchemaComplexType complex, QName defaultName)
        throws Exception {
        QName name;
        Struct corbaStruct = null;
        QName schematypeName = checkPrefix(complex.getQName());              
        if (schematypeName == null) {
            schematypeName = checkPrefix(defaultName);
            name = checkPrefix(createQNameCorbaNamespace(defaultName.getLocalPart()));           
        } else {
            name = checkPrefix(createQNameCorbaNamespace(schematypeName.getLocalPart()));           
        }

        corbaStruct = new Struct();
        corbaStruct.setName(name.getLocalPart());
        corbaStruct.setQName(name);
        String repoId = REPO_STRING + name.getLocalPart().replace('.', '/') + IDL_VERSION;
        corbaStruct.setRepositoryID(repoId);
        corbaStruct.setType(schematypeName);
         
        if (complex.getContentModel() instanceof XmlSchemaSimpleContent) {
            corbaStruct = processSimpleContentStruct((XmlSchemaSimpleContent)complex.getContentModel(),
                                                     defaultName, corbaStruct, schematypeName);
        } else if (complex.getContentModel() instanceof XmlSchemaComplexContent) {
            corbaStruct = processComplexContentStruct((XmlSchemaComplexContent)complex.getContentModel(),
                                                      defaultName, corbaStruct, schematypeName);       
        }
       
        // Process attributes at ComplexType level
        if (complex.getAttributes().getIterator() != null) {
            Iterator iterator = complex.getAttributes().getIterator();
            List attlist2 = processAttributesAsMembers(iterator);
            MemberType member = new MemberType();
            for (int i = 0; i < attlist2.size(); i++) {
                member = (MemberType)attlist2.get(i);
                corbaStruct.getMember().add(member);
            }
        }

        if (complex.getParticle() != null) {
            List members = processContainerAsMembers(complex.getParticle(), defaultName, schematypeName);

            for (Iterator it = members.iterator(); it.hasNext();) {
                MemberType memberType = (MemberType)it.next();
                corbaStruct.getMember().add(memberType);
            }
        }

        return corbaStruct;
    }
View Full Code Here

            assertEquals("Name is incorrect for Anon Array Type", "X._2_S",
                         fx.getName());
            assertEquals("Type is incorrect for AnonFixed Type", "decimal",
                         fx.getType().getLocalPart());
           
            Struct struct = (Struct)mapType.getStructOrExceptionOrUnion().get(0);
            assertEquals("Name is incorrect for Anon Array Type", "X.S",
                         struct.getName());           
            assertEquals("Type is incorrect for Struct Type", "X.S",
                         struct.getType().getLocalPart());
            assertEquals("Name for first Struct Member Type is incorrect", "str",
                         struct.getMember().get(0).getName());
            assertEquals("Idltype for first Struct Member Type is incorrect", "X._1_S",
                         struct.getMember().get(0).getIdltype().getLocalPart());           
            assertEquals("Name for second Struct Member Type is incorrect", "fx",
                         struct.getMember().get(1).getName());
            assertEquals("Idltype for second Struct Member Type is incorrect", "X._2_S",
                         struct.getMember().get(1).getIdltype().getLocalPart());
           
            File f = new File("atype.idl");
            assertTrue("atype.idl should be generated", f.exists());
        } finally {
            new File("atype.idl").deleteOnExit();
View Full Code Here

        XmlSchemaSequence sequence = new XmlSchemaSequence();
        complexType.setParticle(sequence);

       
        // corba:struct
        Struct struct = new Struct();
        struct.setQName(new QName(typeMap.getTargetNamespace(), structName));
        struct.setType(complexType.getQName());
        struct.setRepositoryID(CorbaConstants.REPO_STRING
                               + structName
                               + CorbaConstants.IDL_VERSION);

       
        // struct members
        AST memberTypeNode = structNode.getNextSibling();
        while (memberTypeNode != null) {
            AST memberNode = memberTypeNode.getNextSibling();

            // xmlschema:member
            XmlSchemaElement member = new XmlSchemaElement();
            String memberName = memberNode.toString();
            member.setName(memberName);
            // type
            XmlSchemaType type = TypesUtils.findType(schemas, schema, memberTypeNode);
            member.setSchemaType(type);
            member.setSchemaTypeName(type.getQName());

            sequence.getItems().add(member);

           
            // corba:member
            MemberType memberType = new MemberType();
            memberType.setName(memberName);
            QName idlType = TypesUtils.findCorbaType(typeMap, type.getQName()).getQName();
            memberType.setIdltype(idlType);
            struct.getMember().add(memberType);
           
           
            memberTypeNode = memberNode.getNextSibling();
        }
View Full Code Here

        QName structIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "struct", CorbaConstants.NP_WSDL_CORBA);
        QName longIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "long", CorbaConstants.NP_WSDL_CORBA);
        QName stringIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA);
        QName boolIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "boolean", CorbaConstants.NP_WSDL_CORBA);
       
        Struct structType = new Struct();
        structType.setName("TestStruct");
        MemberType m1 = new MemberType();
        m1.setIdltype(longIdlType);
        m1.setName("member1");
        MemberType m2 = new MemberType();
        m2.setIdltype(stringIdlType);
        m2.setName("member2");
        MemberType m3 = new MemberType();
        m3.setIdltype(boolIdlType);
        m3.setName("member3");
        structType.getMember().add(m1);
        structType.getMember().add(m2);
        structType.getMember().add(m3);

        // build the object holder
        StructMember[] structMembers = new StructMember[3];
        structMembers[0] = new StructMember("member1", orb.get_primitive_tc(TCKind.tk_long), null);
        structMembers[1] = new StructMember("member2", orb.get_primitive_tc(TCKind.tk_string), null);
View Full Code Here

    public void testNestedType() {
        QName objName = new QName("object");
        QName objIdlType = new QName(nestedNamespaceURI, "NestedStruct", nestedPrefix);
        CorbaTypeImpl type = CorbaUtils.getCorbaType(objIdlType, bindingImpl.getCorbaTypeMaps());
        assertTrue(type instanceof Struct);
        Struct structType = (Struct)type;
        TypeCode objTypeCode = CorbaUtils.getTypeCode(orb, objIdlType, bindingImpl.getCorbaTypeMaps());
        CorbaStructHandler obj = new CorbaStructHandler(objName, objIdlType, objTypeCode, structType);
        assertNotNull(obj);
       
        // Create member 1, a BasicStruct
View Full Code Here

        QName structIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "struct", CorbaConstants.NP_WSDL_CORBA);
        QName longIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "long", CorbaConstants.NP_WSDL_CORBA);
        QName stringIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA);
        QName boolIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "boolean", CorbaConstants.NP_WSDL_CORBA);
       
        Struct structType = new Struct();
        structType.setName("TestStruct");
        MemberType m1 = new MemberType();
        m1.setIdltype(longIdlType);
        m1.setName("member1");
        MemberType m2 = new MemberType();
        m2.setIdltype(stringIdlType);
        m2.setName("member2");
        MemberType m3 = new MemberType();
        m3.setIdltype(boolIdlType);
        m3.setName("member3");
        structType.getMember().add(m1);
        structType.getMember().add(m2);
        structType.getMember().add(m3);

        // build the object holder
        StructMember[] structMembers = new StructMember[3];
        structMembers[0] = new StructMember("member1", orb.get_primitive_tc(TCKind.tk_long), null);
        structMembers[1] = new StructMember("member2", orb.get_primitive_tc(TCKind.tk_string), null);
View Full Code Here

    public void testReadWriteStaxStruct() {
        QName objName = new QName("object");
        QName objIdlType = new QName(staxTestNamespaceURI, "TestStruct", staxTestPrefix);
        CorbaTypeImpl type = CorbaUtils.getCorbaType(objIdlType, staxBindingImpl.getCorbaTypeMaps());
        assertTrue(type instanceof Struct);
        Struct structType = (Struct)type;
        TypeCode objTypeCode = CorbaUtils.getTypeCode(orb, objIdlType, staxBindingImpl.getCorbaTypeMaps());
        CorbaStructHandler obj = new CorbaStructHandler(objName, objIdlType, objTypeCode, structType);
        assertNotNull(obj);

        List<MemberType> structMembers = structType.getMember();
        // For this test, we know what each of the members are.  Create the correct handler and assign
        // each member a value
        MemberType m1 = structMembers.get(0);
        TypeCode m1TypeCode = CorbaUtils.getTypeCode(orb, m1.getIdltype(), staxBindingImpl.getCorbaTypeMaps());
        CorbaPrimitiveHandler member1 = new CorbaPrimitiveHandler(new QName(m1.getName()),
View Full Code Here

        }
    }
   
    public static void initializeStructHandler(ORB orb, CorbaObjectHandler obj,
                                               QName name, List<CorbaTypeMap> typeMaps) {
        Struct structType = (Struct)obj.getType();
        List<MemberType> structMembers = structType.getMember();

        for (int i = 0; i < structMembers.size(); ++i) {
            MemberType member = structMembers.get(i);
            QName memberName = new QName(name.getNamespaceURI(), member.getName());
            QName memberType = member.getIdltype();
View Full Code Here

TOP

Related Classes of org.apache.schemas.yoko.bindings.corba.Struct

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.