1 package org.simantics.xml.sax.base;
\r
3 import java.util.Deque;
\r
5 import org.simantics.db.Resource;
\r
6 import org.simantics.db.WriteGraph;
\r
7 import org.simantics.db.exception.DatabaseException;
\r
9 public interface XMLElementParser {
\r
14 public String getElementId();
\r
18 * Priority of the Id. Used with overlapping IDs to select preferred element.
\r
20 public int idPriority();
\r
23 * Creates a resource for the element.
\r
25 * Called on SAX.startElement
\r
29 * @throws DatabaseException
\r
31 public Resource create(WriteGraph graph, ParserElement element) throws DatabaseException;
\r
33 * Configures the element.
\r
35 * Called on SAX.endElement
\r
39 * @throws DatabaseException
\r
41 public void configure(WriteGraph graph, Deque<ParserElement> parents, ParserElement element) throws DatabaseException;
\r
43 * Configures element with characters content
\r
45 * Called on SAX.charaters
\r
49 * @throws DatabaseException
\r
51 public void configure(WriteGraph graph, ParserElement element, String string) throws DatabaseException;
\r
54 * Adds child element. Primary method for connecting elements.
\r
58 * @return true, if connection was done, otherwise return false.
\r
59 * @throws DatabaseException
\r
61 public abstract boolean connectChild(WriteGraph graph, ParserElement element, ParserElement child) throws DatabaseException;
\r
63 * Adds element to a parent. Secondary method for connecting elements. Called only if primary method fails.
\r
67 * @return true, if connection was done, otherwise return false.
\r
68 * @throws DatabaseException
\r
70 public abstract boolean connectParent(WriteGraph graph, ParserElement parent, ParserElement element) throws DatabaseException;
\r
73 //public void configureChild(WriteGraph graph, Stack<Element> parents, Element element, Element child) throws DatabaseException;
\r
74 public String getID();
\r