/** * Method that will create a new nested cursor for iterating * over all (immediate) child nodes of the start element this cursor * currently points to. * If cursor does not point to a start element, * it will throw {@link IllegalStateException}; if it does not support * concept of child cursors, it will throw * {@link UnsupportedOperationException} * * @throws IllegalStateException If cursor can not be created due * to the state cursor is in. * @throws UnsupportedOperationException If cursor does not allow * creation of child cursors. */ public final SMInputCursor childCursor() throws XMLStreamException { return childCursor(null); }
/** * Method that will create a new nested cursor for iterating * over all (immediate) child nodes of the start element this cursor * currently points to. * If cursor does not point to a start element, * it will throw {@link IllegalStateException}; if it does not support * concept of child cursors, it will throw * {@link UnsupportedOperationException} * * @throws IllegalStateException If cursor can not be created due * to the state cursor is in. * @throws UnsupportedOperationException If cursor does not allow * creation of child cursors. */ public final SMInputCursor childCursor() throws XMLStreamException { return childCursor(null); }
/** * Convenience method; equivalent to *<code>childCursor(SMFilterFactory.getMixedFilter());</code> */ public final SMInputCursor childMixedCursor() throws XMLStreamException { return childCursor(SMFilterFactory.getMixedFilter()); }
/** * Convenience method; equivalent to *<code>childCursor(SMFilterFactory.getElementOnlyFilter());</code> */ public final SMInputCursor childElementCursor() throws XMLStreamException { return childCursor(SMFilterFactory.getElementOnlyFilter()); }
/** * Convenience method; equivalent to *<code>childCursor(SMFilterFactory.getElementOnlyFilter(elemName));</code> * Will only return START_ELEMENT and END_ELEMENT events, whose element * name matches given qname. */ public final SMInputCursor childElementCursor(QName elemName) throws XMLStreamException { return childCursor(SMFilterFactory.getElementOnlyFilter(elemName)); }
/** * Convenience method; equivalent to *<code>childCursor(SMFilterFactory.getMixedFilter());</code> */ public final SMInputCursor childMixedCursor() throws XMLStreamException { return childCursor(SMFilterFactory.getMixedFilter()); }
/** * Convenience method; equivalent to *<code>childCursor(SMFilterFactory.getElementOnlyFilter(elemName));</code> * Will only return START_ELEMENT and END_ELEMENT events, whose element's * local name matches given local name, and that does not belong to * a namespace. */ public final SMInputCursor childElementCursor(String elemLocalName) throws XMLStreamException { return childCursor(SMFilterFactory.getElementOnlyFilter(elemLocalName)); }
/** * Convenience method; equivalent to *<code>childCursor(SMFilterFactory.getElementOnlyFilter(elemName));</code> * Will only return START_ELEMENT and END_ELEMENT events, whose element * name matches given qname. */ public final SMInputCursor childElementCursor(QName elemName) throws XMLStreamException { return childCursor(SMFilterFactory.getElementOnlyFilter(elemName)); }
/** * Convenience method; equivalent to *<code>childCursor(SMFilterFactory.getElementOnlyFilter(elemName));</code> * Will only return START_ELEMENT and END_ELEMENT events, whose element's * local name matches given local name, and that does not belong to * a namespace. */ public final SMInputCursor childElementCursor(String elemLocalName) throws XMLStreamException { return childCursor(SMFilterFactory.getElementOnlyFilter(elemLocalName)); }
/** * Convenience method; equivalent to *<code>childCursor(SMFilterFactory.getElementOnlyFilter());</code> */ public final SMInputCursor childElementCursor() throws XMLStreamException { return childCursor(SMFilterFactory.getElementOnlyFilter()); }
private static ScanInfo processScanInfo(SMInputCursor siC) throws XMLStreamException { SMInputCursor childCursor = siC.childCursor(); ScanInfo scanInfo = new ScanInfo(); while (childCursor.getNext() != null) { String nodeName = childCursor.getLocalName(); if (StringUtils.equalsIgnoreCase("engineVersion", nodeName)) { scanInfo.setEngineVersion(StringUtils.trim(childCursor.collectDescendantText(false))); } } return scanInfo; }
private static TestCase processTestCase(SMInputCursor cursor) throws XMLStreamException { String className = cursor.getAttrValue("class"); String name = cursor.getAttrValue("name"); SMInputCursor childCursor = cursor.childCursor(); Map<String,String> childValues = new HashMap<>(); while (childCursor.getNext() != null) { if(childCursor.getLocalName() != null) { childValues.put(childCursor.getLocalName(), childCursor.collectDescendantText(false)); } } return new TestCase( className, name, childValues.get("error"), childValues.get("failure"), childValues.get("skipped")); }
private static Evidence processEvidence(SMInputCursor ecC) throws XMLStreamException { Evidence evidence = new Evidence(); SMInputCursor childCursor = ecC.childCursor(); while (childCursor.getNext() != null) { String nodeName = childCursor.getLocalName(); if ("source".equals(nodeName)) { evidence.setSource(StringUtils.trim(childCursor.collectDescendantText(false))); } else if ("name".equals(nodeName)) { evidence.setName(StringUtils.trim(childCursor.collectDescendantText(false))); } else if ("value".equals(nodeName)) { evidence.setValue(StringUtils.trim(childCursor.collectDescendantText(false))); } } return evidence; }
private static TestCase processTestCase(SMInputCursor cursor) throws XMLStreamException { String className = cursor.getAttrValue("class"); String name = cursor.getAttrValue("name"); SMInputCursor childCursor = cursor.childCursor(); Map<String,String> childValues = new HashMap<>(); while (childCursor.getNext() != null) { if(childCursor.getLocalName() != null) { childValues.put(childCursor.getLocalName(), childCursor.collectDescendantText(false)); } } return new TestCase( className, name, childValues.get("error"), childValues.get("failure"), childValues.get("skipped")); }
private static ProjectInfo processProjectInfo(SMInputCursor piC) throws XMLStreamException { SMInputCursor childCursor = piC.childCursor(); ProjectInfo projectInfo = new ProjectInfo(); while (childCursor.getNext() != null) { String nodeName = childCursor.getLocalName(); if (StringUtils.equalsIgnoreCase("name", nodeName)) { projectInfo.setName(StringUtils.trim(childCursor.collectDescendantText(false))); } else if (StringUtils.equalsIgnoreCase("reportDate", nodeName)) { projectInfo.setReportDate(StringUtils.trim(childCursor.collectDescendantText(false))); } else if (StringUtils.equalsIgnoreCase("credits", nodeName)) { projectInfo.setCredits(StringUtils.trim(childCursor.collectDescendantText(false))); } } return projectInfo; }
public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException { SMInputCursor testSuite = rootCursor.constructDescendantCursor(new ElementFilter("testsuite")); SMEvent testSuiteEvent; for (testSuiteEvent = testSuite.getNext(); testSuiteEvent != null; testSuiteEvent = testSuite.getNext()) { if (testSuiteEvent.compareTo(SMEvent.START_ELEMENT) == 0) { String testSuiteClassName = testSuite.getAttrValue("name"); if (StringUtils.contains(testSuiteClassName, "$")) { // test suites for inner classes are ignored return; } parseTestCase(testSuiteClassName, testSuite.childCursor(new ElementFilter("testcase"))); } } }
public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException { SMInputCursor testSuite = rootCursor.constructDescendantCursor(new ElementFilter("testsuite")); SMEvent testSuiteEvent; for (testSuiteEvent = testSuite.getNext(); testSuiteEvent != null; testSuiteEvent = testSuite.getNext()) { if (testSuiteEvent.compareTo(SMEvent.START_ELEMENT) == 0) { String testSuiteClassName = testSuite.getAttrValue("name"); if (StringUtils.contains(testSuiteClassName, "$")) { // test suites for inner classes are ignored return; } parseTestCase(testSuiteClassName, testSuite.childCursor(new ElementFilter("testcase"))); } } }
@Override public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException { SMInputCursor testSuite = rootCursor.constructDescendantCursor(new ElementFilter("testsuite")); SMEvent testSuiteEvent; for (testSuiteEvent = testSuite.getNext(); testSuiteEvent != null; testSuiteEvent = testSuite.getNext()) { if (testSuiteEvent.compareTo(SMEvent.START_ELEMENT) == 0) { String testSuiteClassName = testSuite.getAttrValue("name"); if (StringUtils.contains(testSuiteClassName, "$")) { // test suites for inner classes are ignored return; } handleTestCases(testSuiteClassName, testSuite.childCursor(new ElementFilter("testcase"))); } } }
private Site processSite(SMInputCursor siteCursor) throws XMLStreamException { Site site = new Site(); site.setHost(siteCursor.getAttrValue("host")); site.setName(siteCursor.getAttrValue("name")); site.setPort(Integer.valueOf(siteCursor.getAttrValue("port"))); site.setSsl(Boolean.valueOf(siteCursor.getAttrValue("ssl"))); SMInputCursor childCursor = siteCursor.childCursor(); // Child of <site>, here only <alerts> while (childCursor.getNext() != null) { String nodeName = childCursor.getLocalName(); if ("alerts".equals(nodeName)) { site.setAlerts(processAlerts(childCursor)); } } return site; }
private void collectFileMeasures(SMInputCursor fileCursor) throws ParseException, XMLStreamException { fileCursor.setFilter(SMFilterFactory.getElementOnlyFilter("file")); while (fileCursor.getNext() != null) { if (fileCursor.asEvent().isStartElement()) { String absoluteFilePath = fileCursor.getAttrValue("path"); if (absoluteFilePath != null) { SMInputCursor fileChildrenCursor = fileCursor.childCursor(new SimpleFilter(SMEvent.START_ELEMENT)); // cursor should be on the metrics element if (canBeIncludedInFileMetrics(fileChildrenCursor)) { // cursor should be now on the line cursor saveHitsData(getResource(absoluteFilePath), fileChildrenCursor); } } } } }