package uk.ac.vamsas.objects; import uk.ac.vamsas.client.IClientDocument; import uk.ac.vamsas.objects.core.*; /** * Implements a depth first traversal over the document tree calling update handlers based on the Vobject.isUpdated() and Vobject.isNewInDocument() state at each backtrack. * @author JimP * */ public class DocumentUpdaterEngine { private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(DocumentUpdaterEngine.class); private IDocumentUpdater handler; /** * initialise the engine with an implementation * of the interface. * @param hander */ public DocumentUpdaterEngine(IDocumentUpdater handler) { super(); this.handler = handler; } /** * call the necessary update handlers at * each point on the VamsasDocument OM * TODO: later: Make this more elegant (use reflection and factor to single update(Object) method) ? * - we take the plodding, explicit approach rather than a funky generalised one here */ public void callHandlers(IClientDocument cdoc) { if (cdoc==null) { log.debug("Null IClientDocument instance."); return; } VAMSAS[] roots = cdoc.getVamsasRoots(); if (roots!=null) { for (int r=0; r