/xmlrpc/vendor/xmlrpc-2.0/src/java/org/xml/sax/HandlerBase.java

https://gitlab.com/manoj-makkuboy/magnetism · Java · 352 lines · 66 code · 37 blank · 249 comment · 0 complexity · c2c428c334500e3f085eb07255486e1d MD5 · raw file

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