protected CSSParseException toCSSParseException(final String key, final ParseException e) {
        final String messagePattern1 = getParserMessage("invalidExpectingOne");
        final String messagePattern2 = getParserMessage("invalidExpectingMore");
        int maxSize = 0;
        final StringBuilder expected = new StringBuilder();
        for (int i = 0; i < e.expectedTokenSequences.length; i++) {
            if (maxSize < e.expectedTokenSequences[i].length) {
                maxSize = e.expectedTokenSequences[i].length;
            }
            for (int j = 0; j < e.expectedTokenSequences[i].length; j++) {
                expected.append(e.tokenImage[e.expectedTokenSequences[i][j]]);
            }
            if (i < e.expectedTokenSequences.length - 1) {
                expected.append(", ");
            }
        }
        final StringBuilder invalid = new StringBuilder();
        Token tok = e.currentToken.next;
        for (int i = 0; i < maxSize; i++) {
            if (i != 0) {
                invalid.append(" ");
            }
            if (tok.kind == 0) {
                invalid.append(e.tokenImage[0]);
                break;
            }
            invalid.append(addEscapes(tok.image));
            tok = tok.next;
        }
        final StringBuilder message = new StringBuilder(getParserMessage(key));
        message.append(" (");
        if (e.expectedTokenSequences.length == 1) {
            message.append(MessageFormat.format(messagePattern1, new Object[] {invalid, expected}));
        }
        else {
            message.append(MessageFormat.format(messagePattern2, new Object[] {invalid, expected}));
        }
        message.append(")");
        return new CSSParseException(message.toString(),
            getInputSource().getURI(), e.currentToken.next.beginLine,
            e.currentToken.next.beginColumn);
    }
protected CSSParseException toCSSParseException ( final String key , final ParseException e ) { final String messagePattern1 = getParserMessage ( "invalidExpectingOne" ) ; final String messagePattern2 = getParserMessage ( "invalidExpectingMore" ) ; int maxSize = 0 ; final StringBuilder expected = new StringBuilder ( ) ; for ( int i = 0 ; i < e . expectedTokenSequences . length ; i ++ ) { if ( maxSize < e . expectedTokenSequences [ i ] . length ) { maxSize = e . expectedTokenSequences [ i ] . length ; } for ( int j = 0 ; j < e . expectedTokenSequences [ i ] . length ; j ++ ) { expected . append ( e . tokenImage [ e . expectedTokenSequences [ i ] [ j ] ] ) ; } if ( i < e . expectedTokenSequences . length - 1 ) { expected . append ( ", " ) ; } } final StringBuilder invalid = new StringBuilder ( ) ; Token tok = e . currentToken . next ; for ( int i = 0 ; i < maxSize ; i ++ ) { if ( i != 0 ) { invalid . append ( " " ) ; } if ( tok . kind == 0 ) { invalid . append ( e . tokenImage [ 0 ] ) ; break ; } invalid . append ( addEscapes ( tok . image ) ) ; tok = tok . next ; } final StringBuilder message = new StringBuilder ( getParserMessage ( key ) ) ; message . append ( " (" ) ; if ( e . expectedTokenSequences . length == 1 ) { message . append ( MessageFormat . format ( messagePattern1 , new Object [ ] { invalid , expected } ) ) ; } else { message . append ( MessageFormat . format ( messagePattern2 , new Object [ ] { invalid , expected } ) ) ; } message . append ( ")" ) ; return new CSSParseException ( message . toString ( ) , getInputSource ( ) . getURI ( ) , e . currentToken . next . beginLine , e . currentToken . next . beginColumn ) ; }
@param key the message lookup key
@param e the parse exception
@return a new CSSParseException