| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.expr.instruct; |
| 9 |
|
| 10 |
import net.sf.saxon.expr.*; |
| 11 |
import net.sf.saxon.functions.AbstractFunction; |
| 12 |
import net.sf.saxon.om.Function; |
| 13 |
import net.sf.saxon.om.Sequence; |
| 14 |
import net.sf.saxon.om.StructuredQName; |
| 15 |
import net.sf.saxon.trace.ExpressionPresenter; |
| 16 |
import net.sf.saxon.trans.XPathException; |
| 17 |
import net.sf.saxon.type.FunctionItemType; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
public class OriginalFunction extends AbstractFunction implements Function, ContextOriginator { |
| 23 |
|
| 24 |
private UserFunction userFunction; |
| 25 |
private Component component; |
| 26 |
|
| 27 |
public OriginalFunction(Component component) { |
| 28 |
this.component = component; |
| 29 |
this.userFunction = (UserFunction)component.getActor(); |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
public Sequence<?> call(XPathContext context, Sequence[] args) throws XPathException { |
| 41 |
XPathContextMajor c2 = userFunction.makeNewContext(context, this); |
| 42 |
c2.setCurrentComponent(component); |
| 43 |
return userFunction.call(c2, args); |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
public FunctionItemType getFunctionItemType() { |
| 52 |
return userFunction.getFunctionItemType(); |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
public StructuredQName getFunctionName() { |
| 61 |
return userFunction.getFunctionName(); |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
public int getArity() { |
| 70 |
return userFunction.getArity(); |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
public String getDescription() { |
| 81 |
return userFunction.getDescription(); |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
public String getContainingPackageName() { |
| 89 |
return component.getContainingPackage().getPackageName(); |
| 90 |
} |
| 91 |
|
| 92 |
public Component getComponent() { |
| 93 |
return component; |
| 94 |
} |
| 95 |
|
| 96 |
@Override |
| 97 |
public void export(ExpressionPresenter out) throws XPathException { |
| 98 |
ExpressionPresenter.ExportOptions options = (ExpressionPresenter.ExportOptions) out.getOptions(); |
| 99 |
out.startElement("origF"); |
| 100 |
out.emitAttribute("name", getFunctionName()); |
| 101 |
out.emitAttribute("arity", ""+getArity()); |
| 102 |
out.emitAttribute("pack", options.packageMap.get(component.getContainingPackage())+""); |
| 103 |
out.endElement(); |
| 104 |
} |
| 105 |
} |
| 106 |
|