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

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


        scope.addToScope(idlType);
        return idlType;
    }

    private IdlType createEnum(CorbaTypeImpl ctype, IdlScopeBase scope, String local) {
        Enum e = (Enum)ctype;
        IdlEnum enum1 = IdlEnum.create(scope, local);
        Iterator it = e.getEnumerator().iterator();

        while (it.hasNext()) {
            // Enumerators are created in the same scope
            // as the enum, according to IDL grammar rules.
            String n = ((Enumerator)it.next()).getValue();
View Full Code Here


        } else if (discriminator.getTypeCodeKind().value() == TCKind._tk_enum) {
            // Get the list of possible enumerations in the enumerator and compare these to the
            // labels we obtained from the Union definition.  In order for the union/enum
            // combination to be syntactically correct, there must be one enumeration not included
            // as a case for the default case to be valid.
            Enum enumType = (Enum)discriminator.getType();
            List<Enumerator> enumerators = enumType.getEnumerator();
            if (labels.isEmpty()) {
                // Any value will do since we only have a default case.
                label = enumerators.get(0).getValue();                 
            } else {
                String enumLabel = null;
View Full Code Here

    }
   
    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;
View Full Code Here

                                     getTypeCode(orb, arrayType.getElemtype(), typeMaps));
        //} else if (obj instanceof Const) {
        //    Const constType = (Const)obj;
        //    tc = getTypeCode(orb, constType.getIdltype(), typeMaps);
        } else if (obj instanceof Enum) {
            Enum enumType = (Enum)obj;
            String name = enumType.getName();
            List enums = enumType.getEnumerator();
            String[] members = new String[enums.size()];

            for (int i = 0; i < members.length; ++i) {
                members[i] = ((Enumerator) enums.get(i)).getValue();
            }
            tc = orb.create_enum_tc(enumType.getRepositoryID(), name, members);
        } else if (obj instanceof Exception) {
            Exception exceptType = (Exception)obj;

            // TODO: check to see if this is a recursive type.
            List list = exceptType.getMember();
View Full Code Here

                                                  TypeCode tc,
                                                  XmlSchemaObject schemaType)
        throws CorbaBindingException {
        CorbaEnumHandler obj = null;
        try {
            Enum enumType = (Enum) CorbaUtils.getCorbaType(idlType, typeMaps);
            StartElement enumStartEl = reader.nextEvent().asStartElement();
            obj = new CorbaEnumHandler(enumStartEl.getName(), idlType, tc, enumType);
            Characters enumCharEl = reader.nextEvent().asCharacters();
            obj.setValue(enumCharEl.getData());
            reader.nextEvent().asEndElement();
View Full Code Here

    public void testReadWriteStaxEnum() {       
        QName objName = new QName("object");
        QName objIdlType = new QName(staxTestNamespaceURI, "TestEnum", staxTestPrefix);
        CorbaTypeImpl type = CorbaUtils.getCorbaType(objIdlType, staxObject.getTypeMaps());
        assertTrue(type instanceof Enum);
        Enum enumType = (Enum)type;
        List<Enumerator> enumerators = enumType.getEnumerator();
        String[] enums = new String[enumerators.size()];
        for (int i = 0; i < enumerators.size(); ++i) {
            Enumerator e = enumerators.get(i);
            enums[i] = e.getValue();
        }
View Full Code Here

    }

    // -- 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());
    }
View Full Code Here

        oStream.write_long(1);
        InputStream iStream = oStream.create_input_stream();
        CorbaObjectReader reader = new CorbaObjectReader(iStream);
       
        String[] enums = {"RED", "GREEN", "BLUE" };
        Enum enumType = new Enum();
        Enumerator enumRed = new Enumerator();
        enumRed.setValue(enums[0]);
        Enumerator enumGreen = new Enumerator();
        enumGreen.setValue(enums[1]);
        Enumerator enumBlue = new Enumerator();
        enumBlue.setValue(enums[2]);
        enumType.getEnumerator().add(enumRed);
        enumType.getEnumerator().add(enumGreen);
        enumType.getEnumerator().add(enumBlue);
       
        // These values don't matter to the outcome of the test but are needed during construction
        QName enumName = new QName("TestEnum");
        QName enumIdlType = new QName("corbatm:TestEnum");
        TypeCode enumTC = orb.create_enum_tc("IDL:TestEnum:1.0", enumName.getLocalPart(), enums);
View Full Code Here

    }

    // -- complex types --
    public void writeEnum(CorbaObjectHandler obj) throws CorbaBindingException {
        CorbaEnumHandler enumHandler = (CorbaEnumHandler)obj;
        Enum enumType = (Enum)enumHandler.getType();
        String enumLabel = enumHandler.getValue();
        List<Enumerator> enumerators = enumType.getEnumerator();
       
        for (int i = 0; i < enumerators.size(); ++i) {
            if (enumerators.get(i).getValue().equals(enumLabel)) {
                stream.write_long(i);
                return;
View Full Code Here

        //XmlSchemaSimpleTypeContent xmlSchemaSimpleTypeContent = enumSchemaSimpleTypeRestriction;
        enumSchemaSimpleType.setContent(enumSchemaSimpleTypeRestriction);

       
        // corba:enum
        Enum corbaEnum = new Enum();
        corbaEnum.setQName(new QName(typeMap.getTargetNamespace(), enumNameScope.toString()));
        corbaEnum.setRepositoryID(enumNameScope.toIDLRepositoryID());
        corbaEnum.setType(enumSchemaSimpleType.getQName());
       
       
        AST node = enumNameNode.getNextSibling();
        while (node != null) {
            // xmlschema:enumeration
            XmlSchemaEnumerationFacet enumeration = new XmlSchemaEnumerationFacet();
            enumeration.setValue(node.toString());
            enumSchemaSimpleTypeRestriction.getFacets().add(enumeration);

            // corba:enumerator
            Enumerator enumerator = new Enumerator();
            enumerator.setValue(node.toString());
            corbaEnum.getEnumerator().add(enumerator);
           
            node = node.getNextSibling();
        }
       
        // add schemaType
View Full Code Here

TOP

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

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.