/** @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; }
public Object parseGeometry( Map<QName, FEPullParser.PullParserHandler> handlers, SMInputCursor crsr) throws XMLStreamException, IOException, SAXException { QName qn = crsr.getQName(); PullParserHandler handler = handlers.get(qn); Object obj = null; if (handler != null) { parserAny.setHandler(handler); parserAny.setPp(crsr.getStreamReader()); obj = parserAny.parse(); } return obj; }