static private float asFloat(Node n) { if ( n == null ) return Float.MIN_VALUE ; NodeValue nv = NodeValue.makeNode(n) ; if ( nv.isFloat() ) return nv.getFloat() ; return Float.MIN_VALUE ; }
private static int intValueStr(NodeValue nv, int valueNan) { if ( nv.isInteger() ) return nv.getInteger().intValue() ; if ( nv.isDecimal() ) // No decimal round in Java 1.4 return (int)Math.round(nv.getDecimal().doubleValue()) ; if ( nv.isFloat() ) { float f = nv.getFloat() ; if ( Float.isNaN(f)) return valueNan ; return Math.round(f) ; } if ( nv.isDouble() ) { double d = nv.getDouble() ; if ( Double.isNaN(d)) return valueNan ; return (int)Math.round(d) ; } throw new ExprEvalException("Not a number:"+nv) ; }
private static int intValueStr(NodeValue nv, int valueNan) { if ( nv.isInteger() ) return nv.getInteger().intValue() ; if ( nv.isDecimal() ) // No decimal round in Java 1.4 return (int)Math.round(nv.getDecimal().doubleValue()) ; if ( nv.isFloat() ) { float f = nv.getFloat() ; if ( Float.isNaN(f)) return valueNan ; return Math.round(f) ; } if ( nv.isDouble() ) { double d = nv.getDouble() ; if ( Double.isNaN(d)) return valueNan ; return (int)Math.round(d) ; } throw new ExprEvalException("Not a number:"+nv) ; }
public static NumericType classifyNumeric(String fName, NodeValue nv) { if ( ! nv.isNumber() ) throw new ExprEvalTypeException("Not a number: ("+fName+") "+nv) ; if ( nv.isInteger() ) return OP_INTEGER ; if ( nv.isDecimal() ) return OP_DECIMAL ; if ( nv.isFloat() ) return OP_FLOAT ; if ( nv.isDouble() ) return OP_DOUBLE ; throw new ARQInternalErrorException("Numeric op unrecognized ("+fName+"): "+nv) ; }
public static NumericType classifyNumeric(String fName, NodeValue nv) { if ( ! nv.isNumber() ) throw new ExprEvalTypeException("Not a number: ("+fName+") "+nv) ; if ( nv.isInteger() ) return OP_INTEGER ; if ( nv.isDecimal() ) return OP_DECIMAL ; if ( nv.isFloat() ) return OP_FLOAT ; if ( nv.isDouble() ) return OP_DOUBLE ; throw new ARQInternalErrorException("Numeric op unrecognized ("+fName+"): "+nv) ; } // --------------------------------
if ( nv.isFloat() || nv.isDouble() )