X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.xml.sax.base%2Fsrc%2Forg%2Fsimantics%2Fxml%2Fsax%2Fbase%2FXMLElementParser.java;fp=org.simantics.xml.sax.base%2Fsrc%2Forg%2Fsimantics%2Fxml%2Fsax%2Fbase%2FXMLElementParser.java;h=c3b380401db4a8744b6d1da5e841923e779990c0;hb=ada38ab0a1a98dcb413bef3273064da36ce2d273;hp=0000000000000000000000000000000000000000;hpb=db6def39515fd442543064502a9ae7ae07ffc160;p=simantics%2Finterop.git 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 index 0000000..c3b3804 --- /dev/null +++ b/org.simantics.xml.sax.base/src/org/simantics/xml/sax/base/XMLElementParser.java @@ -0,0 +1,75 @@ +package org.simantics.xml.sax.base; + +import java.util.Deque; + +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.exception.DatabaseException; + +public interface XMLElementParser { + /** + * ID of the element + * @return + */ + public String getElementId(); + + + /** + * Priority of the Id. Used with overlapping IDs to select preferred element. + */ + public int idPriority(); + + /** + * Creates a resource for the element. + * + * Called on SAX.startElement + * @param graph + * @param element + * @return + * @throws DatabaseException + */ + public Resource create(WriteGraph graph, Element element) throws DatabaseException; + /** + * Configures the element. + * + * Called on SAX.endElement + * @param graph + * @param parents + * @param element + * @throws DatabaseException + */ + public void configure(WriteGraph graph, Deque parents, Element element) throws DatabaseException; + /** + * Configures element with characters content + * + * Called on SAX.charaters + * @param graph + * @param element + * @param string + * @throws DatabaseException + */ + public void configure(WriteGraph graph, Element element, String string) throws DatabaseException; + + /** + * Adds child element. Primary method for connecting elements. + * @param graph + * @param element + * @param child + * @return true, if connection was done, otherwise return false. + * @throws DatabaseException + */ + public abstract boolean connectChild(WriteGraph graph, Element element, Element child) throws DatabaseException; + /** + * Adds element to a parent. Secondary method for connecting elements. Called only if primary method fails. + * @param graph + * @param parent + * @param element + * @return true, if connection was done, otherwise return false. + * @throws DatabaseException + */ + public abstract boolean connectParent(WriteGraph graph, Element parent, Element element) throws DatabaseException; + + + //public void configureChild(WriteGraph graph, Stack parents, Element element, Element child) throws DatabaseException; + public String getID(); +} \ No newline at end of file