1 package rero.bridges.event; 2 3 import java.util.*; 4 import sleep.engine.atoms.*; 5 import sleep.runtime.*; 6 7 import rero.script.*; 8 9 public class PredicateChatListener extends EventChatListener 10 { 11 protected ScriptEnvironment env; 12 protected Check predicate; 13 protected CodeSnippet code; 14 15 public PredicateChatListener(ScriptEnvironment _env, Check _predicate, CodeSnippet c) 16 { 17 env = _env; 18 predicate = _predicate; 19 code = c; 20 21 22 addListener(c); 23 } 24 25 public boolean isChatEvent(String eventId, HashMap eventDescription) 26 { 27 if (!code.isValid()) 28 { 29 return false; 30 } 31 32 env.getScriptVariables().pushLocalLevel(); 33 34 LocalVariables locals = (LocalVariables)env.getScriptVariables().getLocalVariables(); 35 locals.setDataSource(eventDescription); 36 37 boolean check = predicate.check(env); 38 39 env.getScriptVariables().popLocalLevel(); 40 41 return check; 42 } 43 } 44 | Popular Tags |