1 22 23 package org.xquark.util; 24 25 import org.xml.sax.*; 26 import org.xml.sax.ext.LexicalHandler ; 27 28 31 public class HandlerDecorator implements LexicalHandler , ContentHandler, ErrorHandler 32 { 33 private static final String RCSRevision = "$Revision: 1.1 $"; 34 private static final String RCSName = "$Name: $"; 35 36 protected LexicalHandler lexicalHandler = null; 37 protected ContentHandler contentHandler = null; 38 protected ErrorHandler errorHandler = null; 39 40 42 public HandlerDecorator() 43 { 44 this(null, null); 45 } 46 47 49 public HandlerDecorator(ContentHandler contentHandler, LexicalHandler lexicalHandler) 50 { 51 this.contentHandler = contentHandler; 52 this.lexicalHandler = lexicalHandler; 53 } 54 55 public void setContentHandler(ContentHandler handler) 56 { 57 contentHandler = handler; 58 } 59 60 public ContentHandler getContentHandler() 61 { 62 return contentHandler; 63 } 64 65 public void setLexicalHandler(LexicalHandler handler) 66 { 67 lexicalHandler = handler; 68 } 69 70 public LexicalHandler getLexicalHandler() 71 { 72 return lexicalHandler; 73 } 74 75 public void setErrorHandler(ErrorHandler handler) 76 { 77 errorHandler = handler; 78 } 79 80 public ErrorHandler getPluggedErrorHandler() 81 { 82 return errorHandler; 83 } 84 85 public void startDocument() throws SAXException 89 { 90 if (contentHandler != null) 91 contentHandler.startDocument(); 92 } 93 94 public void startElement(String str, String str1, String str2, Attributes attributes) 95 throws SAXException 96 { 97 if (contentHandler != null) 98 contentHandler.startElement(str, str1, str2, attributes); 99 } 100 101 public void setDocumentLocator(Locator locator) 102 { 103 if (contentHandler != null) 104 contentHandler.setDocumentLocator(locator); 105 } 106 107 public void endDocument() throws SAXException 108 { 109 if (contentHandler != null) 110 contentHandler.endDocument(); 111 } 112 113 public void characters(char[] values, int param, int param2) 114 throws SAXException 115 { 116 if (contentHandler != null) 117 contentHandler.characters(values, param, param2); 118 } 119 120 public void processingInstruction(String str, String str1) 121 throws SAXException 122 { 123 if (contentHandler != null) 124 contentHandler.processingInstruction(str, str1); 125 } 126 127 public void endElement(String str, String str1, String str2) 128 throws SAXException 129 { 130 if (contentHandler != null) 131 contentHandler.endElement(str, str1, str2); 132 } 133 134 public void startPrefixMapping(String str, String str1) throws SAXException 135 { 136 if (contentHandler != null) 137 contentHandler.startPrefixMapping(str, str1); 138 } 139 140 public void ignorableWhitespace(char[] values, int param, int param2) 141 throws SAXException 142 { 143 if (contentHandler != null) 144 contentHandler.ignorableWhitespace(values, param, param2); 145 } 146 147 public void endPrefixMapping(String str) throws SAXException 148 { 149 if (contentHandler != null) 150 contentHandler.endPrefixMapping(str); 151 } 152 153 public void skippedEntity(String str) throws SAXException 154 { 155 if (contentHandler != null) 156 contentHandler.skippedEntity(str); 157 } 158 159 public void startDTD(String name, String publicId, String systemId) 163 throws SAXException 164 { 165 if (lexicalHandler != null) 166 lexicalHandler.startDTD(name, publicId, systemId); 167 } 168 169 public void endDTD() throws SAXException 170 { 171 if (lexicalHandler != null) 172 lexicalHandler.endDTD(); 173 } 174 175 public void startEntity(String name) throws SAXException 176 { 177 if (lexicalHandler != null) 178 lexicalHandler.startEntity(name); 179 } 180 181 public void endEntity(String name) throws SAXException 182 { 183 if (lexicalHandler != null) 184 lexicalHandler.endEntity(name); 185 } 186 187 public void startCDATA() throws SAXException 188 { 189 if (lexicalHandler != null) 190 lexicalHandler.startCDATA(); 191 } 192 193 public void endCDATA() throws SAXException 194 { 195 if (lexicalHandler != null) 196 lexicalHandler.endCDATA(); 197 } 198 199 public void comment(char ch[], int start, int length) throws SAXException 200 { 201 if (lexicalHandler != null) 202 lexicalHandler.comment(ch, start, length); 203 } 204 205 216 public void warning(SAXParseException e) 217 throws SAXException 218 { 219 if (errorHandler != null) 220 { 221 errorHandler.warning(e); 222 } 223 } 224 225 226 234 public void error(SAXParseException e) 235 throws SAXException 236 { 237 if (errorHandler != null) 238 { 239 errorHandler.error(e); 240 } 241 } 242 243 244 252 public void fatalError(SAXParseException e) 253 throws SAXException 254 { 255 if (errorHandler != null) 256 { 257 errorHandler.fatalError(e); 258 } 259 } 260 261 } 262 263 264 265 266 | Popular Tags |