class PatternRuleLoader extends DefaultHandler {

  private boolean relaxedMode = false;

  /**
   * @param file XML file with pattern rules
   */
  public final List<AbstractPatternRule> getRules(File file, Language lang) throws IOException {<FILL_FUNCTION_BODY>}

  /**
   * If set to true, don't throw an exception if id or name is not set.
   * Used for online rule editor.
   * @since 2.1
   */
  public void setRelaxedMode(boolean relaxedMode) {
    this.relaxedMode = relaxedMode;
  }

  /**
   * @param is stream with the XML rules
   * @param filename used only for verbose exception message - should refer to where the stream comes from
   */
  public final List<AbstractPatternRule> getRules(InputStream is, String filename, Language lang) throws IOException {
    try {
      PatternRuleHandler handler = new PatternRuleHandler(filename, lang);
      handler.setRelaxedMode(relaxedMode);
      SAXParserFactory factory = SAXParserFactory.newInstance();
      SAXParser saxParser = factory.newSAXParser();
      if (JLanguageTool.isCustomPasswordAuthenticatorUsed()) {
        Tools.setPasswordAuthenticator();
      }
      saxParser.getXMLReader().setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
      saxParser.parse(is, handler);
      return handler.getRules();
    } catch (Exception e) {
      throw new IOException("Cannot load or parse input stream of '" + filename + "'", e);
    }
  }

}

    try (InputStream inputStream = Files.newInputStream(file.toPath())) {
      PatternRuleLoader ruleLoader = new PatternRuleLoader();
      return ruleLoader.getRules(inputStream, file.getAbsolutePath(), lang);
    }
  
<methods>public void <init>() ,public void characters(char[], int, int) throws org.xml.sax.SAXException,public void endDocument() throws org.xml.sax.SAXException,public void endElement(java.lang.String, java.lang.String, java.lang.String) throws org.xml.sax.SAXException,public void endPrefixMapping(java.lang.String) throws org.xml.sax.SAXException,public void error(org.xml.sax.SAXParseException) throws org.xml.sax.SAXException,public void fatalError(org.xml.sax.SAXParseException) throws org.xml.sax.SAXException,public void ignorableWhitespace(char[], int, int) throws org.xml.sax.SAXException,public void notationDecl(java.lang.String, java.lang.String, java.lang.String) throws org.xml.sax.SAXException,public void processingInstruction(java.lang.String, java.lang.String) throws org.xml.sax.SAXException,public org.xml.sax.InputSource resolveEntity(java.lang.String, java.lang.String) throws java.io.IOException, org.xml.sax.SAXException,public void setDocumentLocator(org.xml.sax.Locator) ,public void skippedEntity(java.lang.String) throws org.xml.sax.SAXException,public void startDocument() throws org.xml.sax.SAXException,public void startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) throws org.xml.sax.SAXException,public void startPrefixMapping(java.lang.String, java.lang.String) throws org.xml.sax.SAXException,public void unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String) throws org.xml.sax.SAXException,public void warning(org.xml.sax.SAXParseException) throws org.xml.sax.SAXException<variables>