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, ParserElement 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, ParserElement 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, ParserElement 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, ParserElement element, ParserElement 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, ParserElement parent, ParserElement element) throws DatabaseException; //public void configureChild(WriteGraph graph, Stack parents, Element element, Element child) throws DatabaseException; public String getID(); }