private void skip_over_container()

in src/com/amazon/ion/impl/IonReaderTextRawTokensX.java [1209:1286]


    private void skip_over_container(int terminator) throws IOException
    {
        assert( terminator == '}' || terminator == ']' || terminator == ')' );
        int c;

        for (;;) {
            c = skip_over_whitespace();
            switch (c) {
            case -1:
                unexpected_eof();
            case '}':
            case ']':
            case ')':
                if (c == terminator) { // no point is checking this on every char
                    return;
                }
                break;
            case '"':
                skip_double_quoted_string_helper();
                break;
            case '\'':
                if (is_2_single_quotes_helper()) {
                    skip_triple_quoted_string(null);
                }
                else {
                    c = skip_single_quoted_string(null);
                    unread_char(c);
                }
                break;
            case '(':
                skip_over_container(')');
                break;
            case '[':
                skip_over_container(']');
                break;
            case '{':
                // this consumes lobs as well since the double
                // braces count correctly and the contents
                // of either clobs or blobs will be just content
                c = read_char();
                if (c == '{') {
                    // 2nd '{' - it's a lob of some sort - let's find out what sort
                    c = skip_over_lob_whitespace();

                    int lobType;
                    if (c == '"') {
                        // clob, double quoted
                        lobType = IonTokenConstsX.TOKEN_STRING_DOUBLE_QUOTE;
                    }
                    else if (c == '\'') {
                        // clob, triple quoted - or error
                        if (!is_2_single_quotes_helper()) {
                            error("invalid single quote in lob content");
                        }
                        lobType = IonTokenConstsX.TOKEN_STRING_TRIPLE_QUOTE;
                    }
                    else {
                        // blob
                        unread_char(c);
                        lobType = IonTokenConstsX.TOKEN_OPEN_DOUBLE_BRACE;
                    }

                    skip_over_lob(lobType, null);
                }
                else if (c == '}') {
                    // do nothing, we just opened and closed an empty struct
                    // move on, there's nothing to see here ...
                }
                else {
                    unread_char(c);
                    skip_over_container('}');
                }
                break;
            default:
                break;
            }
        }
    }