public void clean() { allCells = new ArrayList<>(); columns().clean(); rows().clean(); }
public MapArray<String, MapArray<String, ICell>> rowsContains(String value, Column column) { return rows().containsValue(value, column); } public MapArray<String, MapArray<String, ICell>> rowsMatches(String regEx, Column column) {
public boolean waitRows(int count) { return waitCondition(() -> rows().count() >= count); }
private int getRowIndex(String name) { int nameIndex; List<String> headers = rows().headers(); if (headers != null && headers.contains(name)) nameIndex = headers.indexOf(name); else throw exception("Can't Get Row: '%s'. Available RowHeaders: (%s)", name, print(headers, ", ", "'{0}'")); return nameIndex + rows().getStartIndex(); }
public final MapArray<String, ICell> getColumn(String colName) { try { int rowsCount = table.rows().count(); List<String> headers = table.rows().headers(); List<WebElement> webColumn = timer().getResultByCondition( () -> getLineAction(colName), els -> els.size() == rowsCount); return new MapArray<>(rowsCount, table.rows().headers()::get, value -> table.cell(webColumn.get(value), new Column(colName), new Row(headers.get(value)))); } catch (Exception | Error ex) { throw throwColumnException(colName, ex.getMessage()); } }
public MapArray<String, ICell> row(String rowName) { return rows().getRow(rowName); }
public ICell cell(String value) { ICell result; for (Pair<String, MapArray<String, ICell>> row : rows().get()) { result = row.value.first((cName, cValue) -> cValue.getText().equals(value)); if (result != null) return result; } return null; }
public String rowName() { return (rowName != null && !rowName.equals("")) ? rowName : table.rows().headers().get(rowNum - 1); }
public List<String> rowValue(int rowNum) { return rows().getRowValue(rowNum); }
Cell(int columnNum, int rowNum, String colName, String rowName, Table table) { this.columnNum = columnNum; this.rowNum = rowNum; this.columnName = colName; this.rowName = rowName; int colIndex = columnNum - 1 + table.columns().getStartIndex(); int rowIndex = rowNum - 1 + table.rows().getStartIndex(); if (table.cellLocatorTemplate != null) setLocator(fillByMsgTemplate(table.cellLocatorTemplate, colIndex, rowIndex)); else { if (table.rows().locatorChanged()) getFunc = () -> table.row(rowNum).get(columnNum-1).value; else { if (table.columns().locatorChanged()) getFunc = () -> table.column(columnNum).get(rowNum-1).value; }} if (!hasLocator() && getFunc == null) setLocator(fillByMsgTemplate(defaultLocator, columnNum, rowNum)); this.table = table; }
private MapArray<String, MapArray<String, ICell>> withValueByRule( Row row, JFuncTTREx<String, String, Boolean> func) { Collection<String> rowNames = row.hasName() ? table.rows().getRowAsText(row.getName()).where(func).keys() : table.rows().getRowAsText(row.getNum()).where(func).keys(); return new MapArray<>(rowNames, key -> key, this::getColumn); } public final MapArray<String, MapArray<String, ICell>> withValue(String value, Row row) {
public MapArray<String, MapArray<String, ICell>> rowsMatches(String regEx, Column column) { return rows().matchesRegEx(regEx, column); }
private int getRowIndex(String name) { int nameIndex; List<String> headers = select(rows().headers(), String::toLowerCase); String lName = name.toLowerCase(); if (headers != null && headers.contains(lName)) nameIndex = headers.indexOf(lName); else throw exception("Can't Get Row: '%s'. Available RowHeaders: (%s)", name, print(headers, ", ", "'%s'")); return nameIndex + rows().getStartIndex(); }
public final MapArray<String, ICell> getColumn(String colName) { try { int rowsCount = table.rows().count(); List<String> headers = select(table.rows().headers(), String::toLowerCase); List<WebElement> webColumn = timer().getResultByCondition( () -> getLineAction(colName), els -> els.size() == rowsCount); return new MapArray<>(rowsCount, headers::get, value -> table.cell(webColumn.get(value), new Column(colName), new Row(headers.get(value)))); } catch (Exception | Error ex) { throw throwColumnException(colName, ex.getMessage()); } }
public MapArray<String, ICell> row(int rowNum) { return rows().getRow(rowNum); }
public ICell cell(String value) { ICell result; for (Pair<String, MapArray<String, ICell>> row : rows().get()) { result = row.value.first((cName, cValue) -> cValue.getText().equals(value)); if (result != null) return result; } return null; }
public String rowName() { return (rowName != null && !rowName.equals("")) ? rowName : table.rows().headers().get(rowNum - 1); }
public List<String> rowValue(int rowNum) { return rows().getRowValue(rowNum); }