WhitespaceProcessor { public void append(Element element, String content) { int i = 0; char ch; this.element = element; partial = ""; nSpaces = 0; owner = (OdfFileDom) element.getOwnerDocument(); for (i = 0; i < content.length(); i++) { ch = content.charAt(i); if (ch == ' ') { if (nSpaces == 0) { partial += " "; } nSpaces++; } else if (ch == '\n') { emitPartial(); element.appendChild(new TextLineBreakElement(owner)); } else if (ch == '\t') { emitPartial(); element.appendChild(new TextTabElement(owner)); } else if (ch != '\r') { if (nSpaces > 1) { emitPartial(); } partial += ch; nSpaces = 0; } } emitPartial(); }  void append(Element element, String content); String getText(Node element); static void appendText(Element element, String content);  }
@Test public void testAppend() { LOG.info("append"); Element element = null; WhitespaceProcessor instance = new WhitespaceProcessor(); int i; for (i = 0; i < plainText.length; i++) { element = new OdfTextParagraph(dom); instance.append(element, plainText[i]); compareResults(element, plainText[i], elementResult[i]); } }