/** * Returns the text that is covered by this SpanNode. * * @param text the input text * @return the text that is covered by this SpanNode. */ @Override public CharSequence getText(CharSequence text) { if (children().isEmpty()) { return ""; } StringBuilder str = new StringBuilder(); for (SpanNode node : children()) { CharSequence childText = node.getText(text); if (childText != null) { str.append(node.getText(text)); } } return str; }
/** * Returns the text covered by this span as given by subtree i, or null if subtree i is empty. * * @param i the index of the subtree to use * @param text the text to get a substring from * @return the text covered by this span as given by subtree i, or null if subtree i is empty */ public CharSequence getText(int i, CharSequence text) { if (children(i).isEmpty()) { return null; } StringBuilder str = new StringBuilder(); List<SpanNode> ch = children(i); for (SpanNode node : ch) { CharSequence childText = node.getText(text); if (childText != null) { str.append(node.getText(text)); } } return str; }