code: static String generateFragment( String content,
                                      int indexOfProblem,
                                      int charactersToIncludeBeforeAndAfter,
                                      String highlightText ) {
          assert content != null;
          assert indexOfProblem < content.length();
          // Find the substring that immediately precedes the current position ...
          int beforeStart = Math.max(0, indexOfProblem - charactersToIncludeBeforeAndAfter);
          String before = content.substring(beforeStart, indexOfProblem);
  
          // Find the substring that immediately follows the current position ...
          int afterEnd = Math.min(indexOfProblem + charactersToIncludeBeforeAndAfter, content.length());
          String after = content.substring(indexOfProblem, afterEnd);
  
          return before + (highlightText != null ? highlightText : "") + after;
      }
docs: Utility method to generate a highlighted fragment of a particular point in the stream.
  
  @param content the content from which the fragment should be taken; may not be null
  @param indexOfProblem the index of the problem point that should be highlighted; must be a valid index in the content
  @param charactersToIncludeBeforeAndAfter the maximum number of characters before and after the problem point to include in
  the fragment
  @param highlightText the text that should be included in the fragment at the problem point to highlight the location, or an
  empty string if there should be no highlighting
  @return the highlighted fragment; never null