/** {@inheritDoc} */ @Override public void characters(char[] ch, int start, int length) throws SAXException { if (!skipProperty) { super.characters(ch, start, length); } else { if (invalue) { invalue = false; // Arrays.copyOfRange(ch, start, start + length) char[] range = new char[length]; System.arraycopy(ch, start, range, 0, length); String textContent = new String(range); // skip only if filter() say so boolean skip = filter(textContent, lastNodeName); if (!skip) { while (!elementBuffer.isEmpty()) { BufferedElement be = elementBuffer.remove(0); super.startElement(be.getUri(), be.getLocalName(), be.getQName(), be.getAtts()); } super.characters(ch, start, length); skipProperty = false; } } } }
/** * If character sequence belongs to {@code isbn} element, isbn is validated against regular * expression. * * <p>If pattern does not match, isbn is filtered out. * * @see org.xml.sax.helpers.XMLFilterImpl#characters(char[], int, int) */ @Override public void characters(char[] ch, int start, int length) throws SAXException { if (workingOnIsbnElement) { String isbn = String.valueOf(ch, start, length); Matcher matcher = ISBNPATTERN.matcher(isbn); if (matcher.matches()) { super.characters(ch, start, length); } } else { super.characters(ch, start, length); } }
public void characters(char[] ch, int start, int length) throws SAXException { StackContext stackEntry = stack.peek(); SaxEventBufferBuilder bufferBuilder = stackEntry.bufferBuilder; if (bufferBuilder != null) { bufferBuilder.characters(ch, start, length); } super.characters(ch, start, length); }
private void createStyleElement(String namespaceURI, String styleSheet) throws SAXException { AttributesImpl newAttrs = new AttributesImpl(); newAttrs.addAttribute( ATTRIBUTE_URI, ATTRIBUTE_TYPE, ATTRIBUTE_TYPE, ATTRIBUTE_CDATA, ATTRIBUTE_VALUE_TEXT_CSS); super.startElement(namespaceURI, STYLE_ELEMENT_NAME, STYLE_ELEMENT_NAME, newAttrs); // now write the style sheet char[] text = styleSheet.toCharArray(); super.characters(text, 0, text.length); }
/** * Write character data. * * <p>Pass the event on down the filter chain for further processing. * * @param ch The array of characters to write. * @param start The starting position in the array. * @param len The number of characters to write. * @exception org.xml.sax.SAXException If there is an error writing the characters, or if a * handler further down the filter chain raises an exception. * @see org.xml.sax.ContentHandler#characters(char[], int, int) */ public void characters(char ch[], int start, int len) throws SAXException { try { if (!startTagIsClosed) { write('>'); startTagIsClosed = true; } writeEsc(ch, start, len, false); super.characters(ch, start, len); } catch (IOException e) { throw new SAXException(e); } }
public void characters(char[] ch, int start, int length) throws SAXException { if ((ch == null) || (ch.length == 0) || (length <= 0)) { return; } try { /* * we can't use the writeString method here because it's possible we * don't receive all characters at once and calling writeString * would cause unwanted spaces to be added in between these chunks * of character arrays. */ String string = String.valueOf(ch, start, length); if (escapeText) { string = escapeElementEntities(string); } if (format.isTrimText()) { if ((lastOutputNodeType == Node.TEXT_NODE) && !charsAdded) { writer.write(' '); } else if (charsAdded && Character.isWhitespace(lastChar)) { writer.write(' '); } else if (lastOutputNodeType == Node.ELEMENT_NODE && format.isPadText() && lastElementClosed && Character.isWhitespace(ch[0])) { writer.write(PAD_TEXT); } String delim = ""; StringTokenizer tokens = new StringTokenizer(string); while (tokens.hasMoreTokens()) { writer.write(delim); writer.write(tokens.nextToken()); delim = " "; } } else { writer.write(string); } charsAdded = true; lastChar = ch[(start + length) - 1]; lastOutputNodeType = Node.TEXT_NODE; super.characters(ch, start, length); } catch (IOException e) { handleException(e); } }
/** <i>[SAX ContentHandler interface support]</i> Receives notification of character data. */ public void characters(char ch[], int start, int length) throws SAXException { this.ensureInitialization(); super.characters(ch, start, length); }
public void characters(char[] ch, int start, int length) throws SAXException { if (!isPruning()) { super.characters(ch, start, length); } }
/** * Write a sequence of characters. * * @param ch The characters to write. * @param start The starting position in the array. * @param length The number of characters to use. * @exception org.xml.sax.SAXException If there is an error writing the characters, or if a filter * further down the chain raises an exception. * @see XMLWriter#characters(char[], int, int) */ public void characters(char ch[], int start, int length) throws SAXException { state = SEEN_DATA; super.characters(ch, start, length); }
private void writeNewLine() throws SAXException { super.characters(NEWLINE, 0, NEWLINE.length); }
/** * {@inheritDoc} * * @see org.xml.sax.helpers.XMLFilterImpl#characters(char[], int, int) */ @Override public void characters(char[] data, int start, int length) throws SAXException { char[] value = this.replace(String.copyValueOf(data, start, length)).toCharArray(); super.characters(value, 0, value.length); }