class LongSentenceRule extends TextLevelRule {

  public static final String RULE_ID = "TOO_LONG_SENTENCE";

  private static final Pattern QUOTED_SENT_END = Pattern.compile("[?!.][\"“”„»«]", Pattern.DOTALL);
  private static final Pattern SENT_END = Pattern.compile("[?!.]");

  private static List<String> OPENING_QUOTES = Arrays.asList("\"", "“", "„", "«", "(", "[", "{", "—");
  private static List<String> CLOSING_QUOTES = Arrays.asList("\"", "”", "“", "»", ")", "]", "}", "—");

  private final ResourceBundle messages;
  private final int maxWords;

  public LongSentenceRule(ResourceBundle messages, UserConfig userConfig, int maxWords) {
    this.messages = messages;
    setCategory(Categories.STYLE.getCategory(messages));
    setLocQualityIssueType(ITSIssueType.Style);
    setTags(Collections.singletonList(Tag.picky));
    int tmpMaxWords = maxWords;
    if (userConfig != null) {
      int confWords = userConfig.getConfigValueByID(getId());
      if (confWords > 0) {
        tmpMaxWords = confWords;
      }
    }
    this.maxWords = tmpMaxWords;
  }

  @Override
  public String getDescription() {
    return MessageFormat.format(messages.getString("long_sentence_rule_desc"), maxWords);
  }

  @Override
  public String getId() {
    return RULE_ID;
  }

  private boolean isWordCount(String tokenText) {
    if (tokenText.length() > 0) {
      return !StringTools.isNotWordCharacter(tokenText.substring(0,1));
    }
    return false;
  }

  public String getMessage() {
    return MessageFormat.format(messages.getString("long_sentence_rule_msg2"), maxWords);
  }

  @Override
  public RuleMatch[] match(List<AnalyzedSentence> sentences) throws IOException {<FILL_FUNCTION_BODY>}

  @Override
  public int minToCheckParagraph() {
    return 0;
  }
  
// next functions give the user the possibility to configure the function
  @Override
  public int getDefaultValue() {
    return maxWords;
  }

  @Override
  public boolean hasConfigurableValue() {
    return true;
  }

  @Override
  public int getMinConfigurableValue() {
    return 5;
  }

  @Override
  public int getMaxConfigurableValue() {
    return 100;
  }

  @Override
  public String getConfigureText() {
    return messages.getString("guiLongSentencesText");
  }
}

    List<RuleMatch> ruleMatches = new ArrayList<>();
    int pos = 0;
    for (AnalyzedSentence sentence : sentences) {
      AnalyzedTokenReadings[] tokens = sentence.getTokens();
      if (tokens.length < maxWords) {   // just a short-circuit
        pos += sentence.getCorrectedTextLength();
        continue;
      }
      if (QUOTED_SENT_END.matcher(sentence.getText()).find()) {
        pos += sentence.getCorrectedTextLength();
        continue;
      }
      String msg = getMessage();
      int i = 0;
      List<Integer> fromPos = new ArrayList<>();
      List<Integer> toPos = new ArrayList<>();

      AnalyzedTokenReadings fromPosToken = null;
      AnalyzedTokenReadings toPosToken = null;
      int indexOfQuote = -1 ;
      while (i < tokens.length) {
        int numWords = 0;
        while (i < tokens.length && !tokens[i].getToken().equals(":") && !tokens[i].getToken().equals(";")
          && !tokens[i].getToken().equals("\n") && !tokens[i].getToken().equals("\r\n")
          && !tokens[i].getToken().equals("\n\r")
        ) {
          String token = tokens[i].getToken();
          if (indexOfQuote == -1 && OPENING_QUOTES.indexOf(token) > -1) {
            indexOfQuote = OPENING_QUOTES.indexOf(token);
          } else if (indexOfQuote > -1 && CLOSING_QUOTES.indexOf(token) == indexOfQuote) {
            indexOfQuote = -1;
          }
          if (isWordCount(token) && indexOfQuote == -1) {
            //Get first word token
            if (fromPosToken == null) {
              fromPosToken = tokens[i];
            }
            if (numWords == maxWords) {
              //Get last word token
              if (toPosToken == null) {
                for (int j = tokens.length - 1; j >= 0; j--) {
                  if (isWordCount(tokens[j].getToken())) {
                    if (tokens.length > j + 1 && SENT_END.matcher(tokens[j+1].getToken()).matches()) {
                      toPosToken = tokens[j + 1];
                    } else {
                      toPosToken = tokens[j];
                    }
                    break;
                  }
                }
              }
              if (fromPosToken != null && toPosToken != null) {
                fromPos.add(fromPosToken.getStartPos());
                toPos.add(toPosToken.getEndPos());
              } else {
                //keep old logic if we could not find word tokens
                fromPos.add(tokens[0].getStartPos());
                toPos.add(tokens[tokens.length - 1].getEndPos());
              }
              break;
            }
            numWords++;
          }
          i++;
        }
        i++;
      }
      for (int j = 0; j < fromPos.size(); j++) {
        RuleMatch ruleMatch = new RuleMatch(this, sentence, pos+fromPos.get(j), pos+toPos.get(j), msg);
        ruleMatches.add(ruleMatch);
      }
      pos += sentence.getCorrectedTextLength();
    }
    return toRuleMatchArray(ruleMatches);
  
<methods>public void <init>() ,public void <init>(java.util.ResourceBundle) ,public int estimateContextForSureMatch() ,public org.languagetool.rules.RuleMatch[] match(List<org.languagetool.AnalyzedSentence>, org.languagetool.markup.AnnotatedText) throws java.io.IOException,public abstract org.languagetool.rules.RuleMatch[] match(List<org.languagetool.AnalyzedSentence>) throws java.io.IOException,public final org.languagetool.rules.RuleMatch[] match(org.languagetool.AnalyzedSentence) throws java.io.IOException,public abstract int minToCheckParagraph() <variables>