List of usage examples for javax.xml.stream XMLStreamException XMLStreamException
public XMLStreamException(Throwable th)
From source file:org.sonar.plugins.cobertura.api.AbstractCoberturaParser.java
public void parseReport(File xmlFile, final SensorContext context) { try {/*from w ww .j a va2s .c o m*/ StaxParser parser = new StaxParser(new StaxParser.XmlStreamHandler() { public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException { try { rootCursor.advance(); collectPackageMeasures(rootCursor.descendantElementCursor("package"), context); } catch (ParseException e) { throw new XMLStreamException(e); } } }); parser.parse(xmlFile); } catch (XMLStreamException e) { throw new XmlParserException(e); } }
From source file:org.sonar.plugins.cxx.coverage.CxxGcovrSensor.java
private void parseReport(final Project project, File xmlFile, final Map<String, FileData> dataPerFilename) { try {//from w w w .j av a 2 s . c om CxxUtils.LOG.info("Parsing report '{}'", xmlFile); StaxParser parser = new StaxParser(new StaxParser.XmlStreamHandler() { /** * {@inheritDoc} */ public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException { try { rootCursor.advance(); collectPackageMeasures(project, rootCursor.descendantElementCursor("package"), dataPerFilename); } catch (ParseException e) { throw new XMLStreamException(e); } } }); parser.parse(xmlFile); } catch (XMLStreamException e) { throw new XmlParserException(e); } }
From source file:org.sonar.plugins.cxx.cppcheck.CxxCppCheckSensor.java
/** * Parse the stream of CppCheck XML report * //from w ww . j a v a 2s . c o m * @param project * @param xmlStream * - This stream will be closed at the end of this method * @param context */ private void parseReport(final Project project, InputStream xmlStream, final SensorContext context) { try { logger.info("parsing CppCheck XML stream{}"); StaxParser parser = new StaxParser(new StaxParser.XmlStreamHandler() { public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException { try { rootCursor.advance(); collectError(project, rootCursor.childElementCursor("error"), context); } catch (ParseException e) { throw new XMLStreamException(e); } } }); parser.parse(xmlStream); } catch (XMLStreamException e) { throw new XmlParserException(e); } finally { try { if (xmlStream != null) { xmlStream.close(); } } catch (IOException ex) { logger.error("Can't close the xml stream", ex); } } }
From source file:org.sonar.plugins.cxx.cppncss.CxxCppNcssSensor.java
private void parseReport(final Project project, File xmlFile, final SensorContext context) { try {//from w w w . jav a 2 s .co m logger.info("parsing {}", xmlFile); StaxParser parser = new StaxParser(new StaxParser.XmlStreamHandler() { public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException { try { Map<String, FileData> fileDataPerFilename = new HashMap<String, FileData>(); rootCursor.advance(); collectMeasure(project, rootCursor.childElementCursor("measure"), fileDataPerFilename, context); for (FileData d : fileDataPerFilename.values()) { d.saveMetric(project, context); } } catch (ParseException e) { throw new XMLStreamException(e); } } }); parser.parse(xmlFile); } catch (XMLStreamException e) { throw new XmlParserException(e); } }
From source file:org.sonar.plugins.cxx.gcovr.CxxGcovrSensor.java
private void parseReport(final Project project, File xmlFile, final SensorContext context, final Map<String, FileData> dataPerFilename) { try {//from w w w . ja v a2s . c o m logger.info("parsing {}", xmlFile); StaxParser parser = new StaxParser(new StaxParser.XmlStreamHandler() { public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException { try { rootCursor.advance(); collectPackageMeasures(project, rootCursor.descendantElementCursor("package"), context, dataPerFilename); } catch (ParseException e) { throw new XMLStreamException(e); } } }); parser.parse(xmlFile); } catch (XMLStreamException e) { throw new XmlParserException(e); } }
From source file:org.sonar.plugins.cxx.tests.xunit.XunitReportParser.java
private double parseTime(SMInputCursor testCaseCursor) throws XMLStreamException { double time = 0.0; try {//w ww . j a v a 2 s . co m String sTime = testCaseCursor.getAttrValue("time"); if (!StringUtils.isEmpty(sTime)) { Double tmp = ParsingUtils.parseNumber(sTime, Locale.ENGLISH); if (!Double.isNaN(tmp)) { time = ParsingUtils.scaleValue(tmp * 1000, 3); } } } catch (ParseException e) { throw new XMLStreamException(e); } return time; }
From source file:org.sonar.plugins.cxx.valgrind.CxxValgrindSensor.java
private void parseReport(final Project project, File xmlFile, final SensorContext context) { try {/*w w w . j ava2 s .c o m*/ logger.info("parsing {}", xmlFile); StaxParser parser = new StaxParser(new StaxParser.XmlStreamHandler() { public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException { try { Map<String, FileData> fileDataPerFilename = new HashMap<String, FileData>(); rootCursor.advance(); collectError(project, rootCursor.childElementCursor("error"), fileDataPerFilename, context); for (FileData d : fileDataPerFilename.values()) { d.saveMetric(project, context); } } catch (ParseException e) { e.printStackTrace(); throw new XMLStreamException(e); } } }); parser.parse(xmlFile); } catch (XMLStreamException e) { e.printStackTrace(); throw new XmlParserException(e); } }
From source file:org.sonar.plugins.cxx.veraxx.CxxVeraxxSensor.java
private void parseReport(final Project project, File xmlFile, final SensorContext context) { try {/* ww w . j a va 2s.c om*/ logger.info("parsing {}", xmlFile); StaxParser parser = new StaxParser(new StaxParser.XmlStreamHandler() { public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException { try { rootCursor.advance(); collectFile(project, rootCursor.childElementCursor("file"), context); } catch (ParseException e) { throw new XMLStreamException(e); } } }); parser.parse(xmlFile); } catch (XMLStreamException e) { throw new XmlParserException(e); } }
From source file:org.sonar.plugins.gosu.surefire.data.SurefireStaxHandler.java
private static long getTimeAttributeInMS(SMInputCursor testCaseCursor) throws XMLStreamException { // hardcoded to Locale.ENGLISH see http://jira.codehaus.org/browse/SONAR-602 try {/*from www . j a v a2 s. c o m*/ Double time = ParsingUtils.parseNumber(testCaseCursor.getAttrValue("time"), Locale.ENGLISH); return !Double.isNaN(time) ? (long) ParsingUtils.scaleValue(time * 1000, 3) : 0L; } catch (ParseException e) { throw new XMLStreamException(e); } }
From source file:org.sonar.plugins.surefire.TestSuiteParser.java
private Double getTimeAttributeInMS(SMInputCursor testCaseCursor) throws XMLStreamException { // hardcoded to Locale.ENGLISH see http://jira.codehaus.org/browse/SONAR-602 try {//w w w. ja va 2s .c om Double time = ParsingUtils.parseNumber(testCaseCursor.getAttrValue("time"), Locale.ENGLISH); return !Double.isNaN(time) ? ParsingUtils.scaleValue(time * 1000, 3) : 0; } catch (ParseException e) { throw new XMLStreamException(e); } }