Examples of SMInputCursor


Examples of org.codehaus.staxmate.in.SMInputCursor

    }
  }

  private void collectFunctionMeasures(SMInputCursor functions, Map<String, CoverageMeasuresBuilder> coverageData)
    throws XMLStreamException {
    SMInputCursor function = functions.childElementCursor("function");
    while (function.getNext() != null) {
      int blocksCovered = Integer.parseInt(function.getAttrValue("blocks_covered"));
      int blocksNotCovered = Integer.parseInt(function.getAttrValue("blocks_not_covered"));
      collectRangeMeasures(function, coverageData, blocksCovered + blocksNotCovered, blocksCovered);
    }
  }
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

    }
  }

  private void collectRangeMeasures(SMInputCursor function, Map<String, CoverageMeasuresBuilder> coverageData, int conditions, int coveredConditions)
    throws XMLStreamException {
    SMInputCursor range = function.childElementCursor("ranges").advance().childElementCursor("range");
    CoverageMeasuresBuilder builder = null;
    String lastSourceId = "";

    while (range.getNext() != null) {
      String sourceId = range.getAttrValue("source_id");
      int startLine = Integer.parseInt(range.getAttrValue("start_line"));
      int endLine = Integer.parseInt(range.getAttrValue("end_line"));
      int covered = !range.getAttrValue("covered").equalsIgnoreCase("no") ? 1 : 0; // value: yes/no/partial

      if (!sourceId.equals(lastSourceId) || builder == null) {
        builder = coverageData.get(sourceId);
        if (builder == null) {
          builder = CoverageMeasuresBuilder.create();
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

      }
    }
  }

  private void collectFileData(SMInputCursor clazz, CoverageMeasuresBuilder builder) throws XMLStreamException {
    SMInputCursor line = clazz.childElementCursor("lines").advance().childElementCursor("line");
    while (line.getNext() != null) {
      int lineId = Integer.parseInt(line.getAttrValue("number"));
      long noHits = Long.parseLong(line.getAttrValue("hits"));
      if(noHits > Integer.MAX_VALUE){
        CxxUtils.LOG.warn("Truncating the actual number of hits ({}) to the maximum number supported by Sonar ({})",
                          noHits, Integer.MAX_VALUE);
        noHits = Integer.MAX_VALUE;
      }
      builder.setHits(lineId, (int)noHits);

      String isBranch = line.getAttrValue("branch");
      String text = line.getAttrValue("condition-coverage");
      if (StringUtils.equals(isBranch, "true") && StringUtils.isNotBlank(text)) {
        String[] conditions = StringUtils.split(StringUtils.substringBetween(text, "(", ")"), "/");
        builder.setConditions(lineId, Integer.parseInt(conditions[1]), Integer.parseInt(conditions[0]));
      }
    }
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

        throws IOException, XMLStreamException
    {
        /* Let's assume child elements have to be 'li' elements or
         * sublists ('ul', 'ol'); and ignore everything else.
         */
        SMInputCursor listIt = it.childElementCursor();

        // We'll only get START_ELEMENTs here except for EOF:
        while (listIt.getNext() != null) {
            String tag = listIt.getLocalName().toLowerCase();
            if (tag.equals("li")) {
                processListItem(listIt, out, type, depth);
            } else if (tag.equals("ul")) {
                processList(listIt, out, '*', depth+1);
            } else if (tag.equals("ol")) {
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

        out.write(' ');

        /* List item contents are more varied; text, inline markup; maybe
         * even sublists.
         */
        SMInputCursor itemIt = it.childMixedCursor();
        SMEvent evt;

        while ((evt = itemIt.getNext()) != null) {
            if (evt == SMEvent.START_ELEMENT) {
                String tag = itemIt.getLocalName().toLowerCase();
                // only care about sub-lists:
                if (tag.equals("ul") || tag.equals("ol")) {
                    out.write('\n'); // to finish off the current line
                    processList(itemIt, out, (tag.charAt(0) == 'u') ? '*' : '#',
                                depth+1);
                    /* Also, let's also ignore whatever came after the sublist,
                     * for this item, if anything; most likely just whitespace.
                     * Problem otherwise is how to handle "leftovers"; can't
                     * add them to this item any more, would need to start
                     * a new item or something.
                     */
                    return;
                } else { // can also process inline markup
                    String str = checkInlineMarkup(itemIt, tag);
                    if (str != null) {
                        addSingleLine(out, str);
                        continue;
                    }
                }
                // Otherwise, let's just collect and output text:
                addSingleLine(out, itemIt.collectDescendantText(true));
            } else {
                addSingleLine(out, itemIt.getText());
            }
        }
        out.write('\n');
    }
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

        throws IOException, XMLStreamException
    {
        /* Let's assume child elements have to be 'tr', or one of grouping
         * elements ('thead', 'tfoot' or 'tbody'), and ignore everything else.
         */
        SMInputCursor tableIt = it.childElementCursor();
        // We'll only get START_ELEMENTs here except for EOF:
        while (tableIt.getNext() != null) {
            String tag = tableIt.getLocalName().toLowerCase();
            if (tag.equals("thead") || tag.equals("tfoot")
                || tag.equals("tbody")) {
                /* Let's just recursively call this method, should be
                 * safe?
                 */
 
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

    private void processTableRow(SMInputCursor it, Writer out, boolean headerRow)
        throws IOException, XMLStreamException
    {
        // Let's assume only 'tr' elements are encountered...
        SMInputCursor rowIt = it.childElementCursor();
        out.write("|");
        // We'll only get START_ELEMENTs here except for EOF:
        while (rowIt.getNext() != null) {
            String tag = rowIt.getLocalName().toLowerCase();
            if (tag.equals("td")) {
                processTableCell(rowIt, out, headerRow);
            } else if (tag.equals("th")) {
                processTableCell(rowIt, out, true);
            } else {
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

        throws IOException, XMLStreamException
    {
        /* Cells can have varied content, though... generally we only care
         * about text and inline markup, though.
         */
        SMInputCursor cellIt = it.childMixedCursor();
        SMEvent evt;
        while ((evt = cellIt.getNext()) != null) {
            if (evt == SMEvent.START_ELEMENT) {
                String tag = cellIt.getLocalName().toLowerCase();
                // No sub-tables or lists allowed... just inline markup
                String str = checkInlineMarkup(cellIt, tag);
                if (str != null) {
                    addSingleLine(out, str);
                    continue;
                }
                // Otherwise, let's just collect and output text:
                addSingleLine(out, cellIt.collectDescendantText(true));
            } else { // just plain text
                addSingleLine(out, cellIt.getText());
            }
        }
    }
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

        f.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
        f.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
        InputStream in = new java.io.FileInputStream(filename);
        XMLStreamReader sr = f.createXMLStreamReader(in);

        SMInputCursor it = SMInputFactory.rootElementCursor(sr);
        /* Need to store some information about preceding siblings,
         * so let's enable tracking.
         */
        it.setElementTracking(SMInputCursor.Tracking.VISIBLE_SIBLINGS);

        Writer out = new PrintWriter(System.out);

        try {
            processHTML(it, out);
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

        } else if (!name.equals("html")) {
            throw new XMLStreamException("Non-HTML document? Root element '"
                                         +origName+"'; excepted <HTML> or <html>");
        }

        SMInputCursor mainIt = it.childElementCursor();

        while (mainIt.getNext() != null) {
            origName = mainIt.getLocalName();
            name = origName.toLowerCase();

            // Should be 'head' or 'body'
            if (name.equals("head")) {
                processHead(mainIt, out);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.