PageRenderTime 57ms CodeModel.GetById 51ms app.highlight 4ms RepoModel.GetById 0ms app.codeStats 1ms

/jEdit/tags/jedit-4-2-pre4/com/microstar/xml/HandlerBase.java

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