1 package com.icl.saxon.functions; 2 import com.icl.saxon.*; 3 import com.icl.saxon.expr.*; 4 5 import java.lang.Math ; 7 9 10 11 public class Floor extends Function { 12 13 14 17 18 public String getName() { 19 return "floor"; 20 }; 21 22 26 27 public int getDataType() { 28 return Value.NUMBER; 29 } 30 31 35 36 public Expression simplify() throws XPathException { 37 checkArgumentCount(1, 1); 38 argument[0] = argument[0].simplify(); 39 if (argument[0] instanceof Value) { 40 return evaluate(null); 41 } 42 return this; 43 } 44 45 48 49 public double evaluateAsNumber(Context c) throws XPathException { 50 return Math.floor(argument[0].evaluateAsNumber(c)); 51 } 52 53 56 57 public Value evaluate(Context c) throws XPathException { 58 return new NumericValue(evaluateAsNumber(c)); 59 } 60 61 64 65 public int getDependencies() { 66 return argument[0].getDependencies(); 67 } 68 69 72 73 public Expression reduce(int dep, Context c) throws XPathException { 74 Floor f = new Floor(); 75 f.addArgument(argument[0].reduce(dep, c)); 76 f.setStaticContext(getStaticContext()); 77 return f.simplify(); 78 } 79 80 } 81 82 83 | Popular Tags |