1 package net.sf.openrocket.file.simplesax;
3 import java.util.HashMap;
5 import net.sf.openrocket.aerodynamics.WarningSet;
7 import org.xml.sax.SAXException;
11 * A "simple XML" element handler. An object of this class handles a single element of
12 * an XML file. If the input file is:
18 * and the initial handler is initHandler, then the following methods will be called:
20 * 1. initHandler.openElement(String, HashMap, WarningSet) is called for the opening element <foo>, which returns fooHandler
21 * 2. fooHandler.openElement(String, HashMap, WarningSet) is called for the opening element <bar>, which returns barHandler
22 * 3. barHandler.endHandler(String, HashMap, String, WarningSet) is called for the closing element </bar>
23 * 4. fooHandler.closeElement(String, HashMap, String, WarningSet) is called for the closing element </bar>
24 * 5. fooHandler.endHandler(String, HashMap, String, WarningSet) is called for the closing element </foo>
25 * 6. initHandler.closeElement(String, HashMap, String, WarningSet) is called for the closing element </foo>
27 * Note that endHandler(String, HashMap, String, WarningSet) is not called for the initial handler.
29 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
31 public interface ElementHandler {
34 * Called when an opening tag of a contained element is encountered. Returns the handler
35 * that will handle the elements within that element, or <code>null</code> if the element
36 * and all of its contents is to be ignored.
38 * Note that this method may also return <code>this</code>, in which case this
39 * handler will also handle the subelement.
41 * @param element the element name.
42 * @param attributes attributes of the element.
43 * @param warnings the warning set to store warnings in.
44 * @return the handler that handles elements encountered within this element,
45 * or <code>null</code> if the element is to be ignored.
47 public ElementHandler openElement(String element, HashMap<String, String> attributes,
48 WarningSet warnings) throws SAXException;
51 * Called when a closing tag of a contained element is encountered.
53 * This method can be used to handle the textual content of the element for simple text
54 * elements, which is passed in as the "content" parameter.
56 * @param element the element name.
57 * @param attributes attributes of the element.
58 * @param content the textual content of the element.
59 * @param warnings the warning set to store warnings in.
61 public abstract void closeElement(String element, HashMap<String, String> attributes,
62 String content, WarningSet warnings) throws SAXException;
65 * Called when the current element that this handler is handling is closed.
67 * @param warnings the warning set to store warnings in.
69 public abstract void endHandler(String element, HashMap<String, String> attributes,
70 String content, WarningSet warnings) throws SAXException;