public class Table extends Object
Modifier and Type | Field and Description |
---|---|
Element |
tableElement |
Constructor and Description |
---|
Table(Element tableElement)
Constructs a table component from the specified table element.
|
Modifier and Type | Method and Description |
---|---|
Element |
getCell(int colIndex,
int rowIndex)
Returns the
td/th element that exists at the intersection point of the specified column index and the row index. |
Element |
getCell(String x_regex,
String y_regex)
Returns the
td/th element that exists at the intersection point of the first column containing text that matches the specified x_regex and the first row containing text that matches the specified y_regex. |
int[] |
getCellCoord(String regex)
Returns the x,y coordinate (colIndex, rowIndex) of the first cell who's visible text matches the specified regular expression.
|
Element |
getTableElement()
Returns the table element for this Table.
|
List<String> |
getTextFromColumn(int colIndex)
Returns a List containing the visible text of the cells in the specified column index; text values are obtained using Element.getText() and are trimmed of whitespace.
|
List<String> |
getTextFromColumn(String regex)
Returns a List containing the visible text of the cells from the target column, where the target column is the first one having a cell who's visible text matches the specified (case-insensitive) regex (using Matcher.matches); returned text values are obtained using Element.getText() and are trimmed of whitespace;
|
Map<String,String> |
getTextFromColumns(int colIndexOfKeys,
int colIndexOfValues)
Extracts text data from two columns and returns a Map; the keys are the visible text obtained from the cells in the specified column Index and the values are the visible text obtained from cells in the specified column index; text values for both the keys and values are extracted using Element.getText() and are trimmed of whitespace; duplicate keys are overwritten.
|
List<String> |
getTextFromRow(int rowIndex)
Returns a List containing the visible text of the cells from the row specified by the rowInex, where indexing begins at 0; text values are obtained using Element.getText() and are trimmed of whitespace;
|
List<String> |
getTextFromRow(String regex)
Returns a List containing the visible text of the cells from the target row, where the target row is the first one having a cell who's visible text matches the specified (case-insensitive) regex (using Matcher.matches); returned text values are obtained using Element.getText() and are trimmed of whitespace;
|
String |
toString()
Returns the outerHTML of the table Element.
|
public Element tableElement
public Table(Element tableElement)
public Element getTableElement()
public int[] getCellCoord(String regex)
regex
- the regular expression which is used to match against text extracted from cells using Element.getText(), and evaluated in a case-insensitive manner (using Matcher.matches()).public List<String> getTextFromColumn(int colIndex)
colIndex
- the colum index, where the first column has index 0.public List<String> getTextFromColumn(String regex) throws NotFound
regex
- a regular expression matching the visible text of a td/th
element denoting the target row.NotFound
public Map<String,String> getTextFromColumns(int colIndexOfKeys, int colIndexOfValues)
colIndexOfKeys
- the index of the column to use as keys in the Map, where the first column has index 0.colIndexOfValues
- the index of the column to use as values in the Map, where the first column has index 0.public List<String> getTextFromRow(int rowIndex)
rowIndex
- the row index, where the first column has index 0.public List<String> getTextFromRow(String regex) throws NotFound
regex
- a regular expression matching the visible text of a td/th
element denoting the target row.NotFound
public Element getCell(int colIndex, int rowIndex) throws NotFound
td/th
element that exists at the intersection point of the specified column index and the row index.colIndex
- the column index, where the first column has index 0.rowIndex
- the row index, where the first row has index 0.NotFound
public Element getCell(String x_regex, String y_regex) throws NotFound
td/th
element that exists at the intersection point of the first column containing text that matches the specified x_regex and the first row containing text that matches the specified y_regex.x_regex
- a regular expression matching text in the target column, evaluated in a case-insensitive manner.y_regex
- a regular expression matching text in the target row, evaluated in a case-insensitive mannerNotFound