/** * Execute the command. * * Fetches the field value and return an event with * type = field name * content = field value */ public IEvent execute(Object args) { try { Field f = object.getClass().getDeclaredField(name); f.setAccessible(true); Object content = f.get(object); return new Event(name, content); } catch(Exception e) { throw new RuntimeException(e); } } }
/** * */ public void clear() { T[] clone = delegate.toArray((T[])new Object[delegate.size()]); delegate.clear(); for(Object t: clone) { unobserveValue(t); getRuleSystem().addEvent(new Event(addevent, t)); publishToolBeliefEvent(); } }
/** * */ public boolean add(T e) { boolean ret = delegate.add(e); if(ret) { observeValue(e); getRuleSystem().addEvent(new Event(addevent, e)); publishToolBeliefEvent(); } return ret; }
/** * */ public boolean remove(Object o) { boolean ret = delegate.remove(o); if(ret) { unobserveValue(o); getRuleSystem().addEvent(new Event(remevent, o)); publishToolBeliefEvent(); } return ret; }
/** * */ public T set(int index, T element) { T ret = getList().set(index, element); unobserveValue(ret); observeValue(element); getRuleSystem().addEvent(new Event(changeevent, new Object[]{ret, element, Integer.valueOf(index)})); publishToolBeliefEvent(); return ret; }
/** * */ public void clear() { Set<java.util.Map.Entry<T, E>> s = entrySet(); delegate.clear(); for(Map.Entry<? extends T, ? extends E> e : s) { unobserveValue(e.getValue()); // getRuleSystem().addEvent(new Event(remevent, new Tuple2<T, E>(e.getKey(), e.getValue()))); getRuleSystem().addEvent(new Event(remevent, new MapEntry<T, E>(e.getKey(), e.getValue(), null))); publishToolBeliefEvent(); } }
/** * */ public T remove(int index) { T ret = getList().remove(index); unobserveValue(ret); getRuleSystem().addEvent(new Event(remevent, ret)); publishToolBeliefEvent(); return ret; }
/** * */ public boolean addAll(Collection<? extends T> c) { boolean ret = delegate.addAll(c); if(ret) { for(T t: c) { observeValue(t); getRuleSystem().addEvent(new Event(addevent, t)); publishToolBeliefEvent(); } } return ret; }
/** * */ public void add(int index, T element) { getList().add(index, element); observeValue(element); getRuleSystem().addEvent(new Event(addevent, element)); publishToolBeliefEvent(); }
/** * */ public boolean removeAll(Collection<?> c) { boolean ret = delegate.removeAll(c); if(ret) { for(Object t: c) { unobserveValue(t); getRuleSystem().addEvent(new Event(remevent, t)); publishToolBeliefEvent(); } } return ret; }
/** * */ protected void addInhibitor(RGoal inhibitor, IInternalAccess ia) { if(inhibitors==null) inhibitors = new HashSet<RGoal>(); if(inhibitors.add(inhibitor) && inhibitors.size()==1) { BDIAgentInterpreter ip = (BDIAgentInterpreter)((BDIAgent)ia).getInterpreter(); ip.getRuleSystem().addEvent(new Event(new EventType(new String[]{ChangeEvent.GOALINHIBITED, getMGoal().getName()}), this)); } // if(inhibitor.getId().indexOf("AchieveCleanup")!=-1) // System.out.println("add inhibit: "+getId()+" "+inhibitor.getId()+" "+inhibitors); }
public void execute(IInternalAccess agent) { observeValue(value, agent); getRuleSystem(agent).addEvent(new Event(getAddEvent(), new ChangeInfo<Object>(value, null, index>-1? Integer.valueOf(index): null))); // publishToolBeliefEvent(); } });
public void execute(IInternalAccess agent) { unobserveValue(value, agent); // observeValue(value); getRuleSystem(agent).addEvent(new Event(getRemEvent(), new ChangeInfo<Object>(value, null, index>-1? Integer.valueOf(index): null))); // publishToolBeliefEvent(); } });
/** * */ public E remove(Object key) { E ret = delegate.remove(key); unobserveValue(ret); // getRuleSystem().addEvent(new Event(remevent, new Tuple2<T, E>((T)key, ret))); getRuleSystem().addEvent(new Event(remevent, new MapEntry<T, E>((T)key, ret, null))); publishToolBeliefEvent(); return ret; }
/** * An entry was added to the collection. */ public void entryAdded(Object value, int index) { // unobserveValue(ret); observeValue(value); getRuleSystem().addEvent(new Event(getAddEvent(), new ChangeInfo<Object>(value, null, index>-1? Integer.valueOf(index): null))); publishToolBeliefEvent(); }
public void execute(IInternalAccess agent) { if(oldvalue!=newvalue) { unobserveValue(oldvalue, agent); observeValue(newvalue, agent); } getRuleSystem(agent).addEvent(new Event(getChangeEvent(), new ChangeInfo<Object>(newvalue, oldvalue, index>-1? Integer.valueOf(index): null))); // publishToolBeliefEvent(); } });
/** * An entry was removed from the collection. */ public void entryRemoved(Object value, int index) { unobserveValue(value); // observeValue(value); getRuleSystem().addEvent(new Event(getRemEvent(), new ChangeInfo<Object>(value, null, index>-1? Integer.valueOf(index): null))); publishToolBeliefEvent(); }
/** * */ protected void removeInhibitor(RGoal inhibitor, IInternalAccess ia) { // System.out.println("rem inhibit: "+getId()+" "+inhibitor.getId()+" "+inhibitors); // if(inhibitor.getId().indexOf("AchieveCleanup")!=-1) // System.out.println("kokoko: "+inhibitor); if(inhibitors!=null) { if(inhibitors.remove(inhibitor) && inhibitors.size()==0) { // System.out.println("goal not inhibited: "+this); BDIAgentInterpreter ip = (BDIAgentInterpreter)((BDIAgent)ia).getInterpreter(); ip.getRuleSystem().addEvent(new Event(new EventType(new String[]{ChangeEvent.GOALNOTINHIBITED, getMGoal().getName()}), this)); } } }
/** * An entry was changed in the collection. */ public void entryChanged(Object oldvalue, Object newvalue, int index) { if(oldvalue!=newvalue) { unobserveValue(oldvalue); observeValue(newvalue); } getRuleSystem().addEvent(new Event(getChangeEvent(), new ChangeInfo<Object>(newvalue, oldvalue, index>-1? Integer.valueOf(index): null))); publishToolBeliefEvent(); }
public void execute(IInternalAccess agent) { observeValue(value, agent); getRuleSystem(agent).addEvent(new Event(getAddEvent(), new ChangeInfo<Object>(value, null, key))); // publishToolBeliefEvent(); } });