Package org.apache.geronimo.corba.io

Examples of org.apache.geronimo.corba.io.EncapsulationOutputStream


          out.write_long(cached_bytes.length);
          out.write_octet_array(cached_bytes, 0, cached_bytes.length);
          return;
        }
       
        EncapsulationOutputStream eo = new EncapsulationOutputStream(out.__orb());
        write_content(eo);
        try {
             out.write_long(eo.__stream_position());
            eo.writeTo(out);
        }
        catch (IOException ex) {
            MARSHAL m = new MARSHAL();
            m.initCause(ex);
            throw m;
View Full Code Here


    public static void write(OutputStreamBase out, TypeCode tc, java.util.Map map)
            throws org.omg.CORBA.TypeCodePackage.BadKind,
                   org.omg.CORBA.TypeCodePackage.Bounds
    {

        EncapsulationOutputStream eout;
        Integer pos = (Integer) map.get(tc);
        if (pos != null) {
            out.write_long(-1);
            out.write_long(pos.intValue() - out.__stream_position());
        } else {
              out.write_long(tc.kind().value());
            // org.omg.CORBA.TCKindHelper.write(out, tc.kind());
            pos = new Integer(out.__stream_position() - 4);

            switch (tc.kind().value()) {
                case TCKind._tk_null:
                case TCKind._tk_void:
                case TCKind._tk_short:
                case TCKind._tk_long:
                case TCKind._tk_longlong:
                case TCKind._tk_ushort:
                case TCKind._tk_ulong:
                case TCKind._tk_ulonglong:
                case TCKind._tk_float:
                case TCKind._tk_double:
                case TCKind._tk_longdouble:
                case TCKind._tk_boolean:
                case TCKind._tk_char:
                case TCKind._tk_wchar:
                case TCKind._tk_octet:
                case TCKind._tk_any:
                case TCKind._tk_TypeCode:
                case TCKind._tk_Principal:
                    break;

                case TCKind._tk_fixed:
                    map.put(tc, pos);
                    out.write_ushort(tc.fixed_digits());
                    out.write_short(tc.fixed_scale());
                    break;

                case TCKind._tk_objref:
                case TCKind._tk_abstract_interface:
                case TCKind._tk_native:
                    map.put(tc, pos);
                    eout = out.__open_encapsulation();
                    eout.write_string(tc.id());
                    eout.write_string(tc.name());
                    out.__close_encapsulation(eout);
                    break;

                case TCKind._tk_struct:
                case TCKind._tk_except:
                    map.put(tc, pos);
                    eout = out.__open_encapsulation();
                    eout.write_string(tc.id());
                    eout.write_string(tc.name());
                    eout.write_ulong(tc.member_count());
                    for (int i = 0; i < tc.member_count(); i++) {
                        eout.write_string(tc.member_name(i));
                        // recurse
                        write(eout, tc.member_type(i), map);
                    }
                    out.__close_encapsulation(eout);
                    break;

                case TCKind._tk_union: {
                    map.put(tc, pos);
                    eout = out.__open_encapsulation();
                    eout.write_string(tc.id());
                    eout.write_string(tc.name());

                    // write discriminator
                    TypeCodeImpl disc = (TypeCodeImpl) tc.discriminator_type();
                    write(eout, disc, map);

                    int index = tc.default_index();
                    eout.write_long(index);
                    eout.write_ulong(tc.member_count());

                    for (int i = 0; i < tc.member_count(); i++) {

                        if (i == index) {
                            switch (disc.kind().value()) {
                                case TCKind._tk_short:
                                case TCKind._tk_ushort:
                                    eout.write_short((short) 0);
                                    break;

                                case TCKind._tk_long:
                                case TCKind._tk_ulong:
                                    eout.write_long(0);
                                    break;

                                case TCKind._tk_longlong:
                                case TCKind._tk_ulonglong:
                                    eout.write_longlong(0);
                                    break;

                                case TCKind._tk_boolean:
                                    eout.write_boolean(false);
                                    break;

                                case TCKind._tk_char:
                                    eout.write_char((char) 0);
                                    break;

                                case TCKind._tk_enum:
                                    eout.write_ulong(0);
                                    break;

                                default:
                                    throw new org.omg.CORBA.BAD_TYPECODE();

                            }
                        } else {
                            tc.member_label(i).write_value(eout);
                        }

                        eout.write_string(tc.member_name(i));
                        write(eout, tc.member_type(i), map);
                    }

                    out.__close_encapsulation(eout);
                    break;
                }

                case TCKind._tk_enum:
                    map.put(tc, pos);
                    eout = out.__open_encapsulation();
                    eout.write_string(tc.id());
                    eout.write_string(tc.name());
                    eout.write_ulong(tc.member_count());
                    for (int i = 0; i < tc.member_count(); i++) {
                        eout.write_string(tc.member_name(i));
                    }
                    out.__close_encapsulation(eout);
                    break;

                case TCKind._tk_string:
                case TCKind._tk_wstring:
                    out.write_ulong(tc.length());
                    break;

                case TCKind._tk_sequence:
                case TCKind._tk_array:
                    map.put(tc, pos);
                    eout = out.__open_encapsulation();
                    write(out, tc.content_type(), map);
                    out.write_ulong(tc.length());
                    out.__close_encapsulation(eout);
                    break;

                case TCKind._tk_value: {
                    map.put(tc, pos);

                    TypeCode base = tc.concrete_base_type();
                    if (base == null) {
                        base = get_primitive_tc(TCKind.tk_null);
                    }

                    eout = out.__open_encapsulation();

                    eout.write_string(tc.id());
                    eout.write_string(tc.name());
                    eout.write_short(tc.type_modifier());
                    write(eout, base, map);
                    eout.write_ulong(tc.member_count());
                    for (int i = 0; i < tc.member_count(); i++) {
                        eout.write_string(tc.member_name(i));
                        write(eout, tc.member_type(i), map);
                        eout.write_short(tc.member_visibility(i));
                    }
                    out.__close_encapsulation(eout);
                    break;
                }

                case TCKind._tk_value_box:
                    map.put(tc, pos);
                    eout = out.__open_encapsulation();

                    eout.write_string(tc.id());
                    eout.write_string(tc.name());

                    write(eout, tc.content_type(), map);

                    out.__close_encapsulation(eout);
                    break;
View Full Code Here

TOP

Related Classes of org.apache.geronimo.corba.io.EncapsulationOutputStream

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.