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

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


            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(1);
            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


        return union;
    }
   
    private IdlType createStruct(CorbaTypeImpl ctype, IdlScopeBase scope,
                                 String local) throws Exception {
        Struct s = (Struct)ctype;
        boolean undefinedCircular = false;
        IdlStruct struct = IdlStruct.create(scope, local);
        scope.holdForScope(struct);

        Iterator it = s.getMember().iterator();
        while (it.hasNext()) {
            MemberType m = (MemberType)it.next();
            QName qname = m.getIdltype();
            IdlType type = findType(qname);           
           
View Full Code Here

                                               CorbaObjectHandler obj,
                                               QName name,
                                               XmlSchemaObject schemaType,
                                               List<CorbaTypeMap> typeMaps,
                                               ServiceInfo serviceInfo) {
        Struct structType = (Struct)obj.getType();
        List<MemberType> structMembers = structType.getMember();

        XmlSchemaObjectCollection attrs = null;
        XmlSchemaObjectCollection members = null;
           
        XmlSchemaObject stype = schemaType;
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

        if (schemaType == null) {
            throw new CorbaBindingException("Couldn't find xml schema object for : " + idlType);
        }        
        CorbaStructHandler obj = null;
        try {           
            Struct structType = (Struct) CorbaUtils.getCorbaType(idlType, typeMaps);
            XmlSchemaObjectCollection attrs = null;
            XmlSchemaObjectCollection members = null;
           
            boolean readElement = false;

            XmlSchemaObject stype = schemaType;
            if (schemaType instanceof XmlSchemaElement) {
                XmlSchemaElement el = (XmlSchemaElement) schemaType;
                stype = el.getSchemaType();
                if (stype == null) {
                    stype = CorbaUtils.getXmlSchemaType(serviceInfo, el.getRefName());
                }
                readElement = true;
            }
            if (stype instanceof XmlSchemaComplexType) {
                XmlSchemaComplexType ctype = (XmlSchemaComplexType) stype;
                attrs = ctype.getAttributes();
                stype = ctype.getParticle();
                readElement = true;
            }
            if (stype instanceof XmlSchemaGroupRef) {
                members = ((XmlSchemaGroupRef) stype).getParticle().getItems();
            } else if (stype instanceof XmlSchemaGroupBase) {
                members = ((XmlSchemaGroupBase) stype).getItems();
            }
            QName elName;
            if ((attrs != null) && (attrs.getCount() > 0)) {
                elName = reader.peek().asStartElement().getName();
            } else if (readElement) {
                elName = reader.nextEvent().asStartElement().getName();
            } else {
                elName = CorbaUtils.EMPTY_QNAME;
            }
            obj = new CorbaStructHandler(elName, idlType, tc, structType);

            List<MemberType> structMembers = structType.getMember();
            int attrCount = 0;
            int memberCount = 0;
            for (int i = 0; i < structMembers.size(); ++i) {
                XmlSchemaObject schemaObj;
                if ((attrs != null) && (attrCount < attrs.getCount())) {
View Full Code Here

    public void testReadWriteStaxStruct() {       
        QName objName = new QName("object");
        QName objIdlType = new QName(staxTestNamespaceURI, "TestStruct", staxTestPrefix);
        CorbaTypeImpl type = CorbaUtils.getCorbaType(objIdlType, staxObject.getTypeMaps());
        assertTrue(type instanceof Struct);
        Struct structType = (Struct)type;
        TypeCode objTypeCode = CorbaUtils.getTypeCode(orb, objIdlType, staxObject.getTypeMaps());
        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(), staxObject.getTypeMaps());
        CorbaPrimitiveHandler member1 = new CorbaPrimitiveHandler(new QName(m1.getName()),
View Full Code Here

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

       
        // corba:struct
        Struct struct = new Struct();
        struct.setQName(new QName(typeMap.getTargetNamespace(), structScope.toString()));
        struct.setType(complexType.getQName());
        struct.setRepositoryID(structScope.toIDLRepositoryID());

       
        // struct members
        AST memberTypeNode = identifierNode.getNextSibling();
        while (memberTypeNode != null) {
            AST memberNode = TypesUtils.getCorbaTypeNameNode(memberTypeNode);
           
            XmlSchemaType schemaType = null;
            CorbaTypeImpl corbaType = null;
            try {
                TypesVisitor visitor = new TypesVisitor(structScope,
                                                        schemas,
                                                        schema,
                                                        typeMap,
                                                        null);
                visitor.visit(memberTypeNode);
               
                schemaType = visitor.getSchemaType();
                corbaType = visitor.getCorbaType();
               
            } catch (Exception ex) {
                System.out.println(ex.getMessage());
                System.exit(1);
            }

            // needed for anonymous arrays in structs
            if (ArrayVisitor.accept(memberNode)) {
                Scope anonScope = new Scope(structScope,
                                            TypesUtils.getCorbaTypeNameNode(memberTypeNode));
                ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope,
                                                             schemas,
                                                             schema,
                                                             typeMap,
                                                             schemaType,
                                                             corbaType,
                                                             null);
                arrayVisitor.visit(memberNode);
                schemaType = arrayVisitor.getSchemaType();
                corbaType = arrayVisitor.getCorbaType();
            }
           
            // xmlschema:member
            XmlSchemaElement member = new XmlSchemaElement();
            String memberName = memberNode.toString();
            member.setName(memberName);
            member.setSchemaType(schemaType);
            member.setSchemaTypeName(schemaType.getQName());

            sequence.getItems().add(member);

           
            // corba:member
            MemberType memberType = new MemberType();
            memberType.setName(memberName);
            memberType.setIdltype(corbaType.getQName());
            struct.getMember().add(memberType);

            memberTypeNode = memberNode.getNextSibling();
        }

        // add schemaType
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

        } else if (obj instanceof Sequence) {
            Sequence seqType = (Sequence)obj;
            tc = orb.create_sequence_tc((int) seqType.getBound(),
                                        getTypeCode(orb, seqType.getElemtype(), typeMaps));
        } else if (obj instanceof Struct) {
            Struct structType = (Struct)obj;

            // TODO: check to see if this is a recursive type.
            List list = structType.getMember();
            StructMember[] members = new StructMember[list.size()];
            for (int i = 0; i < members.length; ++i) {
                MemberType member = (MemberType) list.get(i);
                members[i] = new StructMember(member.getName(),
                                              getTypeCode(orb, member.getIdltype(), typeMaps), null);
            }
            String name = structType.getName();
            tc = orb.create_struct_tc(structType.getRepositoryID(), name, members);
        } else if (obj instanceof Union) {
            tc = getUnionTypeCode(orb, obj, typeMaps);
        }
        return tc;
    }
View Full Code Here

            }
        }
    }
   
    public void testCorbaStructHandler() {
        Struct structType = new Struct();
        structType.setName("TestStruct");
        structType.setRepositoryID("IDL:TestStruct:1.0");
        MemberType member0 = new MemberType();
        member0.setIdltype(CorbaConstants.NT_CORBA_LONG);
        member0.setName("member0");
        MemberType member1 = new MemberType();
        member1.setIdltype(CorbaConstants.NT_CORBA_STRING);
        member1.setName("member1");
       
        QName structName = new QName("TestStruct");
        QName structIdlType =
            new QName(CorbaConstants.NU_WSDL_CORBA, "testStruct", CorbaConstants.NP_WSDL_CORBA);
        StructMember[] structMembers = new StructMember[2];
        structMembers[0] = new StructMember("member0",
                                            orb.get_primitive_tc(TCKind.tk_long),
                                            null);
        structMembers[1] = new StructMember("member1",
                        orb.get_primitive_tc(TCKind.tk_string),
                        null);
        TypeCode structTC = orb.create_struct_tc(structType.getRepositoryID(),
                                                 structType.getName(),
                                                 structMembers);
       
        CorbaStructHandler obj = new CorbaStructHandler(structName, structIdlType, structTC, structType);
        assertNotNull(obj);
       
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.