List of usage examples for org.apache.commons.jxpath.ri EvalContext getSingleNodePointer
public Pointer getSingleNodePointer()
From source file:org.openvpms.component.system.common.jxpath.TypeConversionUtil.java
/** * Converts the supplied object to BigDecimal * //from w ww .ja v a 2 s.c o m * @param object * the incoming object * @return BigDecimal */ public static BigDecimal bigDecimalValue(Object object) { if (object instanceof BigDecimal) { return (BigDecimal) object; } else if (object instanceof BigInteger) { return new BigDecimal((BigInteger) object); } else if (object instanceof Number) { return new BigDecimal(((Number) object).doubleValue()); } else if (object instanceof Boolean) { return new BigDecimal(((Boolean) object).booleanValue() ? 0.0 : 1.0); } else if (object instanceof String) { BigDecimal value = new BigDecimal(0.0); if (!object.equals("")) { try { value = new BigDecimal((String) object); } catch (NumberFormatException ex) { value = BigDecimal.ZERO; } } return value; } else if (object instanceof NodePointer) { return bigDecimalValue(((NodePointer) object).getValue()); } else if (object instanceof EvalContext) { EvalContext ctx = (EvalContext) object; Pointer ptr = ctx.getSingleNodePointer(); if (ptr != null) { return bigDecimalValue(ptr); } return BigDecimal.ZERO; } return bigDecimalValue(InfoSetUtil.stringValue(object)); }