| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.functions; |
| 9 |
|
| 10 |
import net.sf.saxon.Configuration; |
| 11 |
import net.sf.saxon.expr.Expression; |
| 12 |
import net.sf.saxon.expr.StringLiteral; |
| 13 |
import net.sf.saxon.expr.XPathContext; |
| 14 |
import net.sf.saxon.om.Sequence; |
| 15 |
import net.sf.saxon.trans.XPathException; |
| 16 |
import net.sf.saxon.value.StringValue; |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
public class RegexFunctionSansFlags extends SystemFunction { |
| 23 |
|
| 24 |
private SystemFunction addFlagsArgument() { |
| 25 |
Configuration config = getRetainedStaticContext().getConfiguration(); |
| 26 |
SystemFunction fixed = config.makeSystemFunction( |
| 27 |
getFunctionName().getLocalPart(), getArity() + 1); |
| 28 |
|
| 29 |
fixed.setRetainedStaticContext(getRetainedStaticContext()); |
| 30 |
return fixed; |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
@Override |
| 42 |
public Expression makeFunctionCall(Expression... arguments) { |
| 43 |
SystemFunction withFlags = addFlagsArgument(); |
| 44 |
Expression[] newArgs = new Expression[arguments.length + 1]; |
| 45 |
System.arraycopy(arguments, 0, newArgs, 0, arguments.length); |
| 46 |
newArgs[arguments.length] = new StringLiteral(""); |
| 47 |
return withFlags.makeFunctionCall(newArgs); |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
public Sequence<?> call(XPathContext context, Sequence[] args) throws XPathException { |
| 59 |
SystemFunction withFlags = addFlagsArgument(); |
| 60 |
Sequence[] newArgs = new Sequence[args.length + 1]; |
| 61 |
System.arraycopy(args, 0, newArgs, 0, args.length); |
| 62 |
newArgs[args.length] = StringValue.EMPTY_STRING; |
| 63 |
return withFlags.call(context, newArgs); |
| 64 |
} |
| 65 |
} |
| 66 |
|