PageRenderTime 47ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/PullParser2.1.10/src/java/apis/sax2/org/xml/sax/HandlerBase.java

#
Java | 370 lines | 65 code | 38 blank | 267 comment | 0 complexity | e152e13997b4d9613e8c627ad22a70fd MD5 | raw file
Possible License(s): IPL-1.0
  1. // SAX default handler base class.
  2. // http://www.saxproject.org
  3. // No warranty; no copyright -- use this as you will.
  4. // $Id: HandlerBase.java,v 1.1 2001/12/10 22:38:03 aslom Exp $
  5. package org.xml.sax;
  6. /**
  7. * Default base class for handlers.
  8. *
  9. * <blockquote>
  10. * <em>This module, both source code and documentation, is in the
  11. * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
  12. * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
  13. * for further information.
  14. * </blockquote>
  15. *
  16. * <p>This class implements the default behaviour for four SAX1
  17. * interfaces: EntityResolver, DTDHandler, DocumentHandler,
  18. * and ErrorHandler. It is now obsolete, but is included in SAX2 to
  19. * support legacy SAX1 applications. SAX2 applications should use
  20. * the {@link org.xml.sax.helpers.DefaultHandler DefaultHandler}
  21. * class instead.</p>
  22. *
  23. * <p>Application writers can extend this class when they need to
  24. * implement only part of an interface; parser writers can
  25. * instantiate this class to provide default handlers when the
  26. * application has not supplied its own.</p>
  27. *
  28. * <p>Note that the use of this class is optional.</p>
  29. *
  30. * @deprecated This class works with the deprecated
  31. * {@link org.xml.sax.DocumentHandler DocumentHandler}
  32. * interface. It has been replaced by the SAX2
  33. * {@link org.xml.sax.helpers.DefaultHandler DefaultHandler}
  34. * class.
  35. * @since SAX 1.0
  36. * @author David Megginson
  37. * @version 2.0r2pre3
  38. * @see org.xml.sax.EntityResolver
  39. * @see org.xml.sax.DTDHandler
  40. * @see org.xml.sax.DocumentHandler
  41. * @see org.xml.sax.ErrorHandler
  42. */
  43. public class HandlerBase
  44. implements EntityResolver, DTDHandler, DocumentHandler, ErrorHandler
  45. {
  46. ////////////////////////////////////////////////////////////////////
  47. // Default implementation of the EntityResolver interface.
  48. ////////////////////////////////////////////////////////////////////
  49. /**
  50. * Resolve an external entity.
  51. *
  52. * <p>Always return null, so that the parser will use the system
  53. * identifier provided in the XML document. This method implements
  54. * the SAX default behaviour: application writers can override it
  55. * in a subclass to do special translations such as catalog lookups
  56. * or URI redirection.</p>
  57. *
  58. * @param publicId The public identifer, or null if none is
  59. * available.
  60. * @param systemId The system identifier provided in the XML
  61. * document.
  62. * @return The new input source, or null to require the
  63. * default behaviour.
  64. * @exception org.xml.sax.SAXException Any SAX exception, possibly
  65. * wrapping another exception.
  66. * @see org.xml.sax.EntityResolver#resolveEntity
  67. */
  68. public InputSource resolveEntity (String publicId, String systemId)
  69. throws SAXException
  70. {
  71. return null;
  72. }
  73. ////////////////////////////////////////////////////////////////////
  74. // Default implementation of DTDHandler interface.
  75. ////////////////////////////////////////////////////////////////////
  76. /**
  77. * Receive notification of a notation declaration.
  78. *
  79. * <p>By default, do nothing. Application writers may override this
  80. * method in a subclass if they wish to keep track of the notations
  81. * declared in a document.</p>
  82. *
  83. * @param name The notation name.
  84. * @param publicId The notation public identifier, or null if not
  85. * available.
  86. * @param systemId The notation system identifier.
  87. * @see org.xml.sax.DTDHandler#notationDecl
  88. */
  89. public void notationDecl (String name, String publicId, String systemId)
  90. {
  91. // no op
  92. }
  93. /**
  94. * Receive notification of an unparsed entity declaration.
  95. *
  96. * <p>By default, do nothing. Application writers may override this
  97. * method in a subclass to keep track of the unparsed entities
  98. * declared in a document.</p>
  99. *
  100. * @param name The entity name.
  101. * @param publicId The entity public identifier, or null if not
  102. * available.
  103. * @param systemId The entity system identifier.
  104. * @param notationName The name of the associated notation.
  105. * @see org.xml.sax.DTDHandler#unparsedEntityDecl
  106. */
  107. public void unparsedEntityDecl (String name, String publicId,
  108. String systemId, String notationName)
  109. {
  110. // no op
  111. }
  112. ////////////////////////////////////////////////////////////////////
  113. // Default implementation of DocumentHandler interface.
  114. ////////////////////////////////////////////////////////////////////
  115. /**
  116. * Receive a Locator object for document events.
  117. *
  118. * <p>By default, do nothing. Application writers may override this
  119. * method in a subclass if they wish to store the locator for use
  120. * with other document events.</p>
  121. *
  122. * @param locator A locator for all SAX document events.
  123. * @see org.xml.sax.DocumentHandler#setDocumentLocator
  124. * @see org.xml.sax.Locator
  125. */
  126. public void setDocumentLocator (Locator locator)
  127. {
  128. // no op
  129. }
  130. /**
  131. * Receive notification of the beginning of the document.
  132. *
  133. * <p>By default, do nothing. Application writers may override this
  134. * method in a subclass to take specific actions at the beginning
  135. * of a document (such as allocating the root node of a tree or
  136. * creating an output file).</p>
  137. *
  138. * @exception org.xml.sax.SAXException Any SAX exception, possibly
  139. * wrapping another exception.
  140. * @see org.xml.sax.DocumentHandler#startDocument
  141. */
  142. public void startDocument ()
  143. throws SAXException
  144. {
  145. // no op
  146. }
  147. /**
  148. * Receive notification of the end of the document.
  149. *
  150. * <p>By default, do nothing. Application writers may override this
  151. * method in a subclass to take specific actions at the beginning
  152. * of a document (such as finalising a tree or closing an output
  153. * file).</p>
  154. *
  155. * @exception org.xml.sax.SAXException Any SAX exception, possibly
  156. * wrapping another exception.
  157. * @see org.xml.sax.DocumentHandler#endDocument
  158. */
  159. public void endDocument ()
  160. throws SAXException
  161. {
  162. // no op
  163. }
  164. /**
  165. * Receive notification of the start of an element.
  166. *
  167. * <p>By default, do nothing. Application writers may override this
  168. * method in a subclass to take specific actions at the start of
  169. * each element (such as allocating a new tree node or writing
  170. * output to a file).</p>
  171. *
  172. * @param name The element type name.
  173. * @param attributes The specified or defaulted attributes.
  174. * @exception org.xml.sax.SAXException Any SAX exception, possibly
  175. * wrapping another exception.
  176. * @see org.xml.sax.DocumentHandler#startElement
  177. */
  178. public void startElement (String name, AttributeList attributes)
  179. throws SAXException
  180. {
  181. // no op
  182. }
  183. /**
  184. * Receive notification of the end of an element.
  185. *
  186. * <p>By default, do nothing. Application writers may override this
  187. * method in a subclass to take specific actions at the end of
  188. * each element (such as finalising a tree node or writing
  189. * output to a file).</p>
  190. *
  191. * @param name The element type name.
  192. * @param attributes The specified or defaulted attributes.
  193. * @exception org.xml.sax.SAXException Any SAX exception, possibly
  194. * wrapping another exception.
  195. * @see org.xml.sax.DocumentHandler#endElement
  196. */
  197. public void endElement (String name)
  198. throws SAXException
  199. {
  200. // no op
  201. }
  202. /**
  203. * Receive notification of character data inside an element.
  204. *
  205. * <p>By default, do nothing. Application writers may override this
  206. * method to take specific actions for each chunk of character data
  207. * (such as adding the data to a node or buffer, or printing it to
  208. * a file).</p>
  209. *
  210. * @param ch The characters.
  211. * @param start The start position in the character array.
  212. * @param length The number of characters to use from the
  213. * character array.
  214. * @exception org.xml.sax.SAXException Any SAX exception, possibly
  215. * wrapping another exception.
  216. * @see org.xml.sax.DocumentHandler#characters
  217. */
  218. public void characters (char ch[], int start, int length)
  219. throws SAXException
  220. {
  221. // no op
  222. }
  223. /**
  224. * Receive notification of ignorable whitespace in element content.
  225. *
  226. * <p>By default, do nothing. Application writers may override this
  227. * method to take specific actions for each chunk of ignorable
  228. * whitespace (such as adding data to a node or buffer, or printing
  229. * it to a file).</p>
  230. *
  231. * @param ch The whitespace characters.
  232. * @param start The start position in the character array.
  233. * @param length The number of characters to use from the
  234. * character array.
  235. * @exception org.xml.sax.SAXException Any SAX exception, possibly
  236. * wrapping another exception.
  237. * @see org.xml.sax.DocumentHandler#ignorableWhitespace
  238. */
  239. public void ignorableWhitespace (char ch[], int start, int length)
  240. throws SAXException
  241. {
  242. // no op
  243. }
  244. /**
  245. * Receive notification of a processing instruction.
  246. *
  247. * <p>By default, do nothing. Application writers may override this
  248. * method in a subclass to take specific actions for each
  249. * processing instruction, such as setting status variables or
  250. * invoking other methods.</p>
  251. *
  252. * @param target The processing instruction target.
  253. * @param data The processing instruction data, or null if
  254. * none is supplied.
  255. * @exception org.xml.sax.SAXException Any SAX exception, possibly
  256. * wrapping another exception.
  257. * @see org.xml.sax.DocumentHandler#processingInstruction
  258. */
  259. public void processingInstruction (String target, String data)
  260. throws SAXException
  261. {
  262. // no op
  263. }
  264. ////////////////////////////////////////////////////////////////////
  265. // Default implementation of the ErrorHandler interface.
  266. ////////////////////////////////////////////////////////////////////
  267. /**
  268. * Receive notification of a parser warning.
  269. *
  270. * <p>The default implementation does nothing. Application writers
  271. * may override this method in a subclass to take specific actions
  272. * for each warning, such as inserting the message in a log file or
  273. * printing it to the console.</p>
  274. *
  275. * @param e The warning information encoded as an exception.
  276. * @exception org.xml.sax.SAXException Any SAX exception, possibly
  277. * wrapping another exception.
  278. * @see org.xml.sax.ErrorHandler#warning
  279. * @see org.xml.sax.SAXParseException
  280. */
  281. public void warning (SAXParseException e)
  282. throws SAXException
  283. {
  284. // no op
  285. }
  286. /**
  287. * Receive notification of a recoverable parser error.
  288. *
  289. * <p>The default implementation does nothing. Application writers
  290. * may override this method in a subclass to take specific actions
  291. * for each error, such as inserting the message in a log file or
  292. * printing it to the console.</p>
  293. *
  294. * @param e The warning information encoded as an exception.
  295. * @exception org.xml.sax.SAXException Any SAX exception, possibly
  296. * wrapping another exception.
  297. * @see org.xml.sax.ErrorHandler#warning
  298. * @see org.xml.sax.SAXParseException
  299. */
  300. public void error (SAXParseException e)
  301. throws SAXException
  302. {
  303. // no op
  304. }
  305. /**
  306. * Report a fatal XML parsing error.
  307. *
  308. * <p>The default implementation throws a SAXParseException.
  309. * Application writers may override this method in a subclass if
  310. * they need to take specific actions for each fatal error (such as
  311. * collecting all of the errors into a single report): in any case,
  312. * the application must stop all regular processing when this
  313. * method is invoked, since the document is no longer reliable, and
  314. * the parser may no longer report parsing events.</p>
  315. *
  316. * @param e The error information encoded as an exception.
  317. * @exception org.xml.sax.SAXException Any SAX exception, possibly
  318. * wrapping another exception.
  319. * @see org.xml.sax.ErrorHandler#fatalError
  320. * @see org.xml.sax.SAXParseException
  321. */
  322. public void fatalError (SAXParseException e)
  323. throws SAXException
  324. {
  325. throw e;
  326. }
  327. }
  328. // end of HandlerBase.java