1 package com.icl.saxon.functions; 2 import com.icl.saxon.*; 3 import com.icl.saxon.expr.*; 4 5 import java.util.*; 6 7 8 9 public class Not extends Function { 10 11 14 15 public String getName() { 16 return "not"; 17 }; 18 19 23 24 public int getDataType() { 25 return Value.BOOLEAN; 26 } 27 28 32 33 public Expression simplify() throws XPathException { 34 checkArgumentCount(1, 1); 35 argument[0] = argument[0].simplify(); 36 37 if (argument[0] instanceof Value) { 38 return new BooleanValue(!((Value)argument[0]).asBoolean()); 39 } 40 return this; 41 } 42 43 46 47 public boolean evaluateAsBoolean(Context c) throws XPathException { 48 return !argument[0].evaluateAsBoolean(c); 49 } 50 51 54 55 public Value evaluate(Context c) throws XPathException { 56 return new BooleanValue(evaluateAsBoolean(c)); 57 } 58 59 62 63 public int getDependencies() { 64 return argument[0].getDependencies(); 65 } 66 67 70 71 public Expression reduce(int dep, Context c) throws XPathException { 72 Not f = new Not(); 73 f.addArgument(argument[0].reduce(dep, c)); 74 f.setStaticContext(getStaticContext()); 75 return f.simplify(); 76 } 77 78 } 79 80 81 82 | Popular Tags |