Package com.sun.corba.se.impl.encoding

Examples of com.sun.corba.se.impl.encoding.TypeCodeOutputStream


        else
            return new TypeCodeImpl(orb, tc);
    }

    public static CDROutputStream newOutputStream(ORB orb) {
        TypeCodeOutputStream tcos =
            sun.corba.OutputStreamFactory.newTypeCodeOutputStream(orb);
        //if (debug) System.out.println("Created TypeCodeOutputStream " + tcos +
        // " with no parent");
        return tcos;
    }
View Full Code Here


        // Wrap OutputStream into TypeCodeOutputStream.
        // This test shouldn't be necessary according to the Java language spec.
        if (os instanceof TypeCodeOutputStream) {
            this.write_value((TypeCodeOutputStream)os);
        } else {
            TypeCodeOutputStream wrapperOutStream = null;

            if (outBuffer == null) {
                wrapperOutStream = TypeCodeOutputStream.wrapOutputStream(os);
                this.write_value(wrapperOutStream);
                if (cachingEnabled) {
                    // Cache the buffer for repeated writes
                    outBuffer = wrapperOutStream.getTypeCodeBuffer();
                    //if (outBuffer != null)
                        //System.out.println("Caching outBuffer with length = " +
                        //outBuffer.length + " for id = " + _id);
                }
            } else {
                //System.out.println("Using cached outBuffer: length = " + outBuffer.length +
                                   //", id = " + _id);
            }
            // Write the first 4 bytes first to trigger alignment.
            // We know that it is the kind.
            if (cachingEnabled && outBuffer != null) {
                os.write_long(_kind);
                os.write_octet_array(outBuffer, 0, outBuffer.length);
            } else {
                //System.out.println("Buffer is empty for " + _id);
                wrapperOutStream.writeRawBuffer(os, _kind);
            }
        }
    }
