private void extractRows(Map<String, String> map, NodeList rows) { for (int rowIndex = 0; rowIndex < rows.size(); rowIndex++) { extractRow(map, rows, rowIndex); } }
private void extractRows(Map<String, String> map, NodeList rows) { for (int rowIndex = 0; rowIndex < rows.size(); rowIndex++) { extractRow(map, rows, rowIndex); } }
public TableTag [] getTables() { TableTag [] tableArr = new TableTag[tables.size()]; tables.copyToNodeArray (tableArr); return tableArr; } }
/** * Return the number of child nodes in this tag. * @return The child node count. */ public int getChildCount() { NodeList children; children = getChildren (); return ((null == children) ? 0 : children.size ()); }
private String getValueOfTagWithAttributeValue(String attribute, String value) throws Exception { NodeList matches = getMatchingTags(new HasAttributeFilter(attribute, value)); if (matches.size() != 1) return String.format("There are %d matches, there should be 1.", matches.size()); else return matches.elementAt(0).toHtml(); }
private boolean hasOneTable() { TagNameFilter tableFilter = new TagNameFilter("table"); tables = nodes.extractAllNodesThatMatch(tableFilter); return tables.size() == 1; }
private boolean hasOneTable() { TagNameFilter tableFilter = new TagNameFilter("table"); tables = nodes.extractAllNodesThatMatch(tableFilter); return tables.size() == 1; }
public Row(CompositeTag rowNode) { this.rowNode = rowNode; NodeList nodeList = rowNode.getChildren(); for (int i = 0; i < nodeList.size(); i++) { Node node = nodeList.elementAt(i); if (node instanceof TableColumn) cells.add(new Cell((TableColumn) node)); } }
public HtmlTable(TableTag tableNode) { this.tableNode = tableNode; NodeList nodeList = tableNode.getChildren(); for (int i = 0; i < nodeList.size(); i++) { Node node = nodeList.elementAt(i); if (node instanceof TableRow || node instanceof TableHeader) { rows.add(new Row((CompositeTag) node)); } } }
public Row(CompositeTag rowNode) { this.rowNode = rowNode; NodeList nodeList = rowNode.getChildren(); for (int i = 0; i < nodeList.size(); i++) { Node node = nodeList.elementAt(i); if (node instanceof TableColumn) cells.add(new Cell((TableColumn) node)); } }
public HtmlTable(TableTag tableNode) { this.tableNode = tableNode; NodeList nodeList = tableNode.getChildren(); for (int i = 0; i < nodeList.size(); i++) { Node node = nodeList.elementAt(i); if (node instanceof TableRow || node instanceof TableHeader) { rows.add(new Row((CompositeTag) node)); } } }
Parser parser = Parser.createParser(comment.getText(), "UTF-8"); NodeList htmlAnchorNodes = null; try { htmlAnchorNodes = parser .extractAllNodesThatMatch(new TagNameFilter("a")); } catch (ParserException e) { e.printStackTrace(); } int size = htmlAnchorNodes.size();
/** * Returns the specified attribute value of the first node that is accepted * by the given filter. */ public static String extractAttribute(NodeList nodeList, NodeFilter filter, String attributeName) throws ParserException { NodeList matches = nodeList.extractAllNodesThatMatch(filter, true); if (matches.size() > 0) { return ((TagNode) matches.elementAt(0)).getAttribute(attributeName); } return null; }
public static List<String> getLinks(String url) throws ParserException { Parser htmlParser = new Parser(url); List<String> links = new LinkedList<String>(); NodeList tagNodeList = htmlParser.extractAllNodesThatMatch(new NodeClassFilter(LinkTag.class)); for (int m = 0; m < tagNodeList.size(); m++) { LinkTag loopLinks = (LinkTag) tagNodeList.elementAt(m); String linkName = loopLinks.getLink(); links.add(linkName); } return links; }
private void setExecutionResult(ExecutionResult executionResult) { NodeList cells = rowNode.getChildren(); for (int i = 0; i < cells.size(); i++) { Node cell = cells.elementAt(i); if (cell instanceof Tag) { Tag tag = (Tag) cell; tag.setAttribute("class", executionResult.toString(), '"'); } } } }
private void setExecutionResult(ExecutionResult executionResult) { NodeList cells = rowNode.getChildren(); for (int i = 0; i < cells.size(); i++) { Node cell = cells.elementAt(i); if (cell instanceof Tag) { Tag tag = (Tag) cell; tag.setAttribute("class", executionResult.toString(), '"'); } } } }
private void extractColumns(Map<String, String> map, Node row) { TagNameFilter tdFilter = new TagNameFilter("td"); if (row.getChildren() != null) { NodeList cols = row.getChildren().extractAllNodesThatMatch(tdFilter); if (cols.size() == 2) addColsToMap(map, cols); } }
public int countOfTagWithIdPrefix(String tag, String idPrefix) throws Exception { NodeFilter filter = new AndFilter( new TagNameFilter(tag), new HasAttributePrefixFilter("id", idPrefix)); return getMatchingTags(filter).size(); }
public boolean accept (Node n) { if (n.getParent () != null) { NodeList l = n.getParent ().getChildren (); for (int i = 0; i < l.size (); i++) if (l.elementAt (i) == n && i > 0) return (sibtest.accept (l.elementAt (i - 1))); } return (false); } }
private static NodeList deepClone(NodeList tree, Node clonedParent) { NodeList newNodeList = new NodeList(); for (int i = 0; i < tree.size(); i++) { Node node = tree.elementAt(i); Node newNode = cloneOnlyNode(node, clonedParent); newNodeList.add(newNode); if (node.getChildren() != null) { newNode.setChildren(deepClone(node.getChildren(), newNode)); } } return newNodeList; }