/** * Evaluate a condition. * @param exp The expression. * @param fetcher The value fetcher. */ protected boolean evaluate(IParsedExpression exp, IValueFetcher fetcher) { boolean ret = false; try { ret = ((Boolean)exp.getValue(fetcher)).booleanValue(); } catch(Exception e) { e.printStackTrace(); } return ret; } }
public void run() { object = expression.getValue(new OAVBDIFetcher(state, scope)); } };
/** * Evaluates a java expression. * @param fetcher Expression parameters can be supplied as value fetcher. * @return The evaluated object. */ public static Object evaluateExpression(String exptxt, String[] imports, IValueFetcher fetcher, ClassLoader classloader) { IParsedExpression exp = parser.parseExpression(exptxt, imports, null, classloader); return exp.getValue(fetcher); }
/** * Returns a property. * @param name name of the property * @return the property */ public Object getProperty(String name) { Object ret = super.getProperty(name); if(ret instanceof IParsedExpression) { ret = ((IParsedExpression)ret).getValue(fetcher); } return ret; } }
/** * */ public static Object execute(IOAVState state, IParsedExpression exp, Object scope, String[] names, Object[] values) { OAVBDIFetcher fetcher = new OAVBDIFetcher(state, scope); for(int i=0; i<names.length; i++) fetcher.setValue(names[i], values[i]); return exp.getValue(fetcher); }
/** * Get a property value from the model. * @param name The name. */ public Object getParsedPropertyValue(String name) { UnparsedExpression upex = getPropertyValue(name); Object val = ((IParsedExpression)upex.getParsed()).getValue(null); return val; }
/** * Returns a property. * @param name name of the property * @return the property */ public Object getProperty(String name) { Object ret = super.getProperty(name); if(ret instanceof IParsedExpression) { ret = ((IParsedExpression) ret).getValue(getFetcher()); } return ret; }
/** * Returns a property. * * @param name name of the property * @return the property */ public Object getProperty(String name) { Object ret = super.getProperty(name); if(ret instanceof IParsedExpression) { ret = ((IParsedExpression)ret).getValue(getFetcher()); } return ret; }
/** * Returns a property. * @param name name of the property * @return the property */ public Object getProperty(String name) { synchronized(monitor) { Object ret = super.getProperty(name); if(ret instanceof IParsedExpression) { ret = ((IParsedExpression) ret).getValue(getFetcher()); } return ret; } }
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; }
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); }
/** * 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>()
/** * 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; }
/** * 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; }