1 package com.icl.saxon.functions; 2 import com.icl.saxon.*; 3 import com.icl.saxon.expr.*; 4 5 import java.util.*; 6 import java.text.*; 7 8 9 10 public class BooleanFn extends Function { 11 12 15 16 public String getName() { 17 return "boolean"; 18 }; 19 20 24 25 public int getDataType() { 26 return Value.BOOLEAN; 27 } 28 29 33 34 public Expression simplify() throws XPathException { 35 checkArgumentCount(1, 1); 36 argument[0] = argument[0].simplify(); 37 if (argument[0].getDataType()==Value.BOOLEAN) { 38 return argument[0]; 39 } 40 if (argument[0] instanceof Value) { 41 return new BooleanValue(((Value)argument[0]).asBoolean()); 42 } 43 return this; 44 } 45 46 49 50 public boolean evaluateAsBoolean(Context c) throws XPathException { 51 return argument[0].evaluateAsBoolean(c); 52 } 53 54 57 58 public Value evaluate(Context c) throws XPathException { 59 return new BooleanValue(evaluateAsBoolean(c)); 60 } 61 62 65 66 public int getDependencies() { 67 return argument[0].getDependencies(); 68 } 69 70 73 74 public Expression reduce(int dep, Context c) throws XPathException { 75 BooleanFn f = new BooleanFn(); 76 f.addArgument(argument[0].reduce(dep, c)); 77 f.setStaticContext(getStaticContext()); 78 return f.simplify(); 79 } 80 81 82 83 } 84 85 | Popular Tags |