X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fuk%2Fac%2Fvamsas%2Fobjects%2FDocumentUpdaterEngine.java;h=cb2d2c36c8cec1c73f8ba80e21eb102b8e22994f;hb=6badd7bce3bb217f0b32e3872da900a935d7daa3;hp=370fcc82a37d7022c3c8b6340e8a0224c80eafbc;hpb=22724ef036aa4c1c6496b2d07b99d1f07061b7d2;p=vamsas.git diff --git a/src/uk/ac/vamsas/objects/DocumentUpdaterEngine.java b/src/uk/ac/vamsas/objects/DocumentUpdaterEngine.java index 370fcc8..cb2d2c3 100644 --- a/src/uk/ac/vamsas/objects/DocumentUpdaterEngine.java +++ b/src/uk/ac/vamsas/objects/DocumentUpdaterEngine.java @@ -1,25 +1,143 @@ 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 IDocumentUpdater hander; + 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 hander) { + public DocumentUpdaterEngine(IDocumentUpdater handler) { super(); - this.hander = hander; + 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) { - // TODO: walk down the hierarchy until we find an update and call the handler for it. + if (cdoc==null) { + log.debug("Null IClientDocument instance."); + return; + } + VAMSAS[] roots = cdoc.getVamsasRoots(); + if (roots!=null) { + for (int r=0; r