public class Table extends Object implements Iterable<Element>
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 the column and row specified by the column index and the row index. |
Element |
getCell(int colIndex,
String rowHeaderRegex)
Returns the
td/th element that exists at the intersection point of the the column and row specified by the column index and the (case-insensitive) row headerRegex (using Matcher.matches). |
Element |
getCell(String colHeaderRegex,
int rowIndex)
Returns the
td/th element that exists at the intersection point of the the columns and row specified by the (case-insensitive) column headerRegex (using Matcher.matches) and the rowIndex. |
Element |
getCell(String colHeaderRegex,
String rowHeaderRegex)
Returns the
td/th element that exists at the intersection point of the the row and column specified by the (case-insensitive) column headerRegex and row headerRegex (using Matcher.matches). |
int[] |
getCellCoord(String regex)
Returns the x,y coordinate (colIndex, rowIndex) of the first cell who's visible text matches the specified regular expression.
|
Elements |
getCol(int colIndex)
Returns the
td/th elements in the column specified by the column index, including any elements that span across the specified column. |
Elements |
getCol(String headerRegex)
Returns the
td/th elements from the first column who's text matches the specified (case-insensitive) headerRegex (using Matcher.matches); the returned elements include any elements that merge (colspan) across the specified column. |
Elements |
getColAbove(String headerRegex)
Returns
td/th elements in the column above the cell who's text matches the specified (case-insensitive) headerRegex (using Matcher.matches); the returned elements include any elements that merge (colspan) across the specified column. |
Elements |
getColBelow(String headerRegex)
Returns
td/th elements in the column below the cell who's text matches the specified (case-insensitive) headerRegex (using Matcher.matches); the returned elements include any elements that merge (colspan) across the specified column. |
Element |
getElement()
Returns the table element for this Table.
|
Elements |
getRow(int rowIndex)
Returns the
td/th elements in the row specified by the row index, including any elements that span across the specified row. |
Elements |
getRow(String headerRegex)
Returns the
td/th elements from the first row who's text matches the specified (case-insensitive) headerRegex (using Matcher.matches); the returned elements include any elements that merge (colspan) across the specified row. |
Elements |
getRowLeftOf(String headerRegex)
Returns
td/th elements in the row to the left of the cell who's text matches the specified (case-insensitive) headerRegex (using Matcher.matches); the returned elements include any elements that merge (colspan) across the specified row. |
Elements |
getRowRightOf(String headerRegex)
Returns
td/th elements in the row to the right of the cell who's text matches the specified (case-insensitive) headerRegex (using Matcher.matches); the returned elements include any elements that merge (colspan) across the specified row. |
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.getTextContent() 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 text content obtained from the cells in the specified column Index and the values are the text content 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 inner text of the cells from the row specified by the rowInex, where indexing begins at 0; text values are obtained using Element.getTextContent() and are trimmed of whitespace;
|
List<String> |
getTextFromRow(String regex)
Returns a List containing the inner 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.getTextContent() and are trimmed of whitespace;
|
Iterator<Element> |
iterator()
Returns an iterator over the immediate child
<tr> elements. |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public Element getElement()
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 Elements getCol(int colIndex)
td/th
elements in the column specified by the column index, including any elements that span across the specified column.colIndex
- the colum index, where the first column has index 0.public Elements getCol(String headerRegex) throws NotFound
td/th
elements from the first column who's text matches the specified (case-insensitive) headerRegex (using Matcher.matches); the returned elements include any elements that merge (colspan) across the specified column.headerRegex
- a regular expression matching the text content of a td/th
elementNotFound
public Elements getColAbove(String headerRegex) throws NotFound
td/th
elements in the column above the cell who's text matches the specified (case-insensitive) headerRegex (using Matcher.matches); the returned elements include any elements that merge (colspan) across the specified column.headerRegex
- a regular expression matching the text content of a td/th
elementNotFound
public Elements getColBelow(String headerRegex) throws NotFound
td/th
elements in the column below the cell who's text matches the specified (case-insensitive) headerRegex (using Matcher.matches); the returned elements include any elements that merge (colspan) across the specified column.headerRegex
- a regular expression matching the text content of a td/th
elementNotFound
public Elements getRow(int rowIndex)
td/th
elements in the row specified by the row index, including any elements that span across the specified row.rowIndex
- the row index, where the first row has index 0.public Elements getRow(String headerRegex) throws NotFound
td/th
elements from the first row who's text matches the specified (case-insensitive) headerRegex (using Matcher.matches); the returned elements include any elements that merge (colspan) across the specified row.headerRegex
- a regular expression matching the text content of a td/th
elementNotFound
public Elements getRowLeftOf(String headerRegex) throws NotFound
td/th
elements in the row to the left of the cell who's text matches the specified (case-insensitive) headerRegex (using Matcher.matches); the returned elements include any elements that merge (colspan) across the specified row.headerRegex
- a regular expression matching the text content of a td/th
elementNotFound
public Elements getRowRightOf(String headerRegex) throws NotFound
td/th
elements in the row to the right of the cell who's text matches the specified (case-insensitive) headerRegex (using Matcher.matches); the returned elements include any elements that merge (colspan) across the specified row.headerRegex
- a regular expression matching the text content of a td/th
elementNotFound
public Element getCell(String colHeaderRegex, String rowHeaderRegex) throws NotFound
td/th
element that exists at the intersection point of the the row and column specified by the (case-insensitive) column headerRegex and row headerRegex (using Matcher.matches).colHeaderRegex
- a regular expression matching the text content of a td/th
elementrowHeaderRegex
- a regular expression matching the text content of a td/th
elementNotFound
public Element getCell(String colHeaderRegex, int rowIndex) throws NotFound
td/th
element that exists at the intersection point of the the columns and row specified by the (case-insensitive) column headerRegex (using Matcher.matches) and the rowIndex.rowIndex
- the row index, where the first row has index 0.colHeaderRegex
- a regular expression matching the text content of a td/th
elementNotFound
public Element getCell(int colIndex, String rowHeaderRegex) throws NotFound
td/th
element that exists at the intersection point of the the column and row specified by the column index and the (case-insensitive) row headerRegex (using Matcher.matches).colIndex
- the colum index, where the first column has index 0.rowHeaderRegex
- a regular expression matching the text content of a td/th
elementNotFound
public Element getCell(int colIndex, int rowIndex) throws NotFound
td/th
element that exists at the intersection point of the the column and row specified by the column index and the row index.colIndex
- the colum index, where the first column has index 0.rowIndex
- the row index, where the first row has index 0.NotFound
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