code: public synchronized List<GrammarError> grammarErrors(String text, String language) {
          requireValidHandle();
          List<GrammarError> errorList = new ArrayList<GrammarError>();
          if (!isValidInput(text)) {
              return errorList;
          }
          int offset = 0;
          for (String paragraph : text.replace("\r", "\n").split("\\n")) {
              appendErrorsFromParagraph(errorList, paragraph, offset, language);
              offset += paragraph.length() + 1;
          }
          return errorList;
      }
docs: Check the given text for grammar errors and return a
  list of GrammarError objects representing the errors that were found.
  Unlike the C based API this method accepts multiple paragraphs
  separated by newline characters.
  @param text
  @param language language in which error descriptions should be returned
  @return list of grammar errors