org.sonar.api.rules.XMLRuleParser.processRule()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(104)

本文整理了Java中org.sonar.api.rules.XMLRuleParser.processRule()方法的一些代码示例,展示了XMLRuleParser.processRule()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLRuleParser.processRule()方法的具体详情如下:
包路径:org.sonar.api.rules.XMLRuleParser
类名称:XMLRuleParser
方法名:processRule

XMLRuleParser.processRule介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

public List<Rule> parse(Reader reader) {
 XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
 xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
 xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE);
 // just so it won't try to load DTD in if there's DOCTYPE
 xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
 xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
 SMInputFactory inputFactory = new SMInputFactory(xmlFactory);
 try {
  SMHierarchicCursor rootC = inputFactory.rootElementCursor(reader);
  rootC.advance(); // <rules>
  List<Rule> rules = new ArrayList<>();
  SMInputCursor rulesC = rootC.childElementCursor("rule");
  while (rulesC.getNext() != null) {
   // <rule>
   Rule rule = Rule.create();
   rules.add(rule);
   processRule(rule, rulesC);
  }
  return rules;
 } catch (XMLStreamException e) {
  throw new SonarException("XML is not valid", e);
 }
}

代码示例来源:origin: org.codehaus.sonar/sonar-deprecated

public List<Rule> parse(Reader reader) {
 XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
 xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
 xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE);
 // just so it won't try to load DTD in if there's DOCTYPE
 xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
 xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
 SMInputFactory inputFactory = new SMInputFactory(xmlFactory);
 try {
  SMHierarchicCursor rootC = inputFactory.rootElementCursor(reader);
  rootC.advance(); // <rules>
  List<Rule> rules = new ArrayList<Rule>();
  SMInputCursor rulesC = rootC.childElementCursor("rule");
  while (rulesC.getNext() != null) {
   // <rule>
   Rule rule = Rule.create();
   rules.add(rule);
   processRule(rule, rulesC);
  }
  return rules;
 } catch (XMLStreamException e) {
  throw new SonarException("XML is not valid", e);
 }
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-plugin-api

public List<Rule> parse(Reader reader) {
 XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
 xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
 xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE);
 // just so it won't try to load DTD in if there's DOCTYPE
 xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
 xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
 SMInputFactory inputFactory = new SMInputFactory(xmlFactory);
 try {
  SMHierarchicCursor rootC = inputFactory.rootElementCursor(reader);
  rootC.advance(); // <rules>
  List<Rule> rules = new ArrayList<>();
  SMInputCursor rulesC = rootC.childElementCursor("rule");
  while (rulesC.getNext() != null) {
   // <rule>
   Rule rule = Rule.create();
   rules.add(rule);
   processRule(rule, rulesC);
  }
  return rules;
 } catch (XMLStreamException e) {
  throw new SonarException("XML is not valid", e);
 }
}

相关文章