gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-19 08:14:40 28 4
gpt4 key购买 nike

本文整理了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);

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com