KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > microstar > xml > HandlerBase


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

5 package com.microstar.xml;
6
7 import com.microstar.xml.XmlHandler;
8 import com.microstar.xml.XmlException;
9 import java.io.Reader JavaDoc;
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   */

41 public 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 JavaDoc
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 JavaDoc
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 JavaDoc resolveEntity (String JavaDoc publicId, String JavaDoc systemId)
73     throws java.lang.Exception JavaDoc
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 JavaDoc systemId)
86     throws java.lang.Exception JavaDoc
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 JavaDoc systemId)
97     throws java.lang.Exception JavaDoc
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 JavaDoc name, String JavaDoc publicId, String JavaDoc systemId)
108     throws java.lang.Exception JavaDoc
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 JavaDoc aname, String JavaDoc value, boolean isSpecified)
119     throws java.lang.Exception JavaDoc
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 JavaDoc elname)
130     throws java.lang.Exception JavaDoc
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 JavaDoc elname)
141     throws java.lang.Exception JavaDoc
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 JavaDoc
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 JavaDoc
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 JavaDoc target, String JavaDoc data)
174     throws java.lang.Exception JavaDoc
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 JavaDoc message, String JavaDoc systemId, int line, int column)
186     throws XmlException, java.lang.Exception JavaDoc
187   {
188     throw new XmlException(message, systemId, line, column);
189   }
190
191 }
192
Popular Tags