1 16 package org.apache.commons.jelly.util; 17 18 import org.xml.sax.Attributes ; 19 import org.xml.sax.ContentHandler ; 20 import org.xml.sax.Locator ; 21 import org.xml.sax.SAXException ; 22 23 29 public class SafeContentHandler implements ContentHandler { 30 private ContentHandler handler; 31 private boolean documentStarted; 32 private boolean documentEnded; 33 34 public SafeContentHandler(ContentHandler handler) { 35 this.handler = handler; 36 } 37 38 41 public void startDocument() throws SAXException { 42 if (! documentStarted) { 43 handler.startDocument(); 44 documentStarted = true; 45 } 46 } 47 48 51 public void endDocument() throws SAXException { 52 if (! documentEnded) { 53 handler.endDocument(); 54 documentEnded = true; 55 } 56 } 57 58 64 public void characters(char[] arg0, int arg1, int arg2) 65 throws SAXException { 66 handler.characters(arg0, arg1, arg2); 67 } 68 69 75 public void endElement(String arg0, String arg1, String arg2) 76 throws SAXException { 77 handler.endElement(arg0, arg1, arg2); 78 } 79 80 84 public void endPrefixMapping(String arg0) throws SAXException { 85 handler.endPrefixMapping(arg0); 86 } 87 88 94 public void ignorableWhitespace(char[] arg0, int arg1, int arg2) 95 throws SAXException { 96 handler.ignorableWhitespace(arg0, arg1, arg2); 97 } 98 99 104 public void processingInstruction(String arg0, String arg1) 105 throws SAXException { 106 handler.processingInstruction(arg0, arg1); 107 } 108 109 112 public void setDocumentLocator(Locator arg0) { 113 handler.setDocumentLocator(arg0); 114 } 115 116 120 public void skippedEntity(String arg0) throws SAXException { 121 handler.skippedEntity(arg0); 122 } 123 124 131 public void startElement( 132 String arg0, 133 String arg1, 134 String arg2, 135 Attributes arg3) 136 throws SAXException { 137 handler.startElement(arg0, arg1, arg2, arg3); 138 } 139 140 145 public void startPrefixMapping(String arg0, String arg1) 146 throws SAXException { 147 handler.startPrefixMapping(arg0, arg1); 148 } 149 } 150 | Popular Tags |