ContentHandler characters - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ContentHandler characters method.

This code example shows how to use the following methods:characters, endElement, startElement
   * Start visitor (initialization) 
   */ 
  @Override 
  public void start(int version) throws IOException {
    try { 
      contentHandler.startElement("", "", "EDITS_VERSION", new AttributesImpl());
      StringBuilder bld = new StringBuilder();
      bld.append(version);
      addString(bld.toString());
      contentHandler.endElement("", "", "EDITS_VERSION");
    } 
    catch (SAXException e) {
      throw new IOException("SAX error: " + e.getMessage());
    } 
  } 
 
  public void addString(String str) throws SAXException {
    int slen = str.length();
    char arr[] = new char[slen];
    str.getChars(0, slen, arr, 0);

8
CodeRank
This code example shows how to use the following methods:characters, endDocument, endElement, startDocument, startElement
	} 
 
	public void fire(final ContentHandler handle) throws SAXException {
		switch (type) {
			case START_DOCUMENT:
				handle.startDocument();
				break; 
			case END_DOCUMENT:
				handle.endDocument();
				break; 
			case START_ELEMENT:
				handle.startElement((String) params[0], (String) params[1], (String) params[2],
						(Attributes) params[3]);
				break; 
			case END_ELEMENT:
				handle.endElement((String) params[0], (String) params[1], (String) params[2]);
				break; 
			case CHARACTERS:
				handle.characters((char[]) params[0], (Integer) params[1], (Integer) params[2]);
				break; 

6
CodeRank
This code example shows how to use the following methods:characters, endElement, startElement
	protected void write(ContentHandler pHandler, String pTagName, String pValue) throws SAXException {
		write(pHandler, pTagName, pValue.toCharArray());
	} 
 
	protected void write(ContentHandler pHandler, String pTagName, char[] pValue) throws SAXException {
		pHandler.startElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG, ZERO_ATTRIBUTES);
		if (pTagName != null) {
			pHandler.startElement("", pTagName, pTagName, ZERO_ATTRIBUTES);
		} 
		pHandler.characters(pValue, 0, pValue.length);
		if (pTagName != null) {
			pHandler.endElement("", pTagName, pTagName);
		} 
		pHandler.endElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG);
	} 
 
	protected void write(ContentHandler pHandler, String pLocalName, String pQName,
						 String pValue) throws SAXException {
		pHandler.startElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG, ZERO_ATTRIBUTES);
		pHandler.startElement(XmlRpcWriter.EXTENSIONS_URI, pLocalName, pQName, ZERO_ATTRIBUTES);
6
CodeRank
This code example shows how to use the following methods:characters, endElement, startElement
        contentHandler.endElement("", "properties", "properties");
        contentHandler.endDocument();
    } 
 
    private static void outputProperty(ContentHandler contentHandler, String name, String value) throws SAXException {
        contentHandler.startElement("", "property", "property", NO_ATTRIBUTES);
        contentHandler.startElement("", "name", "name", NO_ATTRIBUTES);
        contentHandler.characters(name.toCharArray(), 0, name.length());
        contentHandler.endElement("", "name", "name");
        contentHandler.startElement("", "value", "value", NO_ATTRIBUTES);
        contentHandler.characters(value.toCharArray(), 0, value.length());
        contentHandler.endElement("", "value", "value");
        contentHandler.endElement("", "property", "property");
    } 
} 
7
CodeRank
This code example shows how to use the following methods:characters, endElement, startElement
    } 
 
    private void genBufferDetails(BufferStats index, BufferStats data, String name) throws SAXException {
        final AttributesImpl atts = new AttributesImpl();
        atts.addAttribute("", "name", "name", "CDATA", name);
        this.contentHandler.startElement(NAMESPACE, "file", PREFIX + ":file", atts);
        atts.clear();
        atts.addAttribute("", "type", "type", "CDATA", "btree");
        this.contentHandler.startElement(NAMESPACE, "buffer", PREFIX + ":buffer", atts);
        atts.clear();
        addValue("size", String.valueOf(index.getSize()));
        addValue("used", String.valueOf(index.getUsed()));
        addValue("hits", String.valueOf(index.getPageHits()));
        addValue("fails", String.valueOf(index.getPageFails()));
        this.contentHandler.endElement(NAMESPACE, "buffer", PREFIX + ":buffer");
        atts.addAttribute("", "type", "type", "CDATA", "data");
        this.contentHandler.startElement(NAMESPACE, "buffer", PREFIX + ":buffer", atts);
        atts.clear();
        addValue("size", String.valueOf(data.getSize()));
        addValue("used", String.valueOf(data.getUsed()));

6
CodeRank
This code example shows how to use the following methods:characters, endDocument, endElement, startDocument, startElement
        String numberString = (String) numberDocument.selectObject("string(/number)");
        int number = Integer.parseInt(numberString);
        String doubleString = Integer.toString(number * 2);
 
        // Generate output document with SAX 
        contentHandler.startDocument();
        contentHandler.startElement("", "number", "number", new AttributesImpl());
        contentHandler.characters(doubleString.toCharArray(), 0, doubleString.length());
        contentHandler.endElement("", "number", "number");
        contentHandler.endDocument();
    } 
} 
7
CodeRank
This code example shows how to use the following methods:characters
 
  public void addString(String str) throws SAXException {
    int slen = str.length();
    char arr[] = new char[slen];
    str.getChars(0, slen, arr, 0);
    contentHandler.characters(arr, 0, slen);
  } 
   
  /** 
   * Finish visitor 
   */ 
  @Override 
  public void close(Throwable error) throws IOException {
    try { 
      contentHandler.endElement("", "", "EDITS");
      if (error != null) {
        String msg = error.getMessage();
        XMLUtils.addSaxString(contentHandler, "ERROR",
            (msg == null) ? "null" : msg);
      } 
6
CodeRank
This code example shows how to use the following methods:characters, endElement, startElement
    throws IOException, SAXException
  { 
    pop(); 
     
    if (uri != null)
      _contentHandler.endElement(uri, localName, qName);
    else 
      _contentHandler.endElement("", null, qName);
  } 
 
  public void processingInstruction(String name, String data)
    throws IOException, SAXException
  { 
    pop(); 
 
    _contentHandler.processingInstruction(name, data);
  } 
   
  public void comment(String data)
    throws IOException, SAXException

7
CodeRank
This code example shows how to use the following methods:characters, endElement, startElement
This code example shows how to use the following methods:toString, characters, endElement, startElement
    } 
 
    private void assertElement( 
            String expected, ContentHandler handler) throws Exception {
        AttributesImpl attributes = new AttributesImpl();
        handler.startElement("", "p", "p", attributes);
        handler.characters("content".toCharArray(), 0, 7);
        handler.endElement("", "p", "p");
        assertEquals(expected, handler.toString());
    } 
 
    private void assertElementWithAttributes( 
            String expected, ContentHandler handler) throws Exception {
        AttributesImpl attributes = new AttributesImpl();
        attributes.addAttribute("", "class", "class", "CDATA", "test");
        handler.startElement("", "p", "p", attributes);
        handler.characters("content".toCharArray(), 0, 7);
        handler.endElement("", "p", "p");
        assertEquals(expected, handler.toString());
    } 
6
CodeRank
characters Method Overview
Receive notification of character data.
See Code Examples for other Java 8 ContentHandler Methods: