Search in sources :

Example 1 with CorbaOctetSequenceHandler

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

the class CorbaObjectReader method readSequence.

// CHECKSTYLE:ON
public void readSequence(CorbaObjectHandler obj) throws CorbaBindingException {
    if (obj instanceof CorbaOctetSequenceHandler) {
        int length = stream.read_ulong();
        byte[] value = new byte[length];
        stream.read_octet_array(value, 0, length);
        ((CorbaOctetSequenceHandler) obj).setValue(value);
    } else {
        CorbaSequenceHandler sequenceObj = (CorbaSequenceHandler) obj;
        List<CorbaObjectHandler> seqElements = sequenceObj.getElements();
        int length = stream.read_ulong();
        List<CorbaObjectHandler> elements = new ArrayList<>(length);
        // object that is in the input stream.
        if (sequenceObj.getTemplateElement() != null) {
            sequenceObj.clear();
            CorbaObjectHandler template = sequenceObj.getTemplateElement();
            for (int i = 0; i < length; ++i) {
                CorbaObjectHandler seqElement;
                if (i < seqElements.size()) {
                    seqElement = seqElements.get(i);
                } else {
                    seqElement = initializeCorbaObjectHandler(template);
                }
                read(seqElement);
                elements.add(seqElement);
            }
            sequenceObj.setElements(elements);
        } else {
            // We have a bounded sequence and the object should already be pre-built
            for (int i = 0; i < length; ++i) {
                read(seqElements.get(i));
            }
            sequenceObj.setElements(seqElements.subList(0, length));
        }
    }
}
Also used : CorbaOctetSequenceHandler(org.apache.cxf.binding.corba.types.CorbaOctetSequenceHandler) CorbaSequenceHandler(org.apache.cxf.binding.corba.types.CorbaSequenceHandler) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) ArrayList(java.util.ArrayList)

Example 2 with CorbaOctetSequenceHandler

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

the class CorbaObjectWriter method writeSequence.

public void writeSequence(CorbaObjectHandler obj) throws CorbaBindingException {
    if (obj instanceof CorbaOctetSequenceHandler) {
        byte[] value = ((CorbaOctetSequenceHandler) obj).getValue();
        stream.write_ulong(value.length);
        stream.write_octet_array(value, 0, value.length);
    } else {
        CorbaSequenceHandler seqHandler = (CorbaSequenceHandler) obj;
        List<CorbaObjectHandler> seqElements = seqHandler.getElements();
        int length = seqElements.size();
        stream.write_ulong(length);
        for (int i = 0; i < length; ++i) {
            this.write(seqElements.get(i));
        }
    }
}
Also used : CorbaOctetSequenceHandler(org.apache.cxf.binding.corba.types.CorbaOctetSequenceHandler) CorbaSequenceHandler(org.apache.cxf.binding.corba.types.CorbaSequenceHandler) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler)

Aggregations

CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)2 CorbaOctetSequenceHandler (org.apache.cxf.binding.corba.types.CorbaOctetSequenceHandler)2 CorbaSequenceHandler (org.apache.cxf.binding.corba.types.CorbaSequenceHandler)2 ArrayList (java.util.ArrayList)1