1 16 package org.outerj.daisy.publisher.serverimpl; 17 18 import org.xml.sax.ContentHandler ; 19 import org.xml.sax.SAXException ; 20 import org.xml.sax.helpers.AttributesImpl ; 21 22 public abstract class AbstractHandler { 23 protected ContentHandler consumer; 24 25 public AbstractHandler(ContentHandler consumer) { 26 this.consumer = consumer; 27 } 28 29 protected void outputError(String message) throws SAXException { 30 AttributesImpl attrs = new AttributesImpl (); 31 attrs.addAttribute("", "class", "class", "CDATA", "daisy-error"); 32 consumer.startElement("", "p", "p", attrs); 33 consumer.characters(message.toCharArray(), 0, message.length()); 34 consumer.endElement("", "p", "p"); 35 } 36 37 protected void outputErrorAsDoc(String message) throws SAXException { 38 consumer.startElement("", "html", "html", new AttributesImpl ()); 39 consumer.startElement("", "body", "body", new AttributesImpl ()); 40 outputError(message); 41 consumer.endElement("", "body", "body"); 42 consumer.endElement("", "html", "html"); 43 } 44 } 45 | Popular Tags |