private void readHeader()

in yoko-core/src/main/java/org/apache/yoko/orb/OB/ValueReader.java [370:539]


    private void readHeader(Header h) {
        if (logger.isLoggable(Level.FINE))
            logger.fine(String.format("Reading header with tag value 0x%08x at pos=0x%x", h.tag, in_.buf_.pos_));

        //
        // Special cases are handled elsewhere
        //
        Assert._OB_assert((h.tag != 0) && (h.tag != -1));

        //
        // Check if the value is chunked
        //
        if ((h.tag & 0x00000008) == 8) {
            h.state.chunked = true;
        } else {
            h.state.chunked = false;
        }

        //
        // Check for presence of codebase URL
        //
        if ((h.tag & 0x00000001) == 1) {
            //
            // Check for indirection tag
            //
            final int save = buf_.pos_;
            final int indTag = in_.read_long();
            if (indTag == -1) {
                final int offs = in_.read_long();
                if (offs >= -4) {
                    throw new MARSHAL(MinorCodes.describeMarshal(MinorCodes.MinorReadInvalidIndirection), MinorCodes.MinorReadInvalidIndirection,
                            CompletionStatus.COMPLETED_NO);
                }
                final int tmp = buf_.pos_;
                buf_.pos_ = (buf_.pos_ - 4) + offs;
                if (buf_.pos_ < 0) {
                    throw new MARSHAL(MinorCodes.describeMarshal(MinorCodes.MinorReadInvalidIndirection), MinorCodes.MinorReadInvalidIndirection,
                            CompletionStatus.COMPLETED_NO);
                }
                h.codebase = in_.read_string();
                buf_.pos_ = tmp;
            } else {
                buf_.pos_ = save;
                h.codebase = in_.read_string();
            }
            if (logger.isLoggable(Level.FINER))
                logger.finer(String.format("Value header codebase value is \"%s\"", h.codebase));
        }

        //
        // Extract repository ID information
        //
        if ((h.tag & 0x00000006) == 0) {
            logger.finer("No type information was included");
            //
            // No type information was marshalled
            //
        } else if ((h.tag & 0x00000006) == 6) {
            logger.finer("Multiple types included in header");
            //
            // Extract a list of repository IDs, representing the
            // truncatable types for this value
            //

            //
            // Check for indirection tag (indirected list)
            //
            int saveList = buf_.pos_;
            int indTag = in_.read_long();
            final boolean indList = (indTag == -1);

            if (indList) {
                final int offs = in_.read_long();
                if (offs > -4) {
                    throw new MARSHAL(MinorCodes.describeMarshal(MinorCodes.MinorReadInvalidIndirection), MinorCodes.MinorReadInvalidIndirection,
                            CompletionStatus.COMPLETED_NO);
                }
                saveList = buf_.pos_;
                buf_.pos_ = (buf_.pos_ - 4) + offs;
                if (buf_.pos_ < 0) {
                    throw new MARSHAL(MinorCodes.describeMarshal(MinorCodes.MinorReadInvalidIndirection), MinorCodes.MinorReadInvalidIndirection,
                            CompletionStatus.COMPLETED_NO);
                }
            } else {
                buf_.pos_ = saveList;
            }

            final int count = in_.read_long();
            h.ids = new String[count];

            for (int i = 0; i < count; i++) {
                //
                // Check for indirection tag (indirected list entry)
                //
                int saveRep = buf_.pos_;
                indTag = in_.read_long();
                if (indTag == -1) {
                    final int offs = in_.read_long();
                    if (offs > -4) {
                        throw new MARSHAL(MinorCodes.describeMarshal(MinorCodes.MinorReadInvalidIndirection), MinorCodes.MinorReadInvalidIndirection,
                                CompletionStatus.COMPLETED_NO);
                    }
                    saveRep = buf_.pos_;
                    buf_.pos_ = (buf_.pos_ - 4) + offs;
                    if (buf_.pos_ < 0) {
                        throw new MARSHAL(MinorCodes.describeMarshal(MinorCodes.MinorReadInvalidIndirection), MinorCodes.MinorReadInvalidIndirection,
                                CompletionStatus.COMPLETED_NO);
                    }
                    h.ids[i] = in_.read_string();
                    buf_.pos_ = saveRep;
                } else {
                    buf_.pos_ = saveRep;
                    h.ids[i] = in_.read_string();
                }
                if (logger.isLoggable(Level.FINER))
                    logger.finer(String.format("Value header respoitory id added \"%s\"", h.ids[i]));
            }

            //
            // Restore buffer position (case of indirected list)
            //
            if (indList) {
                buf_.pos_ = saveList;
            }
        } else if ((h.tag & 0x00000006) == 2) {
            //
            // Extract a single repository ID
            //
            final String id;

            //
            // Check for indirection tag
            //
            int save = buf_.pos_;
            final int indTag = in_.read_long();
            if (indTag == -1) {
                final int offs = in_.read_long();
                if (offs > -4) {
                    throw new MARSHAL(MinorCodes.describeMarshal(MinorCodes.MinorReadInvalidIndirection), MinorCodes.MinorReadInvalidIndirection,
                            CompletionStatus.COMPLETED_NO);
                }
                save = buf_.pos_;
                buf_.pos_ = (buf_.pos_ - 4) + offs;
                if (buf_.pos_ < 0) {
                    throw new MARSHAL(MinorCodes.describeMarshal(MinorCodes.MinorReadInvalidIndirection), MinorCodes.MinorReadInvalidIndirection,
                            CompletionStatus.COMPLETED_NO);
                }
                id = in_.read_string();
                buf_.pos_ = save;
            } else {
                buf_.pos_ = save;
                id = in_.read_string();
            }

            h.ids = new String[1];
            h.ids[0] = id;
            if (logger.isLoggable(Level.FINER))
                logger.finer(String.format("Single header repository id read \"%s\"", id));
        }

        //
        // Record beginning of value data
        //
        h.dataPos = buf_.pos_;

        //
        // Add entry to header table
        //
        headerTable_.put(h.headerPos, h);
    }