org.sonar.api.utils.XmlParserException类的使用及代码示例

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

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

XmlParserException介绍

暂无

代码示例

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

public Object executeXPath(Node node, QName qname, String xPathExpression) {
 XPathExpression expr = compiledExprs.get(xPathExpression);
 try {
  if (expr == null) {
   expr = xpath.compile(xPathExpression);
   compiledExprs.put(xPathExpression, expr);
  }
  return expr.evaluate(node, qname);
 } catch (XPathExpressionException e) {
  throw new XmlParserException("Unable to evaluate xpath expression :" + xPathExpression, e);
 }
}

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

public void parse(String xml) {
 try {
  String fixedXml = fixUnicodeChar(xml);
  doc = builder.parse(new ByteArrayInputStream(fixedXml.getBytes(Charsets.UTF_8)));
  XPathFactory factory = XPathFactory.newInstance();
  xpath = factory.newXPath();
 } catch (IOException | SAXException e) {
  throw new XmlParserException(CAN_NOT_PARSE_XML + xml, e);
 }
}

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

public void parse(@Nullable File file) {
 if (file == null || !file.exists()) {
  throw new XmlParserException("File not found : " + file);
 }
 BufferedReader buffer = null;
 try {
  buffer = new BufferedReader(new InputStreamReader(new FileInputStream(file), Charsets.UTF_8));
  parse(buffer);
 } catch (IOException e) {
  throw new XmlParserException("can not parse the file " + file.getAbsolutePath(), e);
 } finally {
  IOUtils.closeQuietly(buffer);
 }
}

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

public void parse(InputStream stream) {
 BufferedReader buffer = null;
 try {
  buffer = new BufferedReader(new InputStreamReader(stream, Charsets.UTF_8));
  parse(buffer);
 } catch (IOException e) {
  throw new XmlParserException("can not parse the stream", e);
 } finally {
  IOUtils.closeQuietly(buffer);
 }
}

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

public XpathParser() {
 DocumentBuilderFactory bf = DocumentBuilderFactory.newInstance();
 try {
  bf.setFeature("http://apache.org/xml/features/validation/schema", false);
  bf.setFeature("http://xml.org/sax/features/external-general-entities", false);
  bf.setFeature("http://xml.org/sax/features/validation", false);
  bf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
  bf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
  bf.setFeature("http://apache.org/xml/features/allow-java-encodings", true);
 } catch (ParserConfigurationException e) {
  Logger log = Loggers.get(this.getClass().getName());
  log.error("Error occured during features set up.", e);
 }
 try {
  bf.setNamespaceAware(false);
  bf.setValidating(false);
  builder = bf.newDocumentBuilder();
 } catch (ParserConfigurationException e) {
  throw new XmlParserException("can not create a XML parser", e);
 }
}

代码示例来源:origin: mrprince/sonar-p3c-pmd

@Override
public void analyse(Project project, SensorContext context) {
 try {
  Report report = executor.execute();
  for (RuleViolation violation : report) {
   pmdViolationRecorder.saveViolation(violation);
  }
 } catch (Exception e) {
  throw new XmlParserException(e);
 }
}

代码示例来源:origin: org.codehaus.sonar-plugins/sonar-clover-plugin

protected void collect(File xmlFile) {
 try {
  if (reportExists(xmlFile)) {
   files = 0;
   unmatchedFile = 0;
   unmatchedFiles = "";
   LOG.info("Parsing " + xmlFile.getCanonicalPath());
   createStaxParser().parse(xmlFile);
   LOG.info("Matched files in report : {}", getMatchedPercentage());
   if (!unmatchedFiles.isEmpty()) {
    LOG.warn("{} files in clover report did not match any file in SonarQube Index : {}", unmatchedFile, unmatchedFiles);
   }
  }
 } catch (IllegalStateException e) {
  LOG.error("Format of clover report file is unexpected ", e);
  throw new XmlParserException(e);
 } catch (Exception e) {
  LOG.error("An error occured while parsing clover xml report : ", e);
  throw new XmlParserException(e);
 }
}

代码示例来源:origin: org.codehaus.sonar.plugins/sonar-pmd-plugin

public void analyse(Project project, SensorContext context) {
 try {
  Report report = executor.execute();
  reportViolations(report.iterator(), context);
 } catch (Exception e) {
  throw new XmlParserException(e);
 }
}

代码示例来源:origin: org.codehaus.sonar-plugins/sonar-php-plugin

/**
 * @return
 */
public List<PhpCodeSnifferViolation> getViolations(File reportFile) {
 LOG.debug("Report file for PHP_CodeSniffer is " + reportFile);
 if (reportFile == null || !reportFile.exists()) {
  throw new SonarException("The XML report '" + reportFile + "' can't be found");
 }
 String reportPath = reportFile.getAbsolutePath();
 LOG.debug("Getting violations form report file");
 List<PhpCodeSnifferViolation> violations = new ArrayList<PhpCodeSnifferViolation>();
 try {// <checkstyle>
  SMInputFactory inputFactory = new SMInputFactory(XMLInputFactory.newInstance());// <checkstyle>
  SMInputCursor rootNodeCursor = inputFactory.rootElementCursor(reportFile).advance(); // <file>
  SMInputCursor fileNodeCursor = rootNodeCursor.childElementCursor(FILE_NODE_NAME).advance();
  while (fileNodeCursor.asEvent() != null) {
   String fileName = fileNodeCursor.getAttrValue(FILE_NAME_ATTRIBUTE_NAME);
   SMInputCursor violationNodeCursor = fileNodeCursor.childElementCursor().advance(); // <error>
   while (violationNodeCursor.asEvent() != null) {
    violations.add(getViolation(fileName, violationNodeCursor));
    violationNodeCursor.advance();
   }
   fileNodeCursor.advance();
  }
  rootNodeCursor.getStreamReader().closeCompletely();
 } catch (XMLStreamException e) {
  throw new XmlParserException("Unable to parse the  XML Report '" + reportPath + "'", e);
 }
 return violations;
}

代码示例来源:origin: org.codehaus.sonar-plugins/sonar-php-plugin

throw new XmlParserException("Unable to parse the  XML Report", e);

代码示例来源:origin: octo-technology/sonar-objective-c

throw new XmlParserException("Can not parse surefire reports", e);

相关文章

微信公众号

最新文章

更多

XmlParserException类方法