/** * Get the capability-specific fetcher (scope==null for agent scope). */ public static IValueFetcher getFetcher(final IInternalAccess agent, String scope) { return getFetcher(agent, scope, null); }
public IFuture<Tuple2<Boolean, Object>> evaluate(IEvent event) { Boolean ret = (Boolean)exp.getValue(CapabilityWrapper.getFetcher(getAgent(), uexp.getLanguage())); return new Future<Tuple2<Boolean, Object>>(ret!=null && ret.booleanValue()? TRUE: FALSE); } }, new IAction<Void>()
/** * Evaluate the expression. * @return The value of the expression. */ public Object getValue() { return getParsedExpression().getValue(CapabilityWrapper.getFetcher(getAgent(), uexp.getLanguage())); }
/** * Get/Evaluate the updaterate value. * @param agent The agent. * @return The update rate. */ public long getUpdaterateValue(IInternalAccess agent) { long ret = -1; if(updaterate!=null) ret = ((Number)SJavaParser.parseExpression(updaterate, agent.getModel().getAllImports(), agent.getClassLoader()) .getValue(CapabilityWrapper.getFetcher(agent, updaterate.getLanguage()))).longValue(); return ret; }
/** * Get/Evaluate the updaterate value. * @param agent The agent. * @return The update rate. */ public long getUpdaterateValue(IInternalAccess agent) { long ret = -1; if(updaterate!=null) ret = ((Number)SJavaParser.parseExpression(updaterate, agent.getModel().getAllImports(), agent.getClassLoader()).getValue(CapabilityWrapper.getFetcher(agent, updaterate.getLanguage()))).longValue(); return ret; }
bindingparams = new HashMap<String, Object>(); IParsedExpression exp = SJavaParser.parseExpression(bo, agent.getModel().getAllImports(), agent.getClassLoader()); Object val = exp.getValue(CapabilityWrapper.getFetcher(agent, bo.getLanguage(), element!=null ? Collections.singletonMap(element.getFetcherName(), (Object)element) : null)); bindingparams.put(param.getName(), val);
public IFuture<Tuple2<Boolean, Object>> evaluate(IEvent event) { UnparsedExpression uexp = mcond.getExpression(); Boolean ret = (Boolean)SJavaParser.parseExpression(uexp, component.getModel().getAllImports(), component.getClassLoader()).getValue(CapabilityWrapper.getFetcher(component, uexp.getLanguage())); return new Future<Tuple2<Boolean, Object>>(ret!=null && ret.booleanValue()? TRUE: FALSE); } }}), createplan);
/** * Execute the query using a local parameter. * @param name The name of the local parameter. * @param value The value of the local parameter. * @return the result value of the query. */ public Object execute(String name, Object value) { SimpleValueFetcher fet = new SimpleValueFetcher(CapabilityWrapper.getFetcher(getAgent(), uexp.getLanguage())); fet.setValue(name, value); return getParsedExpression().getValue(fet); }
/** * Evaluate the condition. * @return */ public static boolean evaluateCondition(IInternalAccess agent, MCondition cond, MElement owner, Map<String, Object> vals) { boolean ret = false; UnparsedExpression uexp = cond.getExpression(); try { Object res = SJavaParser.getParsedValue(uexp, agent.getModel().getAllImports(), CapabilityWrapper.getFetcher(agent, uexp.getLanguage(), vals), agent.getClassLoader()); if(res instanceof Boolean) { ret = ((Boolean)res).booleanValue(); } else { agent.getLogger().warning("Condition does not evaluate to boolean: "+uexp.getValue()); } } catch(Exception e) { agent.getLogger().warning("Condition evaluation produced exception: "+uexp.getValue()+", "+e); } return ret; }
/** * Execute the query using local parameters. * @param names The names of parameters. * @param values The parameter values. * @return The return value. */ public Object execute(String[] names, Object[] values) { SimpleValueFetcher fet = new SimpleValueFetcher(CapabilityWrapper.getFetcher(getAgent(), uexp.getLanguage())); for(int i=0; i<names.length; i++) { fet.setValue(names[i], values[i]); } return getParsedExpression().getValue(fet); }
public IFuture<Tuple2<Boolean, Object>> evaluate(IEvent event) { UnparsedExpression uexp = mcond.getExpression(); Boolean ret = (Boolean)SJavaParser.parseExpression(uexp, getAgent().getModel().getAllImports(), getAgent().getClassLoader()).getValue(CapabilityWrapper.getFetcher(getAgent(), uexp.getLanguage(), values)); return new Future<Tuple2<Boolean, Object>>(ret!=null && ret.booleanValue()? TRUE: FALSE); } }, new IAction<Void>()
.getValue(CapabilityWrapper.getFetcher(getAgent(), mbel.getDefaultFact().getLanguage())); Iterator<?> it = SReflect.getIterator(tmp); while(it.hasNext()) .getValue(CapabilityWrapper.getFetcher(getAgent(), uexp.getLanguage())); tmpfacts.add(fact);
wrapFetcher(CapabilityWrapper.getFetcher(getAgent(), inivals.get(0).getLanguage()))); if(tmpvalue!=null && getClazz()!=null && SReflect.isSupertype(getClazz(), tmpvalue.getClass())) wrapFetcher(CapabilityWrapper.getFetcher(getAgent(), uexp.getLanguage()))));
component.getModel().getAllImports(), component.getClassLoader()).getValue(CapabilityWrapper.getFetcher(component, mbel.getDefaultFact().getLanguage()));
if(uexp!=null && uexp.getValue()!=null && uexp.getValue().length()>0) SimpleValueFetcher fet = new SimpleValueFetcher(CapabilityWrapper.getFetcher(agent, uexp.getLanguage())); fet.setValue(goal.getFetcherName(), goal); fet.setValue("$ref", other);
CapabilityWrapper.getFetcher(ia, uexp.getLanguage(), vals)); if(val instanceof Boolean) Object val = SJavaParser.getParsedValue(upex, null, CapabilityWrapper.getFetcher(ia, upex.getLanguage(), vals), null); if(val instanceof Boolean)
/** * Evaluate the (initial or default or pull) value. */ protected Object evaluateValue(UnparsedExpression inival) { UnparsedExpression uexp = inival!=null ? inival : getModelElement()!=null ? ((MParameter)getModelElement()).getDefaultValue() : null; return uexp!=null ? SJavaParser.parseExpression(uexp, getAgent().getModel().getAllImports(), getAgent().getClassLoader()).getValue( wrapFetcher(CapabilityWrapper.getFetcher(getAgent(), uexp.getLanguage()))) : null; }
try nowait = ((Boolean)exp.getValue(CapabilityWrapper.getFetcher(getAgent(), mcond.getExpression().getLanguage(), values))).booleanValue();
/** * Create a new parameter. * @param modelelement The model element. * @param name The name. */ public RBelief(MBelief modelelement, IInternalAccess agent) { super(modelelement, agent); String name = getModelElement().getName(); this.publisher = new EventPublisher(agent, ChangeEvent.FACTCHANGED+"."+name, (MBelief)getModelElement()); if(modelelement.getDefaultFact()!=null) setFact(SJavaParser.parseExpression(modelelement.getDefaultFact(), agent.getModel().getAllImports(), agent.getClassLoader()) .getValue(CapabilityWrapper.getFetcher(getAgent(), modelelement.getDefaultFact().getLanguage()))); }
/** * Get the value of a parameter. * @return The value. */ public Object getFact() { Object ret = value; // In case of push the last evaluated value is returned if(((MBelief)getModelElement()).getDefaultFact()!=null && MParameter.EvaluationMode.PULL.equals(((MBelief)getModelElement()).getEvaluationMode())) { ret = SJavaParser.parseExpression(((MBelief)getModelElement()).getDefaultFact(), getAgent().getModel().getAllImports(), getAgent().getClassLoader()) .getValue(CapabilityWrapper.getFetcher(getAgent(), ((MBelief)getModelElement()).getDefaultFact().getLanguage())); } return ret; }