Search in sources :

Example 1 with CorbaAnyHandler

use of org.apache.cxf.binding.corba.types.CorbaAnyHandler in project cxf by apache.

the class CorbaObjectReader method initializeCorbaObjectHandler.

private CorbaObjectHandler initializeCorbaObjectHandler(CorbaObjectHandler template) {
    Constructor<?> templateConstructor = template.getClass().getDeclaredConstructors()[0];
    Object[] params = new Object[4];
    // of a sequence and needs to have the name "item" in order
    if (template.isRecursive()) {
        // Revisit: Is this always the case?
        params[0] = new QName("item");
    } else {
        params[0] = template.getName();
    }
    params[1] = template.getIdlType();
    params[2] = template.getTypeCode();
    params[3] = template.getType();
    CorbaObjectHandler handler = null;
    try {
        handler = (CorbaObjectHandler) templateConstructor.newInstance(params);
        // the template object.
        if (template instanceof CorbaAnyHandler) {
            ((CorbaAnyHandler) handler).setTypeMap(((CorbaAnyHandler) template).getTypeMap());
        }
    } catch (java.lang.Exception ex) {
        throw new CorbaBindingException("Unable to instantiate sequence element", ex);
    }
    if (template instanceof CorbaSequenceHandler) {
        CorbaSequenceHandler templateSeq = (CorbaSequenceHandler) template;
        ((CorbaSequenceHandler) handler).setTemplateElement(templateSeq.getTemplateElement());
    } else if (template instanceof CorbaStructHandler) {
        CorbaStructHandler templateStruct = (CorbaStructHandler) template;
        CorbaStructHandler struct = (CorbaStructHandler) handler;
        struct.setRecursive(template.isRecursive());
        List<CorbaObjectHandler> members = templateStruct.getMembers();
        for (int i = 0; i < members.size(); i++) {
            CorbaObjectHandler member = initializeCorbaObjectHandler(members.get(i));
            struct.addMember(member);
        }
    } else if (template instanceof CorbaArrayHandler) {
        CorbaArrayHandler templateArray = (CorbaArrayHandler) template;
        CorbaArrayHandler array = (CorbaArrayHandler) handler;
        List<CorbaObjectHandler> elements = templateArray.getElements();
        for (int i = 0; i < elements.size(); i++) {
            CorbaObjectHandler element = initializeCorbaObjectHandler(elements.get(i));
            array.addElement(element);
        }
    } else if (template instanceof CorbaUnionHandler) {
        CorbaUnionHandler templateUnion = (CorbaUnionHandler) template;
        CorbaUnionHandler union = (CorbaUnionHandler) handler;
        union.setRecursive(template.isRecursive());
        union.setDiscriminator(initializeCorbaObjectHandler(templateUnion.getDiscriminator()));
        List<CorbaObjectHandler> cases = templateUnion.getCases();
        for (int i = 0; i < cases.size(); i++) {
            union.addCase(initializeCorbaObjectHandler(cases.get(i)));
        }
    }
    return handler;
}
Also used : CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) QName(javax.xml.namespace.QName) CorbaSequenceHandler(org.apache.cxf.binding.corba.types.CorbaSequenceHandler) CorbaStructHandler(org.apache.cxf.binding.corba.types.CorbaStructHandler) CorbaUnionHandler(org.apache.cxf.binding.corba.types.CorbaUnionHandler) CorbaArrayHandler(org.apache.cxf.binding.corba.types.CorbaArrayHandler) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) ArrayList(java.util.ArrayList) List(java.util.List) CorbaAnyHandler(org.apache.cxf.binding.corba.types.CorbaAnyHandler)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 QName (javax.xml.namespace.QName)1 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)1 CorbaAnyHandler (org.apache.cxf.binding.corba.types.CorbaAnyHandler)1 CorbaArrayHandler (org.apache.cxf.binding.corba.types.CorbaArrayHandler)1 CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)1 CorbaSequenceHandler (org.apache.cxf.binding.corba.types.CorbaSequenceHandler)1 CorbaStructHandler (org.apache.cxf.binding.corba.types.CorbaStructHandler)1 CorbaUnionHandler (org.apache.cxf.binding.corba.types.CorbaUnionHandler)1