Java 8 ContentHandler - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ContentHandler class.

This code example shows how to use the following methods:endDocument, endElement
   * 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);
      } 
      contentHandler.endDocument();
    } 
    catch (SAXException e) {
      throw new IOException("SAX error: " + e.getMessage());
    } 
    out.close();
  } 
 
  @Override 
8
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, 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:endDocument, endElement
   * 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);
      } 
      contentHandler.endDocument();
    } 
    catch (SAXException e) {
      throw new IOException("SAX error: " + e.getMessage());
    } 
    out.close();
  } 
 
  @Override 
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
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:endDocument, endElement, startDocument, startElement
        super(Map.class, Map.class, "application/xml", new QName("result"));
    } 
 
    @Override 
    public void encode(Object object, ContentHandler handler) throws Exception {
        handler.startDocument();
        Map map = (Map) object;
        if (map.size() > 1) {
            handler.startElement(null, "map", "map", null);
            encode((Map) object, handler);
            handler.endElement(null, "map", "map");
        } 
        else { 
            encode((Map) object, handler);
        } 
        handler.endDocument();
    } 
 
    void encode(Map<?,?> map, ContentHandler h) throws Exception {
        for (Map.Entry<?, ?> e : map.entrySet()) {
            Object key = e.getKey();
7
CodeRank
This code example shows how to use the following methods:endDocument, endElement, startDocument, startElement
    protected List generators = new ArrayList();
    protected DraftDocument doc;
 
    public void generate(DraftDocument doc, ContentHandler handler, Map context)
        throws SAXException {
        this.setContentHandler(handler);
        this.doc = doc;
 
        try { 
            handler.startDocument();
 
            String raw = NAMESPACE + ":" + ROOT_ELEMENT;
            handler.startElement(NAMESPACE, raw, ROOT_ELEMENT,
                new AttributesImpl());
            doGenerate(); 
            handler.endElement(NAMESPACE, raw, ROOT_ELEMENT);
            handler.endDocument();
        } catch (SAXException e) {
            e.printStackTrace();
        } 

6
CodeRank
This code example shows how to use the following methods:endElement
        else { 
            localName = name.toString();
            qualifiedName = localName;
        } 
        try { 
            handler.endElement(uri, localName, qualifiedName);
        } 
        catch (SAXException e) {
            handleException(e);
        } 
    } 
 
    protected void handleException(SAXException e) {
        throw new RuntimeException(e);
    } 
 
    /* (non-Javadoc) 
     * @see groovy.util.BuilderSupport#createNode(java.lang.Object, java.util.Map, java.lang.Object) 
     */ 
    protected Object createNode(Object name, Map attributes) {
6
CodeRank

Related Java 8 ContentHandler Questions & Answers:

See Code Examples for Java 8 ContentHandler Methods: