]> gerrit.simantics Code Review - simantics/interop.git/blobdiff - org.simantics.xml.sax.base/src/org/simantics/xml/sax/base/XMLElementParser.java
XML Schema converter
[simantics/interop.git] / org.simantics.xml.sax.base / src / org / simantics / xml / sax / base / XMLElementParser.java
diff --git a/org.simantics.xml.sax.base/src/org/simantics/xml/sax/base/XMLElementParser.java b/org.simantics.xml.sax.base/src/org/simantics/xml/sax/base/XMLElementParser.java
new file mode 100644 (file)
index 0000000..c3b3804
--- /dev/null
@@ -0,0 +1,75 @@
+package org.simantics.xml.sax.base;\r
+\r
+import java.util.Deque;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+public interface XMLElementParser {\r
+       /**\r
+        * ID of the element\r
+        * @return\r
+        */\r
+       public String getElementId();\r
+       \r
+       \r
+       /**\r
+        * Priority of the Id. Used with overlapping IDs to select preferred element. \r
+        */\r
+       public int idPriority();\r
+       \r
+       /**\r
+        * Creates a resource for the element.\r
+        * \r
+        *  Called on SAX.startElement\r
+        * @param graph\r
+        * @param element\r
+        * @return\r
+        * @throws DatabaseException\r
+        */\r
+       public Resource create(WriteGraph graph, Element element) throws DatabaseException;\r
+       /**\r
+        * Configures the element.\r
+        * \r
+        * Called on SAX.endElement\r
+        * @param graph\r
+        * @param parents\r
+        * @param element\r
+        * @throws DatabaseException\r
+        */\r
+       public void configure(WriteGraph graph, Deque<Element> parents, Element element) throws DatabaseException;\r
+       /**\r
+        * Configures element with characters content\r
+        * \r
+        * Called on SAX.charaters\r
+        * @param graph\r
+        * @param element\r
+        * @param string\r
+        * @throws DatabaseException\r
+        */\r
+       public void configure(WriteGraph graph, Element element, String string) throws DatabaseException;\r
+       \r
+       /**\r
+        * Adds child element. Primary method for connecting elements.\r
+        * @param graph\r
+        * @param element\r
+        * @param child\r
+        * @return true, if connection was done, otherwise return false.\r
+        * @throws DatabaseException\r
+        */\r
+       public abstract boolean connectChild(WriteGraph graph, Element element, Element child) throws DatabaseException;\r
+       /**\r
+        * Adds element to a parent. Secondary method for connecting elements. Called only if primary method fails.\r
+        * @param graph\r
+        * @param parent\r
+        * @param element\r
+        * @return true, if connection was done, otherwise return false.\r
+        * @throws DatabaseException\r
+        */\r
+       public abstract boolean connectParent(WriteGraph graph, Element parent, Element element) throws DatabaseException;\r
+       \r
+       \r
+       //public void configureChild(WriteGraph graph, Stack<Element> parents, Element element, Element child) throws DatabaseException;\r
+       public String getID();\r
+}
\ No newline at end of file