private Token readToken()

in geronimo-mail_2.1_spec/src/main/java/jakarta/mail/internet/HeaderTokenizer.java [169:212]


    private Token readToken(final char endOfAtom, final boolean keepEscapes) throws ParseException {
        if (pos >= _headerLength) {
            return EOF;
        } else {
            final char c = _header.charAt(pos);
            // comment token...read and skip over this
            if (c == '(') {
                final Token comment = readComment(keepEscapes);
                if (_skip) {
                    return readToken(endOfAtom, keepEscapes);
                } else {
                    return comment;
                }

            // quoted literal
            } else if (c == '\"') {
                return readQuotedString('"', keepEscapes, 1);

            // white space, eat this and find a real token.
            } else if (WHITE.indexOf(c) != -1) {
                eatWhiteSpace();
                return readToken(endOfAtom, keepEscapes);

            // either a CTL or special.  These characters have a self-defining token type.
            } else if (c < 32 || c >= 127 || _delimiters.indexOf(c) != -1) {

                if (endOfAtom != NUL && c != endOfAtom) {
                    return readQuotedString(endOfAtom, keepEscapes, 0);
                }


                pos++;
                return new Token(c, String.valueOf(c));

            } else {
                // start of an atom, parse it off.
                if (endOfAtom != NUL && c != endOfAtom) {
                    return readQuotedString(endOfAtom, keepEscapes, 0);
                }

                return readAtomicToken();
            }
        }
    }