Package org.apache.yoko.bindings.corba.types

Examples of org.apache.yoko.bindings.corba.types.CorbaSequenceHandler


        }
    }

    public CorbaObjectHandler readSequenceFromStax(XMLEventReader reader, QName idlType, TypeCode tc)
        throws CorbaBindingException {
        CorbaSequenceHandler obj = null;
        CorbaTypeImpl typeDefinition = CorbaUtils.getCorbaType(idlType, typeMaps);
       
        try {
            QName seqElementType = null;
            long bound = 0;
            if (typeDefinition instanceof Anonsequence) {
                Anonsequence anonSeqType = (Anonsequence)typeDefinition;
                seqElementType = anonSeqType.getElemtype();
                bound = anonSeqType.getBound();
            } else {
                Sequence seqType = (Sequence)typeDefinition;
                seqElementType = seqType.getElemtype();
                bound = seqType.getBound();
            }
            StartElement seqStartEl = reader.nextEvent().asStartElement();
            obj = new CorbaSequenceHandler(seqStartEl.getName(), idlType, tc, typeDefinition);
            if (bound == 0) {
                LOG.log(Level.INFO, "Unbounded sequence found");
                while (reader.peek().getEventType() == XMLStreamConstants.START_ELEMENT) {
                    CorbaObjectHandler element = readObjectFromStax(reader, seqElementType, true);
                    obj.addElement(element);
                }
            } else {
                LOG.log(Level.INFO, "Bounded sequence found");
                for (long i = 0; i < bound; ++i) {
                    CorbaObjectHandler element = readObjectFromStax(reader, seqElementType, true);
                    obj.addElement(element);
                }
            }
            reader.nextEvent().asEndElement();
        } catch (java.lang.Exception ex) {
            LOG.log(Level.SEVERE, "Received exception while reading object of type " + idlType);
View Full Code Here


        return obj;
    }

    public void writeSequenceToStax(CorbaObjectHandler obj, XMLEventWriter writer, XMLEventFactory factory)
        throws XMLStreamException {
        CorbaSequenceHandler seqHandler = (CorbaSequenceHandler)obj;
        List<CorbaObjectHandler> elements = seqHandler.getElements();
        for (Iterator<CorbaObjectHandler> iter = elements.iterator(); iter.hasNext();) {
            writeObjectToStax(iter.next(), writer, factory, true);
        }
    }
View Full Code Here

            this.write(iter.next());
        }
    }

    public void writeSequence(CorbaObjectHandler obj) throws CorbaBindingException {
        CorbaSequenceHandler seqHandler = (CorbaSequenceHandler)obj;
        List<CorbaObjectHandler> seqElements = seqHandler.getElements();
        int length = seqElements.size();

        stream.write_ulong(length);

        for (Iterator<CorbaObjectHandler> iter = seqElements.iterator(); iter.hasNext();) {
View Full Code Here

            this.read(iter.next());
        }
    }

    public void readSequence(CorbaObjectHandler obj) throws CorbaBindingException {
        CorbaSequenceHandler sequenceObj = (CorbaSequenceHandler)obj;
        List<CorbaObjectHandler> seqElements = sequenceObj.getElements();

        int length = stream.read_ulong();
       
        if (seqElements.size() == 0) {
            // No predefined elements means an unbounded sequence.  Use the template element
            // to construct each object that is in the input stream.
            CorbaObjectHandler template = sequenceObj.getTemplateElement();
            Class<?> templateClass = template.getClass();
            // we know that we are after the 4 parameter version of the constructor
            Class[] paramClasses = new Class[4];
            Object[] params = new Object[4];
            paramClasses[0] = QName.class;
            params[0] = template.getName();
            paramClasses[1] = QName.class;
            params[1] = template.getIdlType();
            paramClasses[2] = TypeCode.class;
            params[2] = template.getTypeCode();
            paramClasses[3] = Object.class;
            params[3] = template.getType();
            Constructor templateConstructor = null;
            try {
                templateConstructor = templateClass.getConstructor(paramClasses);
               
            } catch (java.lang.NoSuchMethodException ex) {
                throw new CorbaBindingException("Exception while reading unbounded sequence", ex);
            }
          
            for (int i = 0; i < length; ++i) {
                CorbaObjectHandler seqElement = null;
                try {
                    seqElement = (CorbaObjectHandler)templateConstructor.newInstance(params);
                    // A special case arises if we have a unbounded sequence of unbounded sequences.  We
                    // need to obtain the template object so that all nested unbounded sequences can be
                    // correctly constructed.
                    if (template instanceof CorbaSequenceHandler) {
                        CorbaSequenceHandler templateSeq = (CorbaSequenceHandler)template;
                        ((CorbaSequenceHandler)seqElement).
                            setTemplateElement(templateSeq.getTemplateElement());
                    }
                } catch (java.lang.Exception ex) {
                    throw new CorbaBindingException("Unable to instantiate sequence element", ex);
                }                   
                this.read(seqElement);
View Full Code Here

TOP

Related Classes of org.apache.yoko.bindings.corba.types.CorbaSequenceHandler

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.