/** Returns the smallest integer greater than or equal to the argument. * If necessary, the argument is first converted to a <code>Double</code> * as if by the XPath <code>number()</code> function. * * @param obj the object whose ceiling is returned * @param nav ignored * * @return a <code>Double</code> containing the smallest integer * greater than or equal to <code>obj</code> */ public static Double evaluate(Object obj, Navigator nav) { Double value = NumberFunction.evaluate( obj, nav ); return new Double( Math.ceil( value.doubleValue() ) ); } }
private boolean evaluateObjectObject( Object lhs, Object rhs, Navigator nav ) { if( lhs == null || rhs == null ) { return false; } Double lhsNum = NumberFunction.evaluate( lhs, nav ); Double rhsNum = NumberFunction.evaluate( rhs, nav ); if( NumberFunction.isNaN( lhsNum ) || NumberFunction.isNaN( rhsNum ) ) { return false; } return evaluateDoubleDouble( lhsNum, rhsNum ); }
new NumberFunction() );
"number", new NumberFunction());
/** Returns the largest integer less than or equal to the argument. * If necessary, the argument is first converted to a <code>Double</code> * as if by the XPath <code>number()</code> function. * * @param obj the object whose floor is returned * @param nav ignored * * @return a <code>Double</code> containing the largest integer less * than or equal to <code>obj</code> */ public static Double evaluate(Object obj, Navigator nav) { Double value = NumberFunction.evaluate( obj, nav ); return new Double( Math.floor( value.doubleValue() ) ); } }
"number", new NumberFunction());
/** * Returns the integer nearest to the argument. * If necessary, the argument is first converted to a <code>Double</code> * as if by the XPath <code>number()</code> function. * * @param obj the object to be rounded * @param nav ignored * * @return the integer nearest to <code>obj</code> */ public static Double evaluate(Object obj, Navigator nav) { Double d = NumberFunction.evaluate( obj, nav ); if (d.isNaN() || d.isInfinite()) { return d; } double value = d.doubleValue(); return new Double( Math.round( value ) ); } }
public Object evaluate(Context context) throws JaxenException { Number lhsValue = NumberFunction.evaluate( getLHS().evaluate( context ), context.getNavigator() ); Number rhsValue = NumberFunction.evaluate( getRHS().evaluate( context ), context.getNavigator() ); double result = lhsValue.doubleValue() / rhsValue.doubleValue(); return new Double( result ); }
public Object evaluate(Context context) throws JaxenException { Number number = NumberFunction.evaluate( getExpr().evaluate( context ), context.getNavigator() ); return new Double( number.doubleValue() * -1 ); }
while ( nodeIter.hasNext() ) double term = NumberFunction.evaluate( nodeIter.next(), nav ).doubleValue(); sum += term;
public Object evaluate(Context context) throws JaxenException { Number lhsValue = NumberFunction.evaluate( getLHS().evaluate( context ), context.getNavigator() ); Number rhsValue = NumberFunction.evaluate( getRHS().evaluate( context ), context.getNavigator() ); double result = lhsValue.doubleValue() + rhsValue.doubleValue(); return new Double( result ); }
public Object evaluate( Context context ) throws JaxenException { Number lhsValue = NumberFunction.evaluate( getLHS().evaluate( context ), context.getNavigator() ); Number rhsValue = NumberFunction.evaluate( getRHS().evaluate( context ), context.getNavigator() ); double result = lhsValue.doubleValue() * rhsValue.doubleValue(); return new Double( result ); }
public Object evaluate( Context context ) throws JaxenException { Number lhsValue = NumberFunction.evaluate( getLHS().evaluate( context ), context.getNavigator() ); Number rhsValue = NumberFunction.evaluate( getRHS().evaluate( context ), context.getNavigator() ); double result = lhsValue.doubleValue() % rhsValue.doubleValue(); return new Double( result ); }
public Object evaluate(Context context) throws JaxenException { Number lhsValue = NumberFunction.evaluate( getLHS().evaluate( context ), context.getNavigator() ); Number rhsValue = NumberFunction.evaluate( getRHS().evaluate( context ), context.getNavigator() ); double result = lhsValue.doubleValue() - rhsValue.doubleValue(); return new Double( result ); }
/** * Returns the number value of <code>args.get(0)</code>, * or the number value of the context node if <code>args</code> * is empty. * * @param context the context at the point in the * expression when the function is called * @param args a list containing the single item to be converted to a * <code>Double</code> * * @return a <code>Double</code> * * @throws FunctionCallException if <code>args</code> has more than one item */ public Object call(Context context, List args) throws FunctionCallException { if (args.size() == 1) { return evaluate( args.get(0), context.getNavigator() ); } else if (args.size() == 0) { return evaluate( context.getNodeSet(), context.getNavigator() ); } throw new FunctionCallException( "number() takes at most one argument." ); }
/** Retrieve a number-value interpretation of this XPath * expression when evaluated against a given context. * * <p> * The number-value of the expression is determined per * the <code>number(..)</code> core function as defined * in the XPath specification. This means that if this * expression selects multiple nodes, the number-value * of the first node is returned. * </p> * * @param node the node, node-set or Context object for evaluation. This value can be null. * * @return a <code>Double</code> indicating the numeric value of * evaluating this expression against the specified context * @throws JaxenException if an XPath error occurs during expression evaluation */ public Number numberValueOf(Object node) throws JaxenException { Context context = getContext( node ); Object result = selectSingleNodeForContext( context ); return NumberFunction.evaluate( result, context.getNavigator() ); }
private boolean evaluateObjectObject( Object lhs, Object rhs, Navigator nav ) { if( eitherIsBoolean( lhs, rhs ) ) { return evaluateObjectObject( BooleanFunction.evaluate( lhs, nav ), BooleanFunction.evaluate( rhs, nav ) ); } else if( eitherIsNumber( lhs, rhs ) ) { return evaluateObjectObject( NumberFunction.evaluate( lhs, nav ), NumberFunction.evaluate( rhs, nav ) ); } else { return evaluateObjectObject( StringFunction.evaluate( lhs, nav ), StringFunction.evaluate( rhs, nav ) ); } }
public static String evaluate(Object seqeuenceObj, Object signObj, Navigator nav) throws FunctionCallException { String sequence = StringFunction.evaluate(seqeuenceObj, nav); int sign = NumberFunction.evaluate(signObj, nav).intValue();