X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=core%2Fsrc%2Fnet%2Fsf%2Fopenrocket%2Ffile%2Fsimplesax%2FElementHandler.java;h=cdbbe1d6187dadef53638464274d6dd00e9d1e31;hb=2a3bbf5b9e7d253dd915ae565488de7abda0d475;hp=ae678f80bb43915398ad72f377a9b8a649ee55f4;hpb=8654c7d5a9d56274a296500d40c7f74229cdf6f1;p=debian%2Fopenrocket diff --git a/core/src/net/sf/openrocket/file/simplesax/ElementHandler.java b/core/src/net/sf/openrocket/file/simplesax/ElementHandler.java index ae678f80..cdbbe1d6 100644 --- a/core/src/net/sf/openrocket/file/simplesax/ElementHandler.java +++ b/core/src/net/sf/openrocket/file/simplesax/ElementHandler.java @@ -2,7 +2,6 @@ package net.sf.openrocket.file.simplesax; import java.util.HashMap; -import net.sf.openrocket.aerodynamics.Warning; import net.sf.openrocket.aerodynamics.WarningSet; import org.xml.sax.SAXException; @@ -18,30 +17,23 @@ import org.xml.sax.SAXException; * * and the initial handler is initHandler, then the following methods will be called: * - * 1. initHandler.{@link #openElement(String, HashMap, WarningSet)} is called for - * the opening element , which returns fooHandler - * 2. fooHandler.{@link #openElement(String, HashMap, WarningSet)} is called for - * the opening element , which returns barHandler - * 3. barHandler.{@link #endHandler(String, HashMap, String, WarningSet)} is called for - * the closing element - * 4. fooHandler.{@link #closeElement(String, HashMap, String, WarningSet)} is called for - * the closing element - * 5. fooHandler.{@link #endHandler(String, HashMap, String, WarningSet)} is called for - * the closing element - * 6. initHandler.{@link #closeElement(String, HashMap, String, WarningSet)} is called for - * the closing element + * 1. initHandler.openElement(String, HashMap, WarningSet) is called for the opening element , which returns fooHandler + * 2. fooHandler.openElement(String, HashMap, WarningSet) is called for the opening element , which returns barHandler + * 3. barHandler.endHandler(String, HashMap, String, WarningSet) is called for the closing element + * 4. fooHandler.closeElement(String, HashMap, String, WarningSet) is called for the closing element + * 5. fooHandler.endHandler(String, HashMap, String, WarningSet) is called for the closing element + * 6. initHandler.closeElement(String, HashMap, String, WarningSet) is called for the closing element * - * Note that {@link #endHandler(String, HashMap, String, WarningSet)} is not called for - * the initial handler. + * Note that endHandler(String, HashMap, String, WarningSet) is not called for the initial handler. * * @author Sampo Niskanen */ -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