Examples of SMInputCursor


Examples of org.codehaus.staxmate.in.SMInputCursor

     * title element (for now); returns as soon as that's gotten.
     */
    private void processHead(SMInputCursor parentIt, Writer out)
        throws IOException, XMLStreamException
    {
        SMInputCursor headIt = parentIt.childElementCursor();
        while (headIt.getNext() != null) {
            if (headIt.getLocalName().toLowerCase().equals("title")) {
                // Could capitalize it too...
                out.write("== ");
                String str = headIt.collectDescendantText(true);
                // Let's remove linefeeds if there was any
                addSingleLine(out, str);
                out.write(" ==\n\n");
                // Ok, that's it, we don't care about other stuff
                break;
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

        /* We need both elements and text content (but not comments etc);
         * further, due to loose nesting of HTML, let's just do flat
         * iteration in general, as we can still do sub-scoping for
         * specific elements (tables etc)
         */
        SMInputCursor bodyIt = parentIt.descendantMixedCursor();
        StringBuffer text = null; // for collected 'loose' text
        SMEvent evt;

        while ((evt = bodyIt.getNext()) != null) {
            // Let's weed out end elements right away...
            if (evt == SMEvent.END_ELEMENT) {
                continue;
            }
            // And straight text as well:
            String inline;
            if (evt == SMEvent.START_ELEMENT) {
                String tag = bodyIt.getLocalName().toLowerCase();
                if (processBlockElement(bodyIt, out, tag, text)) {
                    // true -> was succesfully handled
                    text = null;
                    continue;
                }
                /* Ok; not a block we recognized... but maybe a well-known
                 * inline element?
                 */
                inline = checkInlineMarkup(bodyIt, tag);
            } else {
                inline = bodyIt.getText();
            }

            if (inline != null) {
                if (text == null) {
                    text = new StringBuffer(inline);
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

  // b_iterator is moved and reads A1B1C2 should read A1B2
  public void testOneLevelDeepPartialChildIteration() throws Exception
  {
    assertGotNextElementNamed(a_iterator, "A1");

    SMInputCursor b_iterator = a_iterator.childElementCursor();

    assertGotNextElementNamed(b_iterator, "A1B1");

    SMInputCursor c_iterator = b_iterator.childElementCursor();
    assertGotNextElementNamed(c_iterator, "A1B1C1");

    assertGotNextElementNamed(b_iterator, "A1B2");
    assertNull(b_iterator.getNext());
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

  // Works with patch1
  public void testOneLevelDeepChildCursorAcquisition() throws Exception
  {
    assertGotNextElementNamed(a_iterator, "A1");

    SMInputCursor b_iterator = a_iterator.childElementCursor();

    assertGotNextElementNamed(b_iterator,"A1B1");

    // Edge case 1...
    // Get child cursor but leave in State.INITIAL...
    // Skip tree needs to start with initial depth value of 0...
    b_iterator.childElementCursor();
   
    assertGotNextElementNamed(b_iterator,"A1B2");
    assertNull(b_iterator.getNext());

    assertNull(a_iterator.getNext());
  }
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

  public void testTwoLevelDeepPartialCursorIteration() throws Exception
  {
   
    assertGotNextElementNamed(a_iterator,"A1");
   
    SMInputCursor b_iterator = a_iterator.childElementCursor();
    assertGotNextElementNamed(b_iterator,"A1B1");

    SMInputCursor c_iterator = b_iterator.childElementCursor();
    assertGotNextElementNamed(c_iterator,"A1B1C1");
   
    SMInputCursor d_iterator = c_iterator.childElementCursor();
    assertGotNextElementNamed(d_iterator,"A1B1C1D1");
   
    assertGotNextElementNamed(b_iterator,"A1B2");
    assertNull(b_iterator.getNext());
   
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

  // One more try just to be safe, two level up move, without moving the d_iterator
  public void testTwoLevelDeepChildCursorAcquisition() throws Exception
  {
    assertGotNextElementNamed(a_iterator,"A1");
   
    SMInputCursor b_iterator = a_iterator.childElementCursor();
    assertGotNextElementNamed(b_iterator,"A1B1");

    SMInputCursor c_iterator = b_iterator.childElementCursor();
    assertGotNextElementNamed(c_iterator,"A1B1C1");
   
    /*SMInputCursor d_iterator =*/ c_iterator.childElementCursor();
   
    assertGotNextElementNamed(b_iterator,"A1B2");
    assertNull(b_iterator.getNext());
   
    assertNull(a_iterator.getNext());
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

    this.index = index;
  }

  @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;
        }
        SMInputCursor testCase = testSuite.childCursor(new ElementFilter("testcase"));
        SMEvent event;
        for (event = testCase.getNext(); event != null; event = testCase.getNext()) {
          if (event.compareTo(SMEvent.START_ELEMENT) == 0) {
            String testClassName = getClassname(testCase, testSuiteClassName);
            UnitTestClassReport classReport = index.index(testClassName);
            parseTestCase(testCase, classReport);
          }
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

    detail.setName(name);

    String status = UnitTestResult.STATUS_OK;
    long duration = getTimeAttributeInMS(testCaseCursor);

    SMInputCursor childNode = testCaseCursor.descendantElementCursor();
    if (childNode.getNext() != null) {
      String elementName = childNode.getLocalName();
      if ("skipped".equals(elementName)) {
        status = UnitTestResult.STATUS_SKIPPED;
        // bug with surefire reporting wrong time for skipped tests
        duration = 0L;

      } else if ("failure".equals(elementName)) {
        status = UnitTestResult.STATUS_FAILURE;
        setStackAndMessage(detail, childNode);

      } else if ("error".equals(elementName)) {
        status = UnitTestResult.STATUS_ERROR;
        setStackAndMessage(detail, childNode);
      }
    }
    while (childNode.getNext() != null) {
      // make sure we loop till the end of the elements cursor
    }
    detail.setDurationMilliseconds(duration);
    detail.setStatus(status);
    return detail;
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

      SMInputFactory inputFactory = initStax();
      SMHierarchicCursor cursor = inputFactory.rootElementCursor(xml);

      // advance to <sqale>
      cursor.advance();
      SMInputCursor chcCursor = cursor.childElementCursor(CHARACTERISTIC);

      while (chcCursor.getNext() != null) {
        process(debtModel, null, chcCursor);
      }

      cursor.getStreamReader().closeCompletely();
View Full Code Here

Examples of org.codehaus.staxmate.in.SMInputCursor

  }

  @CheckForNull
  private void process(DebtModel debtModel, @Nullable String parent, SMInputCursor chcCursor) throws XMLStreamException {
    DefaultDebtCharacteristic characteristic = new DefaultDebtCharacteristic();
    SMInputCursor cursor = chcCursor.childElementCursor();
    while (cursor.getNext() != null) {
      String node = cursor.getLocalName();
      if (StringUtils.equals(node, CHARACTERISTIC_KEY)) {
        characteristic.setKey(convertKey(cursor.collectDescendantText().trim()));
        if (parent == null) {
          characteristic.setOrder(debtModel.rootCharacteristics().size() + 1);
          debtModel.addRootCharacteristic(characteristic);
        } else {
          debtModel.addSubCharacteristic(characteristic, parent);
        }

      } else if (StringUtils.equals(node, CHARACTERISTIC_NAME)) {
        characteristic.setName(cursor.collectDescendantText().trim());

        // <chc> can contain characteristics or requirements
      } else if (StringUtils.equals(node, CHARACTERISTIC)) {
        process(debtModel, characteristic.key(), cursor);
      }
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.