View Full Code Here

        // Don't do any work if this is native
        if (_kind == TCKind._tk_native)
            throw wrapper.cannotMarshalNative() ;

        TypeCodeOutputStream topStream = tcos.getTopLevelStream();
        //if (debug) tcos.printBuffer();

        if (_kind == tk_indirect) {
            //if (debug) System.out.println("Writing indirection " + _name + "to " + _id);
            // The encoding used for indirection is the same as that used for recursive ,
            // TypeCodes i.e., a 0xffffffff indirection marker followed by a long offset
            // (in units of octets) from the beginning of the long offset.
            int pos = topStream.getPositionForID(_id);
            int topPos = tcos.getTopLevelPosition();
            //if (debug) System.out.println("TypeCodeImpl " + tcos +
            // " writing indirection " + _id +
                //" to position " + pos + " at position " + topPos);
            tcos.writeIndirection(tk_indirect, pos);
            // All that gets written is _kind and offset.
            return;
        }

        // The original approach changed for 5034649
        // topStream.addIDAtPosition(_id, tcos.getTopLevelPosition());

        // marshal the kind
        tcos.write_long(_kind);

        //if (debug) System.out.println("Writing " + _name + " with id " + _id);
        // We have to remember the stream and position for EVERY type code
        // in case some recursive or indirect type code references it.
        //
        // Bug fix 5034649:
        // Do this AFTER the write of the _kind in case the alignment
        // for the long changes the position.
        topStream.addIDAtPosition(_id, tcos.getTopLevelPosition()-4);

        switch (typeTable[_kind]) {
        case EMPTY:
            // nothing more to marshal
            break;

        case SIMPLE:
            switch (_kind) {
            case TCKind._tk_string:
            case TCKind._tk_wstring:
                // marshal the bound on string length
                tcos.write_long(_length);
                break;
            case TCKind._tk_fixed:
                tcos.write_ushort(_digits);
                tcos.write_short(_scale);
                break;
            default:
                // unknown typecode kind
                throw wrapper.invalidSimpleTypecode() ;
            }
            break;

        case COMPLEX:
            {
                // create an encapsulation
                TypeCodeOutputStream _encap = tcos.createEncapsulation(tcos.orb());

                switch(_kind) {

                case TCKind._tk_objref:
                case TCKind._tk_abstract_interface:
                    {
                        // put the repository id
                        _encap.write_string(_id);

                        // put the name
                        _encap.write_string(_name);
                    }
                    break;

                case TCKind._tk_union:
                    {
                        // put the repository id
                        _encap.write_string(_id);

                        // put the name
                        _encap.write_string(_name);

                        // discriminant typecode
                        _discriminator.write_value(_encap);

                        // default index
                        _encap.write_long(_defaultIndex);

                        // put the number of members
                        _encap.write_long(_memberCount);

                        // marshal label values, names and types
                        for (int i=0; i < _memberCount; i++) {

                            // for the default case, marshal the zero octet
                            if (i == _defaultIndex)
                                _encap.write_octet(_unionLabels[i].extract_octet());

                            else {
                                switch (realType(_discriminator).kind().value()) {
                                case TCKind._tk_short:
                                    _encap.write_short(_unionLabels[i].extract_short());
                                    break;
                                case TCKind._tk_long:
                                    _encap.write_long(_unionLabels[i].extract_long());
                                    break;
                                case TCKind._tk_ushort:
                                    _encap.write_short(_unionLabels[i].extract_ushort());
                                    break;
                                case TCKind._tk_ulong:
                                    _encap.write_long(_unionLabels[i].extract_ulong());
                                    break;
                                case TCKind._tk_float:
                                    _encap.write_float(_unionLabels[i].extract_float());
                                    break;
                                case TCKind._tk_double:
                                    _encap.write_double(_unionLabels[i].extract_double());
                                    break;
                                case TCKind._tk_boolean:
                                    _encap.write_boolean(_unionLabels[i].extract_boolean());
                                    break;
                                case TCKind._tk_char:
                                    _encap.write_char(_unionLabels[i].extract_char());
                                    break;
                                case TCKind._tk_enum:
                                    _encap.write_long(_unionLabels[i].extract_long());
                                    break;
                                case TCKind._tk_longlong:
                                    _encap.write_longlong(_unionLabels[i].extract_longlong());
                                    break;
                                case TCKind._tk_ulonglong:
                                    _encap.write_longlong(_unionLabels[i].extract_ulonglong());
                                    break;
                                    // _REVISIT_ figure out long double mapping
                                    // case TCKind.tk_longdouble:
                                    // _encap.putDouble(_unionLabels[i].extract_longdouble());
                                    // break;
                                case TCKind._tk_wchar:
                                    _encap.write_wchar(_unionLabels[i].extract_wchar());
                                    break;
                                default:
                                    throw wrapper.invalidComplexTypecode() ;
                                }
                            }
                            _encap.write_string(_memberNames[i]);
                            _memberTypes[i].write_value(_encap);
                        }
                    }
                    break;

                case TCKind._tk_enum:
                    {
                        // put the repository id
                        _encap.write_string(_id);

                        // put the name
                        _encap.write_string(_name);

                        // put the number of members
                        _encap.write_long(_memberCount);

                        // marshal identifier names
                        for (int i=0; i < _memberCount; i++)
                            _encap.write_string(_memberNames[i]);
                    }
                    break;

                case TCKind._tk_sequence:
                    {
                        // put the type of the sequence
                        lazy_content_type().write_value(_encap);

                        // put the bound on the length of the sequence
                        _encap.write_long(_length);
                    }
                    break;

                case TCKind._tk_array:
                    {
                        // put the type of the array
                        _contentType.write_value(_encap);

                        // put the length of the array
                        _encap.write_long(_length);
                    }
                    break;

                case TCKind._tk_alias:
                case TCKind._tk_value_box:
                    {
                        // put the repository id
                        _encap.write_string(_id);

                        // put the name
                        _encap.write_string(_name);

                        // put the type aliased
                        _contentType.write_value(_encap);
                    }
                    break;

                case TCKind._tk_struct:
                case TCKind._tk_except:
                    {
                        // put the repository id
                        _encap.write_string(_id);

                        // put the name
                        _encap.write_string(_name);

                        // put the number of members
                        _encap.write_long(_memberCount);

                        // marshal member names and types
                        for (int i=0; i < _memberCount; i++) {
                            _encap.write_string(_memberNames[i]);
                            //if (debug) System.out.println("TypeCode " + _name +
                            // " writing member " + _memberNames[i]);
                            _memberTypes[i].write_value(_encap);
                        }
                    }
                    break;

                case TCKind._tk_value:
                    {
                        // put the repository id
                        _encap.write_string(_id);

                        // put the name
                        _encap.write_string(_name);

                        // put the type modifier
                        _encap.write_short(_type_modifier);

                        // put the type aliased
                        if (_concrete_base == null) {
                            _orb.get_primitive_tc(TCKind._tk_null).write_value(_encap);
                        } else {
                            _concrete_base.write_value(_encap);
                        }

                        // put the number of members
                        _encap.write_long(_memberCount);

                        // marshal member names and types
                        for (int i=0; i < _memberCount; i++) {
                            _encap.write_string(_memberNames[i]);
                            //if (debug) System.out.println("TypeCode " + _name +
                            // " writing member " + _memberNames[i]);
                            _memberTypes[i].write_value(_encap);
                            _encap.write_short(_memberAccess[i]);
                        }
                    }
                    break;

                default:
                    throw wrapper.invalidTypecodeKindMarshal() ;
                }

                // marshal the encapsulation
                _encap.writeOctetSequenceTo(tcos);
                break;
            }
        }
    }
