use of org.apache.commons.jxpath.ri.model.NodePointer in project collect by openforis.
the class ModelRelationalExpression method getValue.
private Object getValue(Object object) {
if (object instanceof Number || object instanceof NumericRange || object instanceof String) {
return object;
}
if (object instanceof Boolean) {
return ((Boolean) object).booleanValue() ? 0.0 : 1.0;
} else if (object instanceof Value) {
return AttributeValueUtils.extractMainFieldValue((Value) object, normalizeNumbers);
}
if (object instanceof NodePointer) {
if (object instanceof VariablePointer && normalizeNumbers) {
ModelNodePointer valuePointer = (ModelNodePointer) ((NodePointer) object).getValuePointer();
valuePointer.setNormalizeNumbers(true);
}
return getValue(((NodePointer) object).getValue());
}
if (object instanceof EvalContext) {
EvalContext ctx = (EvalContext) object;
Pointer ptr = ctx.getSingleNodePointer();
return ptr == null ? Double.NaN : getValue(ptr);
}
return null;
}
use of org.apache.commons.jxpath.ri.model.NodePointer in project collect by openforis.
the class ModelLocationPath method computeValue.
@Override
public Object computeValue(EvalContext context) {
Object value = super.computeValue(context);
if (value instanceof DynamicPropertyPointer) {
NodePointer pointer = ((DynamicPropertyPointer) value).getValuePointer();
Object object = pointer.getNode();
if (object instanceof BooleanAttribute) {
return pointer.getValue();
}
}
return value;
}
use of org.apache.commons.jxpath.ri.model.NodePointer in project collect by openforis.
the class ModelRelationalExpression method getDoubleValue.
private double getDoubleValue(Object object) {
if (object instanceof Number) {
return ((Number) object).doubleValue();
}
if (object instanceof Boolean) {
return ((Boolean) object).booleanValue() ? 0.0 : 1.0;
}
if (object instanceof String) {
if (StringUtils.isBlank((String) object)) {
return 0.0;
}
try {
return Double.parseDouble((String) object);
} catch (NumberFormatException ex) {
return Double.NaN;
}
}
if (object instanceof NodePointer) {
return getDoubleValue(((NodePointer) object).getValue());
}
if (object instanceof EvalContext) {
EvalContext ctx = (EvalContext) object;
Pointer ptr = ctx.getSingleNodePointer();
return ptr == null ? Double.NaN : getDoubleValue(ptr);
}
throw new RuntimeException("Cannot convert " + object.toString() + " to a double value");
}
Aggregations