1 17 package org.alfresco.repo.importer; 18 19 import java.io.InputStream ; 20 21 import org.alfresco.util.ParameterCheck; 22 import org.xml.sax.Attributes ; 23 import org.xml.sax.ErrorHandler ; 24 import org.xml.sax.Locator ; 25 import org.xml.sax.SAXException ; 26 import org.xml.sax.SAXParseException ; 27 28 29 34 public class DefaultContentHandler 35 implements ImportContentHandler, ErrorHandler 36 { 37 private ImportContentHandler targetHandler = null; 38 private Importer importer = null; 39 40 41 46 public DefaultContentHandler(ImportContentHandler targetHandler) 47 { 48 ParameterCheck.mandatory("targetHandler", targetHandler); 49 this.targetHandler = targetHandler; 50 } 51 52 56 public void setImporter(Importer importer) 57 { 58 this.importer = importer; 59 this.targetHandler.setImporter(importer); 60 } 61 62 66 public InputStream importStream(String content) 67 { 68 return targetHandler.importStream(content); 69 } 70 71 75 public void setDocumentLocator(Locator locator) 76 { 77 targetHandler.setDocumentLocator(locator); 78 } 79 80 84 public void startDocument() throws SAXException 85 { 86 importer.start(); 87 targetHandler.startDocument(); 88 } 89 90 94 public void endDocument() throws SAXException 95 { 96 try 97 { 98 targetHandler.endDocument(); 99 } 100 finally 101 { 102 importer.end(); 103 } 104 } 105 106 110 public void startPrefixMapping(String prefix, String uri) throws SAXException 111 { 112 targetHandler.startPrefixMapping(prefix, uri); 113 } 114 115 119 public void endPrefixMapping(String prefix) throws SAXException 120 { 121 targetHandler.endPrefixMapping(prefix); 122 } 123 124 128 public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException 129 { 130 targetHandler.startElement(uri, localName, qName, atts); 131 } 132 133 137 public void endElement(String uri, String localName, String qName) throws SAXException 138 { 139 targetHandler.endElement(uri, localName, qName); 140 } 141 142 146 public void characters(char[] ch, int start, int length) throws SAXException 147 { 148 targetHandler.characters(ch, start, length); 149 } 150 151 155 public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException 156 { 157 targetHandler.ignorableWhitespace(ch, start, length); 158 } 159 160 164 public void processingInstruction(String target, String data) throws SAXException 165 { 166 targetHandler.processingInstruction(target, data); 167 } 168 169 173 public void skippedEntity(String name) throws SAXException 174 { 175 targetHandler.skippedEntity(name); 176 } 177 178 182 public void error(SAXParseException exception) throws SAXException 183 { 184 try 185 { 186 targetHandler.error(exception); 187 } 188 finally 189 { 190 importer.error(exception); 191 } 192 } 193 194 198 public void fatalError(SAXParseException exception) throws SAXException 199 { 200 try 201 { 202 targetHandler.error(exception); 203 } 204 finally 205 { 206 importer.error(exception); 207 } 208 } 209 210 214 public void warning(SAXParseException exception) throws SAXException 215 { 216 targetHandler.warning(exception); 217 } 218 219 } 220 | Popular Tags |