77 78 //////////////////////////////////////////////////////////////////// 79 // Default implementation of the EntityResolver interface. 80 //////////////////////////////////////////////////////////////////// 81 82 /** 83 * Resolve an external entity. 84 * 85 * <p>Always return null, so that the parser will use the system 86 * identifier provided in the XML document. This method implements 87 * the SAX default behaviour: application writers can override it 88 * in a subclass to do special translations such as catalog lookups 89 * or URI redirection.</p> 90 * 91 * @param publicId The public identifier, or null if none is 92 * available. 93 * @param systemId The system identifier provided in the XML 94 * document. 95 * @return The new input source, or null to require the 96 * default behaviour. 97 * @exception java.io.IOException If there is an error setting 98 * up the new input source. 99 * @exception org.xml.sax.SAXException Any SAX exception, possibly 100 * wrapping another exception. 101 * @see org.xml.sax.EntityResolver#resolveEntity 102 */ 103 public InputSource resolveEntity (String publicId, String systemId) 104 throws IOException, SAXException 105 { 106 return null; 107 } 108 109 110 111 //////////////////////////////////////////////////////////////////// 112 // Default implementation of DTDHandler interface. 113 //////////////////////////////////////////////////////////////////// 114 115 116 /** 117 * Receive notification of a notation declaration. 118 * 119 * <p>By default, do nothing. Application writers may override this 120 * method in a subclass if they wish to keep track of the notations 121 * declared in a document.</p> 122 * 123 * @param name The notation name. 124 * @param publicId The notation public identifier, or null if not 125 * available. 126 * @param systemId The notation system identifier. 127 * @exception org.xml.sax.SAXException Any SAX exception, possibly 128 * wrapping another exception. 129 * @see org.xml.sax.DTDHandler#notationDecl 130 */ 131 public void notationDecl (String name, String publicId, String systemId) 132 throws SAXException 133 { 134 // no op 135 } 136 137 138 /** 139 * Receive notification of an unparsed entity declaration. 140 * 141 * <p>By default, do nothing. Application writers may override this 142 * method in a subclass to keep track of the unparsed entities 143 * declared in a document.</p> 144 * 145 * @param name The entity name. 146 * @param publicId The entity public identifier, or null if not 147 * available. 148 * @param systemId The entity system identifier. 149 * @param notationName The name of the associated notation. 150 * @exception org.xml.sax.SAXException Any SAX exception, possibly 151 * wrapping another exception. 152 * @see org.xml.sax.DTDHandler#unparsedEntityDecl 153 */ 154 public void unparsedEntityDecl (String name, String publicId, 155 String systemId, String notationName) 156 throws SAXException 157 { 158 // no op 159 } 160 161 162 163 //////////////////////////////////////////////////////////////////// 164 // Default implementation of ContentHandler interface. 165 //////////////////////////////////////////////////////////////////// 166 167 168 /** 169 * Receive a Locator object for document events. 170 * 171 * <p>By default, do nothing. Application writers may override this 172 * method in a subclass if they wish to store the locator for use 173 * with other document events.</p> 174 * 175 * @param locator A locator for all SAX document events. 176 * @see org.xml.sax.ContentHandler#setDocumentLocator 177 * @see org.xml.sax.Locator 178 */ 179 public void setDocumentLocator (Locator locator) 180 { 181 // no op 182 } 183 184 185 /** 186 * Receive notification of the beginning of the document. 187 * 188 * <p>By default, do nothing. Application writers may override this 189 * method in a subclass to take specific actions at the beginning 190 * of a document (such as allocating the root node of a tree or 191 * creating an output file).</p> 192 * 193 * @exception org.xml.sax.SAXException Any SAX exception, possibly 194 * wrapping another exception. 195 * @see org.xml.sax.ContentHandler#startDocument 196 */ 197 public void startDocument () 198 throws SAXException 199 { 200 // no op 201 } 202 203 204 /** 205 * Receive notification of the end of the document. 206 * 207 * <p>By default, do nothing. Application writers may override this 208 * method in a subclass to take specific actions at the end 209 * of a document (such as finalising a tree or closing an output 210 * file).</p> 211 * 212 * @exception org.xml.sax.SAXException Any SAX exception, possibly 213 * wrapping another exception. 214 * @see org.xml.sax.ContentHandler#endDocument 215 */ 216 public void endDocument () 217 throws SAXException 218 { 219 // no op 220 } 221 222 223 /** 224 * Receive notification of the start of a Namespace mapping. 225 * 226 * <p>By default, do nothing. Application writers may override this 227 * method in a subclass to take specific actions at the start of 228 * each Namespace prefix scope (such as storing the prefix mapping).</p> 229 * 230 * @param prefix The Namespace prefix being declared. 231 * @param uri The Namespace URI mapped to the prefix. 232 * @exception org.xml.sax.SAXException Any SAX exception, possibly 233 * wrapping another exception. 234 * @see org.xml.sax.ContentHandler#startPrefixMapping 235 */ 236 public void startPrefixMapping (String prefix, String uri) 237 throws SAXException 238 { 239 // no op 240 } 241 242 243 /** 244 * Receive notification of the end of a Namespace mapping. 245 * 246 * <p>By default, do nothing. Application writers may override this 247 * method in a subclass to take specific actions at the end of 248 * each prefix mapping.</p> 249 * 250 * @param prefix The Namespace prefix being declared. 251 * @exception org.xml.sax.SAXException Any SAX exception, possibly 252 * wrapping another exception. 253 * @see org.xml.sax.ContentHandler#endPrefixMapping 254 */ 255 public void endPrefixMapping (String prefix) 256 throws SAXException 257 { 258 // no op 259 } 260 261 262 /** 263 * Receive notification of the start of an element. 264 * 265 * <p>By default, do nothing. Application writers may override this 266 * method in a subclass to take specific actions at the start of 267 * each element (such as allocating a new tree node or writing 268 * output to a file).</p> 269 * 270 * @param uri The Namespace URI, or the empty string if the 271 * element has no Namespace URI or if Namespace 272 * processing is not being performed. 273 * @param localName The local name (without prefix), or the 274 * empty string if Namespace processing is not being 275 * performed. 276 * @param qName The qualified name (with prefix), or the 277 * empty string if qualified names are not available. 278 * @param attributes The attributes attached to the element. If 279 * there are no attributes, it shall be an empty 280 * Attributes object. 281 * @exception org.xml.sax.SAXException Any SAX exception, possibly 282 * wrapping another exception. 283 * @see org.xml.sax.ContentHandler#startElement 284 */ 285 public void startElement (String uri, String localName, 286 String qName, Attributes attributes) 287 throws SAXException 288 { 289 // no op 290 } 291 292 293 /** 294 * Receive notification of the end of an element. 295 * 296 * <p>By default, do nothing. Application writers may override this 297 * method in a subclass to take specific actions at the end of 298 * each element (such as finalising a tree node or writing 299 * output to a file).</p> 300 * 301 * @param uri The Namespace URI, or the empty string if the 302 * element has no Namespace URI or if Namespace 303 * processing is not being performed. 304 * @param localName The local name (without prefix), or the 305 * empty string if Namespace processing is not being 306 * performed. 307 * @param qName The qualified name (with prefix), or the 308 * empty string if qualified names are not available. 309 * @exception org.xml.sax.SAXException Any SAX exception, possibly 310 * wrapping another exception. 311 * @see org.xml.sax.ContentHandler#endElement 312 */ 313 public void endElement (String uri, String localName, String qName) 314 throws SAXException 315 { 316 // no op 317 } 318 319 320 /** 321 * Receive notification of character data inside an element. 322 * 323 * <p>By default, do nothing. Application writers may override this 324 * method to take specific actions for each chunk of character data 325 * (such as adding the data to a node or buffer, or printing it to 326 * a file).</p> 327 * 328 * @param ch The characters. 329 * @param start The start position in the character array. 330 * @param length The number of characters to use from the 331 * character array. 332 * @exception org.xml.sax.SAXException Any SAX exception, possibly 333 * wrapping another exception. 334 * @see org.xml.sax.ContentHandler#characters 335 */ 336 public void characters (char ch[], int start, int length) 337 throws SAXException 338 { 339 // no op 340 } 341 342 343 /** 344 * Receive notification of ignorable whitespace in element content. 345 * 346 * <p>By default, do nothing. Application writers may override this 347 * method to take specific actions for each chunk of ignorable 348 * whitespace (such as adding data to a node or buffer, or printing 349 * it to a file).</p> 350 * 351 * @param ch The whitespace characters. 352 * @param start The start position in the character array. 353 * @param length The number of characters to use from the 354 * character array. 355 * @exception org.xml.sax.SAXException Any SAX exception, possibly 356 * wrapping another exception. 357 * @see org.xml.sax.ContentHandler#ignorableWhitespace 358 */ 359 public void ignorableWhitespace (char ch[], int start, int length) 360 throws SAXException 361 { 362 // no op 363 } 364 365 366 /** 367 * Receive notification of a processing instruction. 368 * 369 * <p>By default, do nothing. Application writers may override this 370 * method in a subclass to take specific actions for each 371 * processing instruction, such as setting status variables or 372 * invoking other methods.</p> 373 * 374 * @param target The processing instruction target. 375 * @param data The processing instruction data, or null if 376 * none is supplied. 377 * @exception org.xml.sax.SAXException Any SAX exception, possibly 378 * wrapping another exception. 379 * @see org.xml.sax.ContentHandler#processingInstruction 380 */ 381 public void processingInstruction (String target, String data) 382 throws SAXException 383 { 384 // no op 385 } 386 387 388 /** 389 * Receive notification of a skipped entity. 390 * 391 * <p>By default, do nothing. Application writers may override this 392 * method in a subclass to take specific actions for each 393 * processing instruction, such as setting status variables or 394 * invoking other methods.</p> 395 * 396 * @param name The name of the skipped entity. 397 * @exception org.xml.sax.SAXException Any SAX exception, possibly 398 * wrapping another exception. 399 * @see org.xml.sax.ContentHandler#processingInstruction 400 */ 401 public void skippedEntity (String name) 402 throws SAXException 403 { 404 // no op 405 } 406 407 408 409 //////////////////////////////////////////////////////////////////// 410 // Default implementation of the ErrorHandler interface. 411 //////////////////////////////////////////////////////////////////// 412 413 414 /** 415 * Receive notification of a parser warning. 416 * 417 * <p>The default implementation does nothing. Application writers 418 * may override this method in a subclass to take specific actions 419 * for each warning, such as inserting the message in a log file or 420 * printing it to the console.</p> 421 * 422 * @param e The warning information encoded as an exception. 423 * @exception org.xml.sax.SAXException Any SAX exception, possibly 424 * wrapping another exception. 425 * @see org.xml.sax.ErrorHandler#warning 426 * @see org.xml.sax.SAXParseException 427 */ 428 public void warning (SAXParseException e) 429 throws SAXException 430 { 431 // no op 432 } 433 434 435 /** 436 * Receive notification of a recoverable parser error. 437 * 438 * <p>The default implementation does nothing. Application writers 439 * may override this method in a subclass to take specific actions 440 * for each error, such as inserting the message in a log file or 441 * printing it to the console.</p> 442 * 443 * @param e The error information encoded as an exception. 444 * @exception org.xml.sax.SAXException Any SAX exception, possibly 445 * wrapping another exception. 446 * @see org.xml.sax.ErrorHandler#warning 447 * @see org.xml.sax.SAXParseException 448 */ 449 public void error (SAXParseException e) 450 throws SAXException 451 { 452 // no op 453 } 454 455 456 /** 457 * Report a fatal XML parsing error. 458 * 459 * <p>The default implementation throws a SAXParseException. 460 * Application writers may override this method in a subclass if 461 * they need to take specific actions for each fatal error (such as 462 * collecting all of the errors into a single report): in any case, 463 * the application must stop all regular processing when this 464 * method is invoked, since the document is no longer reliable, and 465 * the parser may no longer report parsing events.</p> 466 * 467 * @param e The error information encoded as an exception. 468 * @exception org.xml.sax.SAXException Any SAX exception, possibly 469 * wrapping another exception. 470 * @see org.xml.sax.ErrorHandler#fatalError 471 * @see org.xml.sax.SAXParseException 472 */ 473 public void fatalError (SAXParseException e) 474 throws SAXException 475 { 476 throw e; 477 } 478 479 } 480 481 // end of DefaultHandler.java | 77 78 //////////////////////////////////////////////////////////////////// 79 // Default implementation of the EntityResolver interface. 80 //////////////////////////////////////////////////////////////////// 81 82 /** 83 * Resolve an external entity. 84 * 85 * <p>Always return null, so that the parser will use the system 86 * identifier provided in the XML document. This method implements 87 * the SAX default behaviour: application writers can override it 88 * in a subclass to do special translations such as catalog lookups 89 * or URI redirection.</p> 90 * 91 * @param publicId The public identifier, or null if none is 92 * available. 93 * @param systemId The system identifier provided in the XML 94 * document. 95 * @return The new input source, or null to require the 96 * default behaviour. 97 * @throws java.io.IOException If there is an error setting 98 * up the new input source. 99 * @throws org.xml.sax.SAXException Any SAX exception, possibly 100 * wrapping another exception. 101 * @see org.xml.sax.EntityResolver#resolveEntity 102 */ 103 @Override 104 public InputSource resolveEntity (String publicId, String systemId) 105 throws IOException, SAXException 106 { 107 return null; 108 } 109 110 111 112 //////////////////////////////////////////////////////////////////// 113 // Default implementation of DTDHandler interface. 114 //////////////////////////////////////////////////////////////////// 115 116 117 /** 118 * Receive notification of a notation declaration. 119 * 120 * <p>By default, do nothing. Application writers may override this 121 * method in a subclass if they wish to keep track of the notations 122 * declared in a document.</p> 123 * 124 * @param name The notation name. 125 * @param publicId The notation public identifier, or null if not 126 * available. 127 * @param systemId The notation system identifier. 128 * @throws org.xml.sax.SAXException Any SAX exception, possibly 129 * wrapping another exception. 130 * @see org.xml.sax.DTDHandler#notationDecl 131 */ 132 @Override 133 public void notationDecl (String name, String publicId, String systemId) 134 throws SAXException 135 { 136 // no op 137 } 138 139 140 /** 141 * Receive notification of an unparsed entity declaration. 142 * 143 * <p>By default, do nothing. Application writers may override this 144 * method in a subclass to keep track of the unparsed entities 145 * declared in a document.</p> 146 * 147 * @param name The entity name. 148 * @param publicId The entity public identifier, or null if not 149 * available. 150 * @param systemId The entity system identifier. 151 * @param notationName The name of the associated notation. 152 * @throws org.xml.sax.SAXException Any SAX exception, possibly 153 * wrapping another exception. 154 * @see org.xml.sax.DTDHandler#unparsedEntityDecl 155 */ 156 @Override 157 public void unparsedEntityDecl (String name, String publicId, 158 String systemId, String notationName) 159 throws SAXException 160 { 161 // no op 162 } 163 164 165 166 //////////////////////////////////////////////////////////////////// 167 // Default implementation of ContentHandler interface. 168 //////////////////////////////////////////////////////////////////// 169 170 171 /** 172 * Receive a Locator object for document events. 173 * 174 * <p>By default, do nothing. Application writers may override this 175 * method in a subclass if they wish to store the locator for use 176 * with other document events.</p> 177 * 178 * @param locator A locator for all SAX document events. 179 * @see org.xml.sax.ContentHandler#setDocumentLocator 180 * @see org.xml.sax.Locator 181 */ 182 @Override 183 public void setDocumentLocator (Locator locator) 184 { 185 // no op 186 } 187 188 189 /** 190 * Receive notification of the beginning of the document. 191 * 192 * <p>By default, do nothing. Application writers may override this 193 * method in a subclass to take specific actions at the beginning 194 * of a document (such as allocating the root node of a tree or 195 * creating an output file).</p> 196 * 197 * @throws org.xml.sax.SAXException Any SAX exception, possibly 198 * wrapping another exception. 199 * @see org.xml.sax.ContentHandler#startDocument 200 */ 201 @Override 202 public void startDocument () 203 throws SAXException 204 { 205 // no op 206 } 207 208 209 /** 210 * Receive notification of the end of the document. 211 * 212 * <p>By default, do nothing. Application writers may override this 213 * method in a subclass to take specific actions at the end 214 * of a document (such as finalising a tree or closing an output 215 * file).</p> 216 * 217 * @throws org.xml.sax.SAXException Any SAX exception, possibly 218 * wrapping another exception. 219 * @see org.xml.sax.ContentHandler#endDocument 220 */ 221 @Override 222 public void endDocument () 223 throws SAXException 224 { 225 // no op 226 } 227 228 229 /** 230 * Receive notification of the start of a Namespace mapping. 231 * 232 * <p>By default, do nothing. Application writers may override this 233 * method in a subclass to take specific actions at the start of 234 * each Namespace prefix scope (such as storing the prefix mapping).</p> 235 * 236 * @param prefix The Namespace prefix being declared. 237 * @param uri The Namespace URI mapped to the prefix. 238 * @throws org.xml.sax.SAXException Any SAX exception, possibly 239 * wrapping another exception. 240 * @see org.xml.sax.ContentHandler#startPrefixMapping 241 */ 242 @Override 243 public void startPrefixMapping (String prefix, String uri) 244 throws SAXException 245 { 246 // no op 247 } 248 249 250 /** 251 * Receive notification of the end of a Namespace mapping. 252 * 253 * <p>By default, do nothing. Application writers may override this 254 * method in a subclass to take specific actions at the end of 255 * each prefix mapping.</p> 256 * 257 * @param prefix The Namespace prefix being declared. 258 * @throws org.xml.sax.SAXException Any SAX exception, possibly 259 * wrapping another exception. 260 * @see org.xml.sax.ContentHandler#endPrefixMapping 261 */ 262 @Override 263 public void endPrefixMapping (String prefix) 264 throws SAXException 265 { 266 // no op 267 } 268 269 270 /** 271 * Receive notification of the start of an element. 272 * 273 * <p>By default, do nothing. Application writers may override this 274 * method in a subclass to take specific actions at the start of 275 * each element (such as allocating a new tree node or writing 276 * output to a file).</p> 277 * 278 * @param uri The Namespace URI, or the empty string if the 279 * element has no Namespace URI or if Namespace 280 * processing is not being performed. 281 * @param localName The local name (without prefix), or the 282 * empty string if Namespace processing is not being 283 * performed. 284 * @param qName The qualified name (with prefix), or the 285 * empty string if qualified names are not available. 286 * @param attributes The attributes attached to the element. If 287 * there are no attributes, it shall be an empty 288 * Attributes object. 289 * @throws org.xml.sax.SAXException Any SAX exception, possibly 290 * wrapping another exception. 291 * @see org.xml.sax.ContentHandler#startElement 292 */ 293 @Override 294 public void startElement (String uri, String localName, 295 String qName, Attributes attributes) 296 throws SAXException 297 { 298 // no op 299 } 300 301 302 /** 303 * Receive notification of the end of an element. 304 * 305 * <p>By default, do nothing. Application writers may override this 306 * method in a subclass to take specific actions at the end of 307 * each element (such as finalising a tree node or writing 308 * output to a file).</p> 309 * 310 * @param uri The Namespace URI, or the empty string if the 311 * element has no Namespace URI or if Namespace 312 * processing is not being performed. 313 * @param localName The local name (without prefix), or the 314 * empty string if Namespace processing is not being 315 * performed. 316 * @param qName The qualified name (with prefix), or the 317 * empty string if qualified names are not available. 318 * @throws org.xml.sax.SAXException Any SAX exception, possibly 319 * wrapping another exception. 320 * @see org.xml.sax.ContentHandler#endElement 321 */ 322 @Override 323 public void endElement (String uri, String localName, String qName) 324 throws SAXException 325 { 326 // no op 327 } 328 329 330 /** 331 * Receive notification of character data inside an element. 332 * 333 * <p>By default, do nothing. Application writers may override this 334 * method to take specific actions for each chunk of character data 335 * (such as adding the data to a node or buffer, or printing it to 336 * a file).</p> 337 * 338 * @param ch The characters. 339 * @param start The start position in the character array. 340 * @param length The number of characters to use from the 341 * character array. 342 * @throws org.xml.sax.SAXException Any SAX exception, possibly 343 * wrapping another exception. 344 * @see org.xml.sax.ContentHandler#characters 345 */ 346 @Override 347 public void characters (char ch[], int start, int length) 348 throws SAXException 349 { 350 // no op 351 } 352 353 354 /** 355 * Receive notification of ignorable whitespace in element content. 356 * 357 * <p>By default, do nothing. Application writers may override this 358 * method to take specific actions for each chunk of ignorable 359 * whitespace (such as adding data to a node or buffer, or printing 360 * it to a file).</p> 361 * 362 * @param ch The whitespace characters. 363 * @param start The start position in the character array. 364 * @param length The number of characters to use from the 365 * character array. 366 * @throws org.xml.sax.SAXException Any SAX exception, possibly 367 * wrapping another exception. 368 * @see org.xml.sax.ContentHandler#ignorableWhitespace 369 */ 370 @Override 371 public void ignorableWhitespace (char ch[], int start, int length) 372 throws SAXException 373 { 374 // no op 375 } 376 377 378 /** 379 * Receive notification of a processing instruction. 380 * 381 * <p>By default, do nothing. Application writers may override this 382 * method in a subclass to take specific actions for each 383 * processing instruction, such as setting status variables or 384 * invoking other methods.</p> 385 * 386 * @param target The processing instruction target. 387 * @param data The processing instruction data, or null if 388 * none is supplied. 389 * @throws org.xml.sax.SAXException Any SAX exception, possibly 390 * wrapping another exception. 391 * @see org.xml.sax.ContentHandler#processingInstruction 392 */ 393 @Override 394 public void processingInstruction (String target, String data) 395 throws SAXException 396 { 397 // no op 398 } 399 400 401 /** 402 * Receive notification of a skipped entity. 403 * 404 * <p>By default, do nothing. Application writers may override this 405 * method in a subclass to take specific actions for each 406 * processing instruction, such as setting status variables or 407 * invoking other methods.</p> 408 * 409 * @param name The name of the skipped entity. 410 * @throws org.xml.sax.SAXException Any SAX exception, possibly 411 * wrapping another exception. 412 * @see org.xml.sax.ContentHandler#processingInstruction 413 */ 414 @Override 415 public void skippedEntity (String name) 416 throws SAXException 417 { 418 // no op 419 } 420 421 422 423 //////////////////////////////////////////////////////////////////// 424 // Default implementation of the ErrorHandler interface. 425 //////////////////////////////////////////////////////////////////// 426 427 428 /** 429 * Receive notification of a parser warning. 430 * 431 * <p>The default implementation does nothing. Application writers 432 * may override this method in a subclass to take specific actions 433 * for each warning, such as inserting the message in a log file or 434 * printing it to the console.</p> 435 * 436 * @param e The warning information encoded as an exception. 437 * @throws org.xml.sax.SAXException Any SAX exception, possibly 438 * wrapping another exception. 439 * @see org.xml.sax.ErrorHandler#warning 440 * @see org.xml.sax.SAXParseException 441 */ 442 @Override 443 public void warning (SAXParseException e) 444 throws SAXException 445 { 446 // no op 447 } 448 449 450 /** 451 * Receive notification of a recoverable parser error. 452 * 453 * <p>The default implementation does nothing. Application writers 454 * may override this method in a subclass to take specific actions 455 * for each error, such as inserting the message in a log file or 456 * printing it to the console.</p> 457 * 458 * @param e The error information encoded as an exception. 459 * @throws org.xml.sax.SAXException Any SAX exception, possibly 460 * wrapping another exception. 461 * @see org.xml.sax.ErrorHandler#warning 462 * @see org.xml.sax.SAXParseException 463 */ 464 @Override 465 public void error (SAXParseException e) 466 throws SAXException 467 { 468 // no op 469 } 470 471 472 /** 473 * Report a fatal XML parsing error. 474 * 475 * <p>The default implementation throws a SAXParseException. 476 * Application writers may override this method in a subclass if 477 * they need to take specific actions for each fatal error (such as 478 * collecting all of the errors into a single report): in any case, 479 * the application must stop all regular processing when this 480 * method is invoked, since the document is no longer reliable, and 481 * the parser may no longer report parsing events.</p> 482 * 483 * @param e The error information encoded as an exception. 484 * @throws org.xml.sax.SAXException Any SAX exception, possibly 485 * wrapping another exception. 486 * @see org.xml.sax.ErrorHandler#fatalError 487 * @see org.xml.sax.SAXParseException 488 */ 489 @Override 490 public void fatalError (SAXParseException e) 491 throws SAXException 492 { 493 throw e; 494 } 495 496 } 497 498 // end of DefaultHandler.java |