/** * 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 String convertObject(Object val, Object context) { String ret = null; if(val instanceof IParsedExpression) { ret = ((IParsedExpression)val).getExpressionText(); } return ret; } }
public void setValue(Object value) { this.value = value; if(type == null) type = ((IParsedExpression)value).getStaticType(); }
fetcher.setValue("$perspective", viewport.getPerspective()); String name = ((IParsedExpression)prop).getExpressionText();//(String)prop; ret = getProperty(name); ret = ((IParsedExpression)ret).getValue(fetcher); ret = ((IParsedExpression)prop).getValue(fetcher);
fetcher.setValue("$perspective", viewport.getPerspective()); String name = ((IParsedExpression)prop).getExpressionText();//(String)prop; ret = getProperty(name); ret = ((IParsedExpression)ret).getValue(fetcher); ret = ((IParsedExpression)prop).getValue(fetcher); fetcher.setValue("$object", obj); fetcher.setValue("$perspective", viewport.getPerspective()); ret = ((IParsedExpression)ret).getValue(fetcher);
/** * 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; } }
if(parsedexp!=null) ret = parsedexp.getExpressionText(); if(parsedexp!=null) rets.add(parsedexp.getExpressionText()); if(parsedexp!=null) ret = parsedexp.getExpressionText(); if(parsedexp!=null) rets.add(parsedexp.getExpressionText());
ret = SJavaParser.parseExpression(value, null, cl).getStaticType(); ret = SJavaParser.parseExpression(values.get(0), null, cl).getStaticType();
/** * 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 String getObjectName(Object obj) { String name = null; if(state.getType(obj).isSubtype(OAVBDIMetaModel.modelelement_type)) { name = (String)state.getAttributeValue(obj, OAVBDIMetaModel.modelelement_has_name); } if(name==null && state.getType(obj).isSubtype(OAVBDIMetaModel.elementreference_type)) { name = (String)state.getAttributeValue(obj, OAVBDIMetaModel.elementreference_has_concrete); } if(name==null && state.getType(obj).isSubtype(OAVBDIMetaModel.expression_type)) { IParsedExpression exp =(IParsedExpression)state.getAttributeValue(obj, OAVBDIMetaModel.expression_has_parsed); String text = (String)state.getAttributeValue(obj, OAVBDIMetaModel.expression_has_text); name = exp!=null ? exp.getExpressionText() : text!=null ? text.trim() : null; } if(name==null) { name = ""+obj; } return obj instanceof String ? (String)obj : state.getType(obj).getName().substring(1) + " " + name; } }
public void run() { object = expression.getValue(new OAVBDIFetcher(state, scope)); } };
if(parsedexp!=null) ret = parsedexp.getExpressionText(); if(parsedexp!=null) ret = parsedexp.getExpressionText();
/** * 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); }
/** * Legacy conversion to unparsed expression. * * @param name Name * @param exp */ public void setPropertyValue(String name, IParsedExpression exp) { if(exp != null) { MProperty mprop = new MProperty(); mprop.setName(name); UnparsedExpression uexp = new UnparsedExpression(name, (String) null, exp.getExpressionText(), null); uexp.setParsedExp(exp); mprop.setInitialValue(uexp); addProperty(mprop); } else { MProperty mprop = new MProperty(); mprop.setName(name); UnparsedExpression uexp = new UnparsedExpression(name, (String) null, null, null); SJavaParser.parseExpression(uexp, null, MActivity.class.getClassLoader()); mprop.setInitialValue(uexp); addProperty(mprop); } }
/** * 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; } }
parcon.addConstraint(new LiteralConstraint(OAVBDIRuntimeModel.parameter_has_name, pname)); parcon.addConstraint(new BoundConstraint(OAVBDIRuntimeModel.parameter_has_value, new Variable(pexp.getExpressionText().trim(), state.getTypeModel().getJavaType(clazz)))); parcons.add(parcon);
/** * Get a parsed value. * Handles values, which may be parsed or unparsed, * and always returns a parsed value. * @param value The value. * @return The parsed and evaluated value. */ public static Object getParsedValue(Object value, String[] imports, IValueFetcher fetcher, ClassLoader classloader) { if(value instanceof UnparsedExpression) { // todo: language UnparsedExpression upe = (UnparsedExpression)value; IParsedExpression pe = parseExpression(upe, imports, classloader); value = pe!=null ? pe.getValue(fetcher) : null; } return value; }
/** * Set properties on a map. * @param properties A list properties (containing maps with "name", "value" keys). * @param fetcher The fetcher for parsing the Java expression (can provide * predefined values to the expression) */ public static Map convertProperties(List properties, IValueFetcher fetcher) { HashMap ret = null; if(properties!=null) { ret = new HashMap(); for(int i=0; i<properties.size(); i++) { Map prop = (Map)properties.get(i); IParsedExpression exp = (IParsedExpression)prop.get("value"); boolean dyn = ((Boolean)prop.get("dynamic")).booleanValue(); if(dyn) ret.put((String)prop.get("name"), exp); else ret.put((String)prop.get("name"), exp==null? null: exp.getValue(fetcher)); } } 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(fetcher); } return ret; } }
properties.put(propname, exp); else properties.put(propname, exp.getValue(fetcher));