/** * This will be called for each chunk of character data encountered. * * @param elementText all text in an element, including whitespace. */ private void characters(String elementText) throws JDOMException { char[] c = elementText.toCharArray(); try { contentHandler.characters(c, 0, c.length); } catch (SAXException se) { throw new JDOMException("Exception in characters", se); } }
/** Convert an Object to a String and generate SAX characters events. */ public static void objectToCharacters(Object o, ContentHandler contentHandler) { try { char[] charValue = (o == null) ? null : o.toString().toCharArray(); if (charValue != null) contentHandler.characters(charValue, 0, charValue.length); } catch (Exception e) { throw new OXFException(e); } }
/** * Read characters from a Reader and generate SAX characters events. * * <p>The caller has to close the Reader if needed. */ public static void readerToCharacters(Reader reader, ContentHandler contentHandler) { try { // Work with buffered Reader reader = new BufferedReader(reader); // Read and write in chunks char[] buf = new char[1024]; int count; while ((count = reader.read(buf)) != -1) contentHandler.characters(buf, 0, count); } catch (Exception e) { throw new OXFException(e); } }