private AddressToken scanGroupAddress()

in geronimo-mail_2.1_spec/src/main/java/jakarta/mail/internet/AddressParser.java [583:629]


    private AddressToken scanGroupAddress(final TokenStream tokens) throws AddressException {
        // A group does not require that there be anything between the ':' and ';".  This is
        // just a group with an empty list.
        AddressToken token = tokens.nextRealToken();

        // now scan until we reach the terminator.  The only validation is done on illegal characters.
        while (true) {
            switch (token.type) {
                // The following tokens are all valid in group addresses, so just skip over them.
                case ATOM:
                case QUOTED_LITERAL:
                case DOMAIN_LITERAL:
                case PERIOD:
                case AT_SIGN:
                case COMMA:
                    break;

                case COLON:
                     illegalAddress("Nested group", token);

                // route address within a group specifier....we need to at least verify the bracket nesting
                // and higher level syntax of the route.
                case LEFT_ANGLE:
                    scanRouteAddress(tokens, true);
                    break;

                // the only allowed terminator is the ';'
                case END_OF_TOKENS:
                    illegalAddress("Missing ';'", token);

                // now for the illegal ones in this context.
                case SEMICOLON:
                    // verify there's nothing illegal after this.
                    final AddressToken next = tokens.nextRealToken();
                    if (next.type != COMMA && next.type != END_OF_TOKENS) {
                        illegalAddress("Illegal address", token);
                    }
                    // don't forget to put this back on...our caller will need it.
                    tokens.pushToken(next);
                    return token;

                case RIGHT_ANGLE:
                    illegalAddress("Unexpected '>'", token);
            }
            token = tokens.nextRealToken();
        }
    }