2010-02-04 07:30:56 +01:00
|
|
|
package com.metaweb.gridworks.expr;
|
|
|
|
|
|
|
|
import java.util.Properties;
|
|
|
|
|
|
|
|
import com.metaweb.gridworks.model.Cell;
|
|
|
|
import com.metaweb.gridworks.model.Project;
|
|
|
|
import com.metaweb.gridworks.model.Row;
|
|
|
|
|
|
|
|
public class ExpressionUtils {
|
|
|
|
static public Properties createBindings(Project project) {
|
|
|
|
Properties bindings = new Properties();
|
2010-02-05 00:38:40 +01:00
|
|
|
|
|
|
|
bindings.put("true", true);
|
|
|
|
bindings.put("false", false);
|
|
|
|
|
2010-02-04 07:30:56 +01:00
|
|
|
bindings.put("project", project);
|
2010-02-05 00:38:40 +01:00
|
|
|
|
2010-02-04 07:30:56 +01:00
|
|
|
return bindings;
|
|
|
|
}
|
|
|
|
|
|
|
|
static public void bind(Properties bindings, Row row, Cell cell) {
|
|
|
|
bindings.put("row", row);
|
|
|
|
bindings.put("cells", row.getField("cells", bindings));
|
|
|
|
|
2010-02-07 04:36:40 +01:00
|
|
|
if (cell == null) {
|
|
|
|
bindings.remove("cell");
|
|
|
|
bindings.remove("value");
|
|
|
|
} else {
|
|
|
|
bindings.put("cell", cell);
|
|
|
|
bindings.put("value", cell.value);
|
|
|
|
}
|
2010-02-04 07:30:56 +01:00
|
|
|
}
|
2010-02-05 09:39:10 +01:00
|
|
|
|
|
|
|
static public boolean isBlank(Object o) {
|
|
|
|
return o == null || (o instanceof String && ((String) o).isEmpty());
|
|
|
|
}
|
|
|
|
|
|
|
|
static public boolean isTrue(Object o) {
|
|
|
|
return o != null &&
|
|
|
|
(o instanceof Boolean ?
|
|
|
|
((Boolean) o).booleanValue() :
|
|
|
|
Boolean.parseBoolean(o.toString()));
|
|
|
|
}
|
2010-02-04 07:30:56 +01:00
|
|
|
}
|