]> gerrit.simantics Code Review - simantics/interop.git/blob - org.simantics.xml.sax.base/src/org/simantics/xml/sax/base/XMLElementParser.java
Initial support for XML export (order of Elements is not kept)
[simantics/interop.git] / org.simantics.xml.sax.base / src / org / simantics / xml / sax / base / XMLElementParser.java
1 package org.simantics.xml.sax.base;\r
2 \r
3 import java.util.Deque;\r
4 \r
5 import org.simantics.db.Resource;\r
6 import org.simantics.db.WriteGraph;\r
7 import org.simantics.db.exception.DatabaseException;\r
8 \r
9 public interface XMLElementParser {\r
10         /**\r
11          * ID of the element\r
12          * @return\r
13          */\r
14         public String getElementId();\r
15         \r
16         \r
17         /**\r
18          * Priority of the Id. Used with overlapping IDs to select preferred element. \r
19          */\r
20         public int idPriority();\r
21         \r
22         /**\r
23          * Creates a resource for the element.\r
24          * \r
25          *  Called on SAX.startElement\r
26          * @param graph\r
27          * @param element\r
28          * @return\r
29          * @throws DatabaseException\r
30          */\r
31         public Resource create(WriteGraph graph, ParserElement element) throws DatabaseException;\r
32         /**\r
33          * Configures the element.\r
34          * \r
35          * Called on SAX.endElement\r
36          * @param graph\r
37          * @param parents\r
38          * @param element\r
39          * @throws DatabaseException\r
40          */\r
41         public void configure(WriteGraph graph, Deque<ParserElement> parents, ParserElement element) throws DatabaseException;\r
42         /**\r
43          * Configures element with characters content\r
44          * \r
45          * Called on SAX.charaters\r
46          * @param graph\r
47          * @param element\r
48          * @param string\r
49          * @throws DatabaseException\r
50          */\r
51         public void configure(WriteGraph graph, ParserElement element, String string) throws DatabaseException;\r
52         \r
53         /**\r
54          * Adds child element. Primary method for connecting elements.\r
55          * @param graph\r
56          * @param element\r
57          * @param child\r
58          * @return true, if connection was done, otherwise return false.\r
59          * @throws DatabaseException\r
60          */\r
61         public abstract boolean connectChild(WriteGraph graph, ParserElement element, ParserElement child) throws DatabaseException;\r
62         /**\r
63          * Adds element to a parent. Secondary method for connecting elements. Called only if primary method fails.\r
64          * @param graph\r
65          * @param parent\r
66          * @param element\r
67          * @return true, if connection was done, otherwise return false.\r
68          * @throws DatabaseException\r
69          */\r
70         public abstract boolean connectParent(WriteGraph graph, ParserElement parent, ParserElement element) throws DatabaseException;\r
71         \r
72         \r
73         //public void configureChild(WriteGraph graph, Stack<Element> parents, Element element, Element child) throws DatabaseException;\r
74         public String getID();\r
75 }