PageRenderTime 46ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/com/microstar/xml/HandlerBase.java

#
Java | 191 lines | 60 code | 19 blank | 112 comment | 0 complexity | f6978bbc76b5d45267cebd13f0c0a35f MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. // HandlerBase.java: Simple base class for AElfred processors.
  2. // NO WARRANTY! See README, and copyright below.
  3. // $Id: HandlerBase.java 3792 2001-09-02 05:37:43Z spestov $
  4. package com.microstar.xml;
  5. import com.microstar.xml.XmlHandler;
  6. import com.microstar.xml.XmlException;
  7. import java.io.Reader;
  8. /**
  9. * Convenience base class for AElfred handlers.
  10. * <p>This base class implements the XmlHandler interface with
  11. * (mostly empty) default handlers. You are not required to use this,
  12. * but if you need to handle only a few events, you might find
  13. * it convenient to extend this class rather than implementing
  14. * the entire interface. This example overrides only the
  15. * <code>charData</code> method, using the defaults for the others:
  16. * <pre>
  17. * import com.microstar.xml.HandlerBase;
  18. *
  19. * public class MyHandler extends HandlerBase {
  20. * public void charData (char ch[], int start, int length)
  21. * {
  22. * System.out.println("Data: " + new String (ch, start, length));
  23. * }
  24. * }
  25. * </pre>
  26. * <p>This class is optional, but if you use it, you must also
  27. * include the <code>XmlException</code> class.
  28. * <p>Do not extend this if you are using SAX; extend
  29. * <code>org.xml.sax.HandlerBase</code> instead.
  30. * @author Copyright (c) 1998 by Microstar Software Ltd.
  31. * @author written by David Megginson &lt;dmeggins@microstar.com&gt;
  32. * @version 1.1
  33. * @see XmlHandler
  34. * @see XmlException
  35. * @see org.xml.sax.HandlerBase
  36. */
  37. public class HandlerBase implements XmlHandler {
  38. /**
  39. * Handle the start of the document.
  40. * <p>The default implementation does nothing.
  41. * @see com.microstar.xml.XmlHandler#startDocument
  42. * @exception java.lang.Exception Derived methods may throw exceptions.
  43. */
  44. public void startDocument ()
  45. throws java.lang.Exception
  46. {
  47. }
  48. /**
  49. * Handle the end of the document.
  50. * <p>The default implementation does nothing.
  51. * @see com.microstar.xml.XmlHandler#endDocument
  52. * @exception java.lang.Exception Derived methods may throw exceptions.
  53. */
  54. public void endDocument ()
  55. throws java.lang.Exception
  56. {
  57. }
  58. /**
  59. * Resolve an external entity.
  60. * <p>The default implementation simply returns the supplied
  61. * system identifier.
  62. * @see com.microstar.xml.XmlHandler#resolveEntity
  63. * @exception java.lang.Exception Derived methods may throw exceptions.
  64. */
  65. public Object resolveEntity (String publicId, String systemId)
  66. throws java.lang.Exception
  67. {
  68. return null;
  69. }
  70. /**
  71. * Handle the start of an external entity.
  72. * <p>The default implementation does nothing.
  73. * @see com.microstar.xml.XmlHandler#startExternalEntity
  74. * @exception java.lang.Exception Derived methods may throw exceptions.
  75. */
  76. public void startExternalEntity (String systemId)
  77. throws java.lang.Exception
  78. {
  79. }
  80. /**
  81. * Handle the end of an external entity.
  82. * <p>The default implementation does nothing.
  83. * @see com.microstar.xml.XmlHandler#endExternalEntity
  84. * @exception java.lang.Exception Derived methods may throw exceptions.
  85. */
  86. public void endExternalEntity (String systemId)
  87. throws java.lang.Exception
  88. {
  89. }
  90. /**
  91. * Handle a document type declaration.
  92. * <p>The default implementation does nothing.
  93. * @see com.microstar.xml.XmlHandler#doctypeDecl
  94. * @exception java.lang.Exception Derived methods may throw exceptions.
  95. */
  96. public void doctypeDecl (String name, String publicId, String systemId)
  97. throws java.lang.Exception
  98. {
  99. }
  100. /**
  101. * Handle an attribute assignment.
  102. * <p>The default implementation does nothing.
  103. * @see com.microstar.xml.XmlHandler#attribute
  104. * @exception java.lang.Exception Derived methods may throw exceptions.
  105. */
  106. public void attribute (String aname, String value, boolean isSpecified)
  107. throws java.lang.Exception
  108. {
  109. }
  110. /**
  111. * Handle the start of an element.
  112. * <p>The default implementation does nothing.
  113. * @see com.microstar.xml.XmlHandler#startElement
  114. * @exception java.lang.Exception Derived methods may throw exceptions.
  115. */
  116. public void startElement (String elname)
  117. throws java.lang.Exception
  118. {
  119. }
  120. /**
  121. * Handle the end of an element.
  122. * <p>The default implementation does nothing.
  123. * @see com.microstar.xml.XmlHandler#endElement
  124. * @exception java.lang.Exception Derived methods may throw exceptions.
  125. */
  126. public void endElement (String elname)
  127. throws java.lang.Exception
  128. {
  129. }
  130. /**
  131. * Handle character data.
  132. * <p>The default implementation does nothing.
  133. * @see com.microstar.xml.XmlHandler#charData
  134. * @exception java.lang.Exception Derived methods may throw exceptions.
  135. */
  136. public void charData (char ch[], int start, int length)
  137. throws java.lang.Exception
  138. {
  139. }
  140. /**
  141. * Handle ignorable whitespace.
  142. * <p>The default implementation does nothing.
  143. * @see com.microstar.xml.XmlHandler#ignorableWhitespace
  144. * @exception java.lang.Exception Derived methods may throw exceptions.
  145. */
  146. public void ignorableWhitespace (char ch[], int start, int length)
  147. throws java.lang.Exception
  148. {
  149. }
  150. /**
  151. * Handle a processing instruction.
  152. * <p>The default implementation does nothing.
  153. * @see com.microstar.xml.XmlHandler#processingInstruction
  154. * @exception java.lang.Exception Derived methods may throw exceptions.
  155. */
  156. public void processingInstruction (String target, String data)
  157. throws java.lang.Exception
  158. {
  159. }
  160. /**
  161. * Throw an exception for a fatal error.
  162. * <p>The default implementation throws <code>XmlException</code>.
  163. * @see com.microstar.xml.XmlHandler#error
  164. * @exception com.microstar.xml.XmlException A specific parsing error.
  165. * @exception java.lang.Exception Derived methods may throw exceptions.
  166. */
  167. public void error (String message, String systemId, int line, int column)
  168. throws XmlException, java.lang.Exception
  169. {
  170. throw new XmlException(message, systemId, line, column);
  171. }
  172. }