Package fit

Examples of fit.Parse


    return toSimpleText(table, new StringBuffer());
  }

  int columnNumberContainingText(String columnName, int headerRowIndex) throws InvalidInputException {
    int columnNumber = -1;
    Parse columns = table.at(0, headerRowIndex, 0);
    while (columns != null) {
      columnNumber++;
      if (columnName.equals(columns.text())) {
        return columnNumber;
      }
      columns = columns.more;
    }
    throw new InvalidInputException(errorMsg(columnName));
View Full Code Here


    return table.at(0, rowIndex, columnIndex).text();
  }

  public void copyAndAppendLastRow(int numberOfTimes) {
    if (numberOfTimes > 0 && tableHasMoreThanTwoRows()) {
      Parse lastRow = lastRow();
      Parse secondLastRow = secondLastRow(lastRow);
      copyAndAppend(lastRow, numberOfTimes);
      secondLastRow.more = lastRow;
    }
  }
View Full Code Here

  void incrementColumnValues(String columnName, Delta delta, int headerRowIndex) throws InvalidInputException {
    int columnNumber = columnNumberContainingText(columnName, headerRowIndex);
    int totalNumberOfRows = numberOfRows();
    for (int i = headerRowIndex + 2; i < totalNumberOfRows; ++i) {
      Parse columnToBeUpdated = table.at(0, i, columnNumber);
      String value = columnToBeUpdated.text();
      value = delta.addTo(value, i - headerRowIndex - 1);
      columnToBeUpdated.body = value;
    }
  }
View Full Code Here

  int numberOfRows() {
    return table.parts.size();
  }

  int rowNumberContainingText(String searchText) throws InvalidInputException {
    Parse rows = table.at(0, 0);
    int numberOfRows = rows.size();
    for (int i = 0; i < numberOfRows; i++) {
      Parse columns = table.at(0, i, 0);
      int numberOfColumns = columns.size();
      for (int j = 0; j < numberOfColumns; ++j) {
        if (searchText.equals(table.at(0, i, j).text())) {
          return i;
        }
      }
View Full Code Here

    }
    throw new InvalidInputException(errorMsg(searchText));
  }

  Parse secondLastRow(Parse lastRow) {
    Parse nextRow = table.parts;
    Parse currentRow = null;
    while (nextRow != lastRow) {
      currentRow = nextRow;
      nextRow = nextRow.more;
    }
    currentRow.more = null;
View Full Code Here

    return currentRow;
  }

  private void copyAndAppend(Parse lastRow, int numberOfTimes) {
    for (int i = 0; i < numberOfTimes; i++) {
      Parse columns = lastRow.parts;
      Parse nextColumn = columns.more;
      Parse newNextColumn = newParse(nextColumn, nextColumn.more);
      Parse newColumn = newParse(columns, newNextColumn);
      Parse newRow = new Parse(stripAngularBrackets(lastRow.tag), lastRow.body, newColumn, null);
      lastRow.last().more = newRow;
    }
  }
View Full Code Here

      lastRow.last().more = newRow;
    }
  }

  private Parse newParse(Parse columns, Parse nextColumn) {
    return new Parse(stripAngularBrackets(columns.tag), columns.body, columns.parts, nextColumn);
  }
View Full Code Here

      public void enterRow() throws Exception {
        throw new Exception(ERROR_MESSAGE);
      }
    };
    simpleTable = new Parse("<table><tr><td>a</td></tr><tr><td>b</td></tr></table>");
  }
View Full Code Here

    assertEquals("b", simpleTable.parts.more.parts.body);
  }

  @Test
  public void testInsertRowAfter() {
    Parse errorCell = new Parse("td", "error", null, null);
    Parse row = new Parse("tr", null, errorCell, null);
    fixture.insertRowAfter(simpleTable.parts.more, row);

    assertEquals("<tr>", simpleTable.parts.more.more.tag);
    assertEquals("error", simpleTable.parts.more.more.parts.body);
  }
View Full Code Here

    assertEquals("error", simpleTable.parts.more.more.parts.body);
  }

  @Test
  public void testInsertRowBetween() {
    Parse errorCell = new Parse("td", "error", null, null);
    Parse row = new Parse("tr", null, errorCell, null);
    fixture.insertRowAfter(simpleTable.parts, row);

    assertEquals("<tr>", simpleTable.parts.more.tag);
    assertEquals("error", simpleTable.parts.more.parts.body);
View Full Code Here

TOP

Related Classes of fit.Parse

Copyright © 2018 www.massapicom. 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.