List of usage examples for javax.xml.stream XMLStreamException XMLStreamException
public XMLStreamException()
From source file:org.apache.axiom.om.impl.llom.OMStAXWrapper.java
/** * @param i//ww w. j a v a 2s . c o m * @param s * @param s1 * @throws XMLStreamException * @see javax.xml.stream.XMLStreamReader#require(int, String, String) */ public void require(int i, String s, String s1) throws XMLStreamException { throw new XMLStreamException(); }
From source file:org.slc.sli.api.resources.config.StAXMsgBodyReader.java
/** * Helper method for digesting XML documents * @param reader XML reader// w w w. jav a 2 s.c o m * @return EntityBody representation that corresponds to the xml * @throws XMLStreamException on malformed XML */ private static final EntityBody readDocument(final XMLStreamReader reader) throws XMLStreamException { if (XMLStreamConstants.START_DOCUMENT == reader.getEventType()) { EntityBody body = null; while (reader.hasNext()) { reader.next(); switch (reader.getEventType()) { case XMLStreamConstants.START_ELEMENT: { body = readDocumentElement(reader); return body; } case XMLStreamConstants.END_DOCUMENT: { return body; } case XMLStreamConstants.CHARACTERS: { // Ignore break; } default: { throw new XMLStreamException(); } } } } else { throw new XMLStreamException(reader.getLocalName()); } throw new XMLStreamException(); }
From source file:org.slc.sli.api.resources.config.StAXMsgBodyReader.java
/** * Reads everything under the main document wrapper tag * @param reader Reader that we have for XML * @return EntityBody representation of the document * @throws XMLStreamException on malformed XML */// w w w .jav a 2 s. c o m private static final EntityBody readDocumentElement(final XMLStreamReader reader) throws XMLStreamException { final Map<String, Object> elements = new HashMap<String, Object>(); while (reader.hasNext()) { reader.next(); switch (reader.getEventType()) { case XMLStreamConstants.START_ELEMENT: { final Pair<Object, Boolean> memberDataPair = readElement(reader); addToElements(reader.getLocalName(), memberDataPair, elements); break; } case XMLStreamConstants.END_ELEMENT: { return new EntityBody(elements); } case XMLStreamConstants.CHARACTERS: { // Ignore break; } default: { throw new XMLStreamException(); } } } throw new XMLStreamException(); }
From source file:org.sonar.plugins.cxx.cppcheck.CppcheckParserV1.java
/** * {@inheritDoc}//from www . j a va2 s . c o m */ public void processReport(final Project project, final SensorContext context, File report) throws javax.xml.stream.XMLStreamException { CxxUtils.LOG.info("cppcheck V1 - Parsing report '{}'", report); StaxParser parser = new StaxParser(new StaxParser.XmlStreamHandler() { /** * {@inheritDoc} */ public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException { parsed = true; try { rootCursor.advance(); // results } catch (com.ctc.wstx.exc.WstxEOFException eofExc) { throw new EmptyReportException(); } int countIssues = 0; try { SMInputCursor errorCursor = rootCursor.childElementCursor("error"); // error while (errorCursor.getNext() != null) { String file = errorCursor.getAttrValue("file"); String line = errorCursor.getAttrValue("line"); String id = errorCursor.getAttrValue("id"); String msg = errorCursor.getAttrValue("msg"); if (isInputValid(file, line, id, msg)) { if (sensor.saveUniqueViolation(project, context, CxxCppCheckRuleRepository.KEY, file, line, id, msg)) { ++countIssues; } } else { CxxUtils.LOG.warn("Skipping invalid violation: '{}'", msg); } } CxxUtils.LOG.info("CppCheck issues processed = " + countIssues); } catch (RuntimeException e) { parsed = false; throw new XMLStreamException(); } } private boolean isInputValid(String file, String line, String id, String msg) { return !StringUtils.isEmpty(id) && !StringUtils.isEmpty(msg); } }); parser.parse(report); }
From source file:org.sonar.plugins.cxx.cppcheck.CppcheckParserV2.java
/** * {@inheritDoc}/* ww w . j av a2s . c o m*/ */ public void processReport(final Project project, final SensorContext context, File report) throws javax.xml.stream.XMLStreamException { CxxUtils.LOG.info("cppcheck V2 - Parsing report '{}'", report); StaxParser parser = new StaxParser(new StaxParser.XmlStreamHandler() { /** * {@inheritDoc} */ public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException { parsed = true; try { rootCursor.advance(); } catch (com.ctc.wstx.exc.WstxEOFException eofExc) { throw new EmptyReportException(); } try { String version = rootCursor.getAttrValue("version"); if (version.equals("2")) { SMInputCursor errorsCursor = rootCursor.childElementCursor("errors"); if (errorsCursor.getNext() != null) { int countIssues = 0; SMInputCursor errorCursor = errorsCursor.childElementCursor("error"); while (errorCursor.getNext() != null) { String id = errorCursor.getAttrValue("id"); String msg = errorCursor.getAttrValue("msg"); String file = null; String line = null; SMInputCursor locationCursor = errorCursor.childElementCursor("location"); if (locationCursor.getNext() != null) { file = locationCursor.getAttrValue("file"); line = locationCursor.getAttrValue("line"); } if (isInputValid(file, line, id, msg)) { if (sensor.saveUniqueViolation(project, context, CxxCppCheckRuleRepository.KEY, file, line, id, msg)) { countIssues++; } } else { CxxUtils.LOG.warn("Skipping invalid violation: '{}'", msg); } } CxxUtils.LOG.info("CppCheck issues processed = " + countIssues); } } } catch (RuntimeException e) { parsed = false; throw new XMLStreamException(); } } private boolean isInputValid(String file, String line, String id, String msg) { return !StringUtils.isEmpty(id) && !StringUtils.isEmpty(msg); } }); parser.parse(report); }