View Full Code Here

        else
            return new TypeCodeImpl(orb, tc);
    }

    public static CDROutputStream newOutputStream(ORB orb) {
        TypeCodeOutputStream tcos = new TypeCodeOutputStream((ORB)orb);
        //if (debug) System.out.println("Created TypeCodeOutputStream " + tcos +
        // " with no parent");
        return tcos;
    }
View Full Code Here

        // Wrap OutputStream into TypeCodeOutputStream.
        // This test shouldn't be necessary according to the Java language spec.
        if (os instanceof TypeCodeOutputStream) {
            this.write_value((TypeCodeOutputStream)os);
        } else {
            TypeCodeOutputStream wrapperOutStream = null;

            if (outBuffer == null) {
                wrapperOutStream = TypeCodeOutputStream.wrapOutputStream(os);
                this.write_value(wrapperOutStream);
                if (cachingEnabled) {
                    // Cache the buffer for repeated writes
                    outBuffer = wrapperOutStream.getTypeCodeBuffer();
                    //if (outBuffer != null)
                        //System.out.println("Caching outBuffer with length = " +
                        //outBuffer.length + " for id = " + _id);
                }
            } else {
                //System.out.println("Using cached outBuffer: length = " + outBuffer.length +
                                   //", id = " + _id);
            }
            // Write the first 4 bytes first to trigger alignment.
            // We know that it is the kind.
            if (cachingEnabled && outBuffer != null) {
                os.write_long(_kind);
                os.write_octet_array(outBuffer, 0, outBuffer.length);
            } else {
                //System.out.println("Buffer is empty for " + _id);
                wrapperOutStream.writeRawBuffer(os, _kind);
            }
        }
    }
