private static String getErrorSnippet(final String record, final int pos) {
        final StringBuilder snippet = new StringBuilder();

        final int start = pos - SNIPPET_SIZE / 2;
        if (start < 0) {
            snippet.append(record.substring(0, pos));
        } else {
            snippet.append(SNIPPET_ELLIPSIS);
            snippet.append(record.substring(start, pos));
        }

        snippet.append(POS_MARKER_LEFT);
        snippet.append(record.charAt(pos));
        snippet.append(POS_MARKER_RIGHT);

        if (pos + 1 < record.length()) {
            final int end = pos + SNIPPET_SIZE / 2;
            if (end > record.length()) {
                snippet.append(record.substring(pos + 1));
            } else {
                snippet.append(record.substring(pos + 1, end));
                snippet.append(SNIPPET_ELLIPSIS);
            }
        }

        return snippet.toString();
    }
private static String getErrorSnippet ( final String record , final int pos ) { final StringBuilder snippet = new StringBuilder ( ) ; final int start = pos - SNIPPET_SIZE / 2 ; if ( start < 0 ) { snippet . append ( record . substring ( 0 , pos ) ) ; } else { snippet . append ( SNIPPET_ELLIPSIS ) ; snippet . append ( record . substring ( start , pos ) ) ; } snippet . append ( POS_MARKER_LEFT ) ; snippet . append ( record . charAt ( pos ) ) ; snippet . append ( POS_MARKER_RIGHT ) ; if ( pos + 1 < record . length ( ) ) { final int end = pos + SNIPPET_SIZE / 2 ; if ( end > record . length ( ) ) { snippet . append ( record . substring ( pos + 1 ) ) ; } else { snippet . append ( record . substring ( pos + 1 , end ) ) ; snippet . append ( SNIPPET_ELLIPSIS ) ; } } return snippet . toString ( ) ; }
Extracts a text snippet from the record for showing the position at
which an error occurred. The exact position additionally highlighted
with {@link POS_MARKER_LEFT} and {@link POS_MARKER_RIGHT}.

@param record the record currently being parsed
@param pos the position at which the error occurred
@return a text snippet.