1 16 package com.blandware.atleap.common.parsers.xml; 17 18 import org.xml.sax.Attributes ; 19 import org.xml.sax.SAXException ; 20 import org.xml.sax.helpers.DefaultHandler ; 21 22 import java.io.IOException ; 23 import java.io.Writer ; 24 25 33 class TextExtractingContentHandler extends DefaultHandler { 34 private Writer output; 35 36 private TextExtractingContentHandler() {} 37 38 TextExtractingContentHandler(Writer writer) { 39 this.output = writer; 40 } 41 42 public void startElement(String uri, String localName, String qName, 43 Attributes attributes) throws SAXException { 44 try { 45 output.write(' '); 46 } catch (IOException e) { 47 throw new SAXException (e); 48 } 49 } 50 51 public void endElement(String uri, String localName, String qName) 52 throws SAXException { 53 try { 54 output.write(' '); 55 } catch (IOException e) { 56 throw new SAXException (e); 57 } 58 } 59 60 public void characters(char[] ch, int start, int length) 61 throws SAXException { 62 try { 63 output.write(ch, start, length); 64 } catch (IOException e) { 65 throw new SAXException (e); 66 } 67 } 68 69 public void ignorableWhitespace(char[] ch, int start, int length) 70 throws SAXException { 71 try { 72 output.write(ch, start, length); 73 } catch (IOException e) { 74 throw new SAXException (e); 75 } 76 } 77 78 public void skippedEntity(String name) throws SAXException { 79 try { 80 output.write(' '); 81 } catch (IOException e) { 82 throw new SAXException (e); 83 } 84 } 85 86 public void processingInstruction(String target, String data) 87 throws SAXException { 88 try { 89 output.write(' '); 90 } catch (IOException e) { 91 throw new SAXException (e); 92 } 93 } 94 } 95 | Popular Tags |