VisClient/org/hfbk/vis/ScriptRouter.java

Go to the documentation of this file.
00001 package org.hfbk.vis;
00002 
00003 import org.hfbk.util.Scripter;
00004 import org.hfbk.util.Scripter.ScriptFunction;
00005 
00038 public class ScriptRouter {
00039         
00040         Scripter engine;
00041         
00042         String currentRoutes;
00043         
00044         VisClient client;
00045         
00049         public ScriptRouter(VisClient client) {
00050                 this.client=client;             
00051                 updateRoutes();
00052         }
00053         
00057         public void updateRoutes(){
00058                 if (Prefs.current.routes==currentRoutes) return;
00059                 currentRoutes=Prefs.current.routes;
00060                  
00061                 try{
00062                         engine=new VisClientScripter(client);
00063                         engine.evaluate(currentRoutes);
00064                 }catch(Exception e){
00065                         System.out.println("Routes failed, see preferences! "+e);
00066                 }
00067         }
00068          
00073         boolean dispatch(String route, String[] args){          
00074                 if (engine==null) return false; 
00075                 updateRoutes();
00076                 
00077                 ScriptFunction routeFunction=engine.getFunction(route);
00078                 if (routeFunction==null) return false;
00079                 try {
00080                         routeFunction.call((Object[])args);
00081                         return true;
00082                 } catch (Exception e){
00083                         System.out.println("Route "+route+" "+e.getMessage());
00084                         return false;
00085                 }               
00086         }
00087 } 

Generated on Tue Apr 7 17:57:20 2009 for visclient by  doxygen 1.5.1