/** * Found more than one adjacent Text node; merge them. Appends forwards * and removes backwards to minimize memory copies of list elems. */ private void merge(ParentNode node, int i, int j) { int k = i; StringBuffer buf = new StringBuffer(node.getChild(k++).getValue()); while (k <= j) buf.append(node.getChild(k++).getValue()); k = j; while (k >= i) node.removeChild(k--); // replace run with compact merged Text node unless empty String norm = normalizeWhitespace(buf.toString()); if (norm.length() > 0) { node.insertChild(new Text(norm), i); } }
/** * Found more than one adjacent Text node; merge them. Appends forwards * and removes backwards to minimize memory copies of list elems. */ private void merge(ParentNode node, int i, int j) { int k = i; StringBuffer buf = new StringBuffer(node.getChild(k++).getValue()); while (k <= j) buf.append(node.getChild(k++).getValue()); k = j; while (k >= i) node.removeChild(k--); // replace run with compact merged Text node unless empty String norm = normalizeWhitespace(buf.toString()); if (norm.length() > 0) { node.insertChild(new Text(norm), i); } }
@Override protected void insertFosterParentedChild(Element child, Element table, Element stackParent) throws SAXException { try { Node parent = table.getParent(); if (parent != null) { // always an element if not null ((ParentNode)parent).insertChild(child, indexOfTable(table, stackParent)); cachedTableIndex++; } else { stackParent.appendChild(child); } } catch (XMLException e) { fatal(e); } }
@Override protected Element createAndInsertFosterParentedElement(String ns, String name, HtmlAttributes attributes, Element table, Element stackParent) throws SAXException { try { Node parent = table.getParent(); Element child = createElement(ns, name, attributes, parent != null ? (Element) parent : stackParent); if (parent != null) { // always an element if not null ((ParentNode) parent).insertChild(child, indexOfTable(table, stackParent)); cachedTableIndex++; } else { stackParent.appendChild(child); } return child; } catch (XMLException e) { fatal(e); throw new RuntimeException("Unreachable"); } }
@Override protected Element createAndInsertFosterParentedElement(String ns, String name, HtmlAttributes attributes, Element table, Element stackParent) throws SAXException { try { Node parent = table.getParent(); Element child = createElement(ns, name, attributes, parent != null ? (Element) parent : stackParent); if (parent != null) { // always an element if not null ((ParentNode) parent).insertChild(child, indexOfTable(table, stackParent)); cachedTableIndex++; } else { stackParent.appendChild(child); } return child; } catch (XMLException e) { fatal(e); throw new RuntimeException("Unreachable"); } }
@Override protected void insertFosterParentedChild(Element child, Element table, Element stackParent) throws SAXException { try { Node parent = table.getParent(); if (parent != null) { // always an element if not null ((ParentNode)parent).insertChild(child, indexOfTable(table, stackParent)); cachedTableIndex++; } else { stackParent.appendChild(child); } } catch (XMLException e) { fatal(e); } }
@Override protected void insertFosterParentedChild(Element child, Element table, Element stackParent) throws SAXException { try { Node parent = table.getParent(); if (parent != null) { // always an element if not null ((ParentNode)parent).insertChild(child, indexOfTable(table, stackParent)); cachedTableIndex++; } else { stackParent.appendChild(child); } } catch (XMLException e) { fatal(e); } }
columnIndex += span; parent.insertChild(quote, index + 1); UtilNode.setIgnore(node); return ENext.SKIP;