private void extractRow(Map<String, String> map, NodeList rows, int rowIndex) { Node row = rows.elementAt(rowIndex); if (row != null) extractColumns(map, row); }
private void extractRow(Map<String, String> map, NodeList rows, int rowIndex) { Node row = rows.elementAt(rowIndex); if (row != null) extractColumns(map, row); }
/** * Get the child of this node at the given position. * @param index The in the node list of the child. * @return The child at that index. */ public Node getChild (int index) { return ( (null == getChildren ()) ? null : getChildren ().elementAt (index)); }
/** * Get child at given index * @param index The index into the child node list. * @return Node The child node at the given index or null if none. */ public Node childAt (int index) { return ( (null == getChildren ()) ? null : getChildren ().elementAt (index)); }
/** * Get the child of this node at the given position. * @param index The in the node list of the child. * @return The child at that index. */ public Node getChild (int index) { return ( (null == getChildren ()) ? null : getChildren ().elementAt (index)); }
/** * Get child at given index * @param index The index into the child node list. * @return Node The child node at the given index or null if none. */ public Node childAt (int index) { return ( (null == getChildren ()) ? null : getChildren ().elementAt (index)); }
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)); } } }
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; }
/** * 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; }
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 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 NodeList getRows(NodeList tables) { TagNameFilter trFilter = new TagNameFilter("tr"); Node table = tables.elementAt(0); if (table.getChildren() != null) return table.getChildren().extractAllNodesThatMatch(trFilter); return new NodeList(); }
private NodeList getRows(NodeList tables) { TagNameFilter trFilter = new TagNameFilter("tr"); Node table = tables.elementAt(0); if (table.getChildren() != null) return table.getChildren().extractAllNodesThatMatch(trFilter); return new NodeList(); }
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; }