| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.functions; |
| 9 |
|
| 10 |
import net.sf.saxon.expr.Expression; |
| 11 |
import net.sf.saxon.expr.Literal; |
| 12 |
import net.sf.saxon.expr.XPathContext; |
| 13 |
import net.sf.saxon.om.GroundedValue; |
| 14 |
import net.sf.saxon.om.Sequence; |
| 15 |
import net.sf.saxon.trans.XPathException; |
| 16 |
import net.sf.saxon.value.BooleanValue; |
| 17 |
import net.sf.saxon.value.IntegerValue; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
public class ConstantFunction extends SystemFunction { |
| 25 |
|
| 26 |
public GroundedValue<?> value; |
| 27 |
|
| 28 |
public ConstantFunction(GroundedValue<?> value) { |
| 29 |
this.value = value; |
| 30 |
} |
| 31 |
|
| 32 |
public Sequence<?> call(XPathContext context, Sequence[] arguments) throws XPathException { |
| 33 |
return value; |
| 34 |
} |
| 35 |
|
| 36 |
@Override |
| 37 |
public Expression makeFunctionCall(Expression[] arguments) { |
| 38 |
return Literal.makeLiteral(value); |
| 39 |
} |
| 40 |
|
| 41 |
@Override |
| 42 |
public IntegerValue[] getIntegerBounds() { |
| 43 |
if (value instanceof IntegerValue) { |
| 44 |
return new IntegerValue[]{(IntegerValue) value, (IntegerValue) value}; |
| 45 |
} else { |
| 46 |
return null; |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
public static class True extends ConstantFunction { |
| 51 |
public True() { |
| 52 |
super(BooleanValue.TRUE); |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
public static class False extends ConstantFunction { |
| 57 |
public False() { |
| 58 |
super(BooleanValue.FALSE); |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
} |
| 63 |
|