SafeContentHandler extends ContentHandlerDecorator { @Override public void characters(char[] ch, int start, int length) throws SAXException { filter(ch, start, length, charactersOutput); } SafeContentHandler(ContentHandler handler); @Override void startElement(
            String uri, String localName, String name, Attributes atts); @Override void endElement(String uri, String localName, String name); @Override void endDocument(); @Override void characters(char[] ch, int start, int length); @Override void ignorableWhitespace(char[] ch, int start, int length);  }
@Test public void testNormalCharacters() throws SAXException { safe.characters("abc".toCharArray(), 0, 3); assertEquals("abc", output.toString()); }
@Test public void testInvalidCharacters() throws SAXException { safe.characters("ab\u0007".toCharArray(), 0, 3); safe.characters("a\u000Bc".toCharArray(), 0, 3); safe.characters("\u0019bc".toCharArray(), 0, 3); assertEquals("ab\ufffda\ufffdc\ufffdbc", output.toString()); }