*/
-public abstract class ElementHandler {
-
+public interface ElementHandler {
+
/**
- * Called when an opening element is encountered. Returns the handler that will handle
- * the elements within that element, or null
if the element and all of
- * its contents is to be ignored.
+ * Called when an opening tag of a contained element is encountered. Returns the handler
+ * that will handle the elements within that element, or null
if the element
+ * and all of its contents is to be ignored.
*
* Note that this method may also return this
, in which case this
* handler will also handle the subelement.
@@ -52,43 +44,29 @@ public abstract class ElementHandler {
* @return the handler that handles elements encountered within this element,
* or null
if the element is to be ignored.
*/
- public abstract ElementHandler openElement(String element,
- HashMap attributes, WarningSet warnings) throws SAXException;
-
+ public ElementHandler openElement(String element, HashMap attributes,
+ WarningSet warnings) throws SAXException;
+
/**
- * Called when an element is closed. The default implementation checks whether there is
- * any non-space text within the element and if there exists any attributes, and adds
- * a warning of both. This can be used at the and of the method to check for
- * spurious data.
+ * Called when a closing tag of a contained element is encountered.
+ *
+ * This method can be used to handle the textual content of the element for simple text
+ * elements, which is passed in as the "content" parameter.
*
* @param element the element name.
* @param attributes attributes of the element.
* @param content the textual content of the element.
* @param warnings the warning set to store warnings in.
*/
- public void closeElement(String element, HashMap attributes,
- String content, WarningSet warnings) throws SAXException {
-
- if (!content.trim().equals("")) {
- warnings.add(Warning.fromString("Unknown text in element '" + element
- + "', ignoring."));
- }
- if (!attributes.isEmpty()) {
- warnings.add(Warning.fromString("Unknown attributes in element '" + element
- + "', ignoring."));
- }
- }
-
+ public abstract void closeElement(String element, HashMap attributes,
+ String content, WarningSet warnings) throws SAXException;
/**
- * Called when the element block that this handler is handling ends.
- * The default implementation is a no-op.
+ * Called when the current element that this handler is handling is closed.
*
* @param warnings the warning set to store warnings in.
*/
- public void endHandler(String element, HashMap attributes,
- String content, WarningSet warnings) throws SAXException {
- // No-op
- }
+ public abstract void endHandler(String element, HashMap attributes,
+ String content, WarningSet warnings) throws SAXException;
-}
+}
\ No newline at end of file