int rowNumberContainingText(String searchText) throws InvalidInputException { Parse rows = table.at(0, 0); int numberOfRows = rows.size(); for (int i = 0; i < numberOfRows; i++) { Parse columns = table.at(0, i, 0); int numberOfColumns = columns.size(); for (int j = 0; j < numberOfColumns; ++j) { if (searchText.equals(table.at(0, i, j).text())) { return i; } } } throw new InvalidInputException(errorMsg(searchText)); }
public Parse makeMessageCell(Exception e) { Parse errorCell = new Parse("td", "", null, null); final StringWriter buffer = new StringWriter(); e.printStackTrace(new PrintWriter(buffer)); errorCell.addToTag(" colspan=\"" + (columnBindings.length + 1) + "\""); errorCell.addToBody("<i>" + ERROR_INDICATOR + e.getMessage() + "</i>"); errorCell.addToBody("<pre>" + (buffer.toString()) + "</pre>"); wrong(errorCell); return errorCell; }
@Override public void doTable(Parse table) { table.parts.parts.addToBody("<br/>classpath: " + System.getProperty("java.class.path")); } }
int endTag = lc.indexOf(">", startTag) + 1; int startEnd = findMatchingEndTag(lc, endTag, tags[level], offset); int endEnd = lc.indexOf(">", startEnd) + 1; int startMore = lc.indexOf("<" + tags[level], endEnd); parts = new Parse(body, tags, level + 1, offset + endTag); body = null; } else { // Check for nested table int index = body.indexOf("<" + tags[0]); if (index >= 0) { parts = new Parse(body, tags, 0, offset + endTag); body = ""; more = new Parse(trailer, tags, level, offset + endEnd); trailer = null;
@Override public void doCells(Parse cells) { this.cells = cells; String methodName = cells.text(); try { getClass().getMethod(methodName).invoke(this); } catch (Exception e) { exception(cells, e); } }
public void doRows(Parse rows) { try { bind(rows.parts); results = query(); match(list(rows.more), list(results), 0); Parse last = rows.last(); last.more = buildRows(surplus.toArray()); mark(last.more, "surplus"); mark(missing.iterator(), "missing"); } catch (Exception e) { exception (rows.leaf(), e); } }
public void exception(Parse cell, Throwable exception) { while (exception.getClass().equals(InvocationTargetException.class)) { exception = ((InvocationTargetException) exception).getTargetException(); } if (isFriendlyException(exception)) { cell.addToBody("<hr/>" + label(exception.getMessage())); } else { final StringWriter buf = new StringWriter(); exception.printStackTrace(new PrintWriter(buf)); cell.addToBody("<hr><pre><div class=\"fit_stacktrace\">" + (buf.toString()) + "</div></pre>"); } cell.addToTag(" class=\"error\""); counts.exceptions++; }
/** * Returns the first leaf descendant of the current node in depth-first traversal. * * @return first leaf */ public Parse leaf() { return parts == null ? this : parts.leaf(); }
/** * Returns the number of sibling nodes following this node. For the first child node of a given * parent, this is equal to the size of the child list. * * @return number of siblings following */ public int size() { return more == null ? 1 : more.size() + 1; }
public void ignore(Parse cell) { cell.addToTag(" bgcolor=\"" + gray + "\""); counts.ignores++; }
/** * Returns the last node of the current sibling list. * * @return last sibling */ public Parse last() { return more == null ? this : more.last(); }