View Full Code Here

        // Don't do any work if this is native
        if (_kind == TCKind._tk_native)
            throw wrapper.cannotMarshalNative() ;

        TypeCodeOutputStream topStream = tcos.getTopLevelStream();
        //if (debug) tcos.printBuffer();

        if (_kind == tk_indirect) {
            //if (debug) System.out.println("Writing indirection " + _name + "to " + _id);
            // The encoding used for indirection is the same as that used for recursive ,
            // TypeCodes i.e., a 0xffffffff indirection marker followed by a long offset
            // (in units of octets) from the beginning of the long offset.
            int pos = topStream.getPositionForID(_id);
            int topPos = tcos.getTopLevelPosition();
            //if (debug) System.out.println("TypeCodeImpl " + tcos +
            // " writing indirection " + _id +
                //" to position " + pos + " at position " + topPos);
            tcos.writeIndirection(tk_indirect, pos);
            // All that gets written is _kind and offset.
            return;
        }

        // The original approach changed for 5034649
        // topStream.addIDAtPosition(_id, tcos.getTopLevelPosition());

        // marshal the kind
        tcos.write_long(_kind);

        //if (debug) System.out.println("Writing " + _name + " with id " + _id);
        // We have to remember the stream and position for EVERY type code
        // in case some recursive or indirect type code references it.
        //
        // Bug fix 5034649:
        // Do this AFTER the write of the _kind in case the alignment
        // for the long changes the position.
        topStream.addIDAtPosition(_id, tcos.getTopLevelPosition()-4);

        switch (typeTable[_kind]) {
        case EMPTY:
            // nothing more to marshal
            break;

        case SIMPLE:
            switch (_kind) {
            case TCKind._tk_string:
            case TCKind._tk_wstring:
                // marshal the bound on string length
                tcos.write_long(_length);
                break;
            case TCKind._tk_fixed:
                tcos.write_ushort(_digits);
                tcos.write_short(_scale);
                break;
            default:
                // unknown typecode kind
                throw wrapper.invalidSimpleTypecode() ;
            }
            break;

        case COMPLEX:
            {
                // create an encapsulation
                TypeCodeOutputStream _encap = tcos.createEncapsulation(tcos.orb());

                switch(_kind) {

                case TCKind._tk_objref:
                case TCKind._tk_abstract_interface:
                    {
                        // put the repository id
                        _encap.write_string(_id);

                        // put the name
                        _encap.write_string(_name);
                    }
                    break;

                case TCKind._tk_union:
                    {
                        // put the repository id
                        _encap.write_string(_id);

                        // put the name
                        _encap.write_string(_name);

                        // discriminant typecode
                        _discriminator.write_value(_encap);

                        // default index
                        _encap.write_long(_defaultIndex);

                        // put the number of members
                        _encap.write_long(_memberCount);

                        // marshal label values, names and types
                        for (int i=0; i < _memberCount; i++) {

                            // for the default case, marshal the zero octet
                            if (i == _defaultIndex)
                                _encap.write_octet(_unionLabels[i].extract_octet());

                            else {
                                switch (realType(_discriminator).kind().value()) {
                                case TCKind._tk_short:
                                    _encap.write_short(_unionLabels[i].extract_short());
                                    break;
                                case TCKind._tk_long:
                                    _encap.write_long(_unionLabels[i].extract_long());
                                    break;
                                case TCKind._tk_ushort:
                                    _encap.write_short(_unionLabels[i].extract_ushort());
                                    break;
                                case TCKind._tk_ulong:
                                    _encap.write_long(_unionLabels[i].extract_ulong());
                                    break;
                                case TCKind._tk_float:
                                    _encap.write_float(_unionLabels[i].extract_float());
                                    break;
                                case TCKind._tk_double:
                                    _encap.write_double(_unionLabels[i].extract_double());
                                    break;
                                case TCKind._tk_boolean:
                                    _encap.write_boolean(_unionLabels[i].extract_boolean());
                                    break;
                                case TCKind._tk_char:
                                    _encap.write_char(_unionLabels[i].extract_char());
                                    break;
                                case TCKind._tk_enum:
                                    _encap.write_long(_unionLabels[i].extract_long());
                                    break;
                                case TCKind._tk_longlong:
                                    _encap.write_longlong(_unionLabels[i].extract_longlong());
                                    break;
                                case TCKind._tk_ulonglong:
                                    _encap.write_longlong(_unionLabels[i].extract_ulonglong());
                                    break;
                                    // _REVISIT_ figure out long double mapping
                                    // case TCKind.tk_longdouble:
                                    // _encap.putDouble(_unionLabels[i].extract_longdouble());
                                    // break;
                                case TCKind._tk_wchar:
                                    _encap.write_wchar(_unionLabels[i].extract_wchar());
                                    break;
                                default:
                                    throw wrapper.invalidComplexTypecode() ;
                                }
                            }
                            _encap.write_string(_memberNames[i]);
                            _memberTypes[i].write_value(_encap);
                        }
                    }
                    break;

                case TCKind._tk_enum:
                    {
                        // put the repository id
                        _encap.write_string(_id);

                        // put the name
                        _encap.write_string(_name);

                        // put the number of members
                        _encap.write_long(_memberCount);

                        // marshal identifier names
                        for (int i=0; i < _memberCount; i++)
                            _encap.write_string(_memberNames[i]);
                    }
                    break;

                case TCKind._tk_sequence:
                    {
                        // put the type of the sequence
                        lazy_content_type().write_value(_encap);

                        // put the bound on the length of the sequence
                        _encap.write_long(_length);
                    }
                    break;

                case TCKind._tk_array:
                    {
                        // put the type of the array
                        _contentType.write_value(_encap);

                        // put the length of the array
                        _encap.write_long(_length);
                    }
                    break;

                case TCKind._tk_alias:
                case TCKind._tk_value_box:
                    {
                        // put the repository id
                        _encap.write_string(_id);

                        // put the name
                        _encap.write_string(_name);

                        // put the type aliased
                        _contentType.write_value(_encap);
                    }
                    break;

                case TCKind._tk_struct:
                case TCKind._tk_except:
                    {
                        // put the repository id
                        _encap.write_string(_id);

                        // put the name
                        _encap.write_string(_name);

                        // put the number of members
                        _encap.write_long(_memberCount);

                        // marshal member names and types
                        for (int i=0; i < _memberCount; i++) {
                            _encap.write_string(_memberNames[i]);
                            //if (debug) System.out.println("TypeCode " + _name +
                            // " writing member " + _memberNames[i]);
                            _memberTypes[i].write_value(_encap);
                        }
                    }
                    break;

                case TCKind._tk_value:
                    {
                        // put the repository id
                        _encap.write_string(_id);

                        // put the name
                        _encap.write_string(_name);

                        // put the type modifier
                        _encap.write_short(_type_modifier);

                        // put the type aliased
                        if (_concrete_base == null) {
                            _orb.get_primitive_tc(TCKind._tk_null).write_value(_encap);
                        } else {
                            _concrete_base.write_value(_encap);
                        }

                        // put the number of members
                        _encap.write_long(_memberCount);

                        // marshal member names and types
                        for (int i=0; i < _memberCount; i++) {
                            _encap.write_string(_memberNames[i]);
                            //if (debug) System.out.println("TypeCode " + _name +
                            // " writing member " + _memberNames[i]);
                            _memberTypes[i].write_value(_encap);
                            _encap.write_short(_memberAccess[i]);
                        }
                    }
                    break;

                default:
                    throw wrapper.invalidTypecodeKindMarshal() ;
                }

                // marshal the encapsulation
                _encap.writeOctetSequenceTo(tcos);
                break;
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.sun.corba.se.impl.encoding.TypeCodeOutputStream

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.