| 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.SystemFunctionCall; |
| 12 |
import net.sf.saxon.expr.XPathContext; |
| 13 |
import net.sf.saxon.expr.parser.ExpressionVisitor; |
| 14 |
import net.sf.saxon.lib.EnvironmentVariableResolver; |
| 15 |
import net.sf.saxon.lib.Feature; |
| 16 |
import net.sf.saxon.om.Sequence; |
| 17 |
import net.sf.saxon.trans.XPathException; |
| 18 |
import net.sf.saxon.value.SequenceExtent; |
| 19 |
import net.sf.saxon.value.StringValue; |
| 20 |
|
| 21 |
import java.util.ArrayList; |
| 22 |
import java.util.List; |
| 23 |
|
| 24 |
public class AvailableEnvironmentVariables extends SystemFunction { |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
public Sequence<StringValue> call(XPathContext context, Sequence[] arguments) throws XPathException { |
| 36 |
EnvironmentVariableResolver resolver = context.getConfiguration().getConfigurationProperty( |
| 37 |
Feature.ENVIRONMENT_VARIABLE_RESOLVER); |
| 38 |
List<StringValue> myList = new ArrayList<>(); |
| 39 |
if (context.getConfiguration().getBooleanProperty(Feature.ALLOW_EXTERNAL_FUNCTIONS)) { |
| 40 |
for (java.lang.String s : resolver.getAvailableEnvironmentVariables()) { |
| 41 |
myList.add(new StringValue(s)); |
| 42 |
} |
| 43 |
} |
| 44 |
return new SequenceExtent<>(myList); |
| 45 |
} |
| 46 |
|
| 47 |
@Override |
| 48 |
public Expression makeFunctionCall(Expression[] arguments) { |
| 49 |
return new SystemFunctionCall(this, arguments) { |
| 50 |
|
| 51 |
public Expression preEvaluate(ExpressionVisitor visitor) { |
| 52 |
return this; |
| 53 |
} |
| 54 |
}; |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
|