Package net.sf.saxon.functions
Class KeyFn
- java.lang.Object
-
- net.sf.saxon.functions.AbstractFunction
-
- net.sf.saxon.functions.SystemFunction
-
- net.sf.saxon.functions.KeyFn
-
- All Implemented Interfaces:
Callable
,StatefulSystemFunction
,Function
,GroundedValue
,Item
,Sequence
public class KeyFn extends SystemFunction implements StatefulSystemFunction
-
-
Constructor Summary
Constructors Constructor Description KeyFn()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PathMap.PathMapNodeSet
addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)
Add a representation of this expression to a PathMap.Sequence
call(XPathContext context, Sequence[] arguments)
Evaluate the expressionSystemFunction
copy()
Make a copy of this SystemFunction.Expression
fixArguments(Expression... arguments)
Allow the function to create an optimized call based on the values of the actual arguments.KeyManager
getKeyManager()
NamespaceResolver
getNamespaceResolver()
int
getSpecialProperties(Expression[] arguments)
Get the static properties of this expression (other than its type).static Expression
internalKeyCall(KeyManager keyManager, KeyDefinitionSet keySet, java.lang.String name, Expression value, Expression doc, RetainedStaticContext rsc)
Factory method to create an internal call on key() with a known key definitionprotected static Sequence
search(KeyManager keyManager, XPathContext context, Sequence sought, NodeInfo origin, KeyDefinitionSet selectedKeySet)
-
Methods inherited from class net.sf.saxon.functions.SystemFunction
dependsOnContextItem, dynamicCall, equals, export, exportAdditionalArguments, exportAttributes, getArity, getCardinality, getCompilerName, getContextNode, getDescription, getDetails, getErrorCodeForTypeErrors, getFunctionItemType, getFunctionName, getIntegerBounds, getNetCost, getOperandRoles, getRequiredType, getResultItemType, getResultItemType, getRetainedStaticContext, getStaticBaseUriString, getStreamerName, getUniStringArg, hashCode, importAttributes, isSequenceVariadic, isTrustedResultType, makeCall, makeFunction, makeFunctionCall, makeOptimizedFunctionCall, resultIfEmpty, setArity, setDetails, setRetainedStaticContext, supplyTypeInformation, toShortString, toString, typeCheckCaller
-
Methods inherited from class net.sf.saxon.functions.AbstractFunction
atomize, deepEquals, effectiveBooleanValue, getAnnotations, getSerialNumber, getUnicodeStringValue, isArray, isMap, makeNewContext, simplify, typeCheck
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, materialize
-
Methods inherited from interface net.sf.saxon.om.Item
getLength, getStringValue, head, isStreamed, itemAt, iterate, reduce, subsequence
-
Methods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
-
-
-
Method Detail
-
getKeyManager
public KeyManager getKeyManager()
-
getNamespaceResolver
public NamespaceResolver getNamespaceResolver()
-
internalKeyCall
public static Expression internalKeyCall(KeyManager keyManager, KeyDefinitionSet keySet, java.lang.String name, Expression value, Expression doc, RetainedStaticContext rsc)
Factory method to create an internal call on key() with a known key definition- Parameters:
keySet
- the set of KeyDefinitions (always a single KeyDefinition)name
- the name allocated to the key (first argument of the function)value
- the value being searched for (second argument of the function)doc
- the document being searched (third argument)- Returns:
- a call on the key() function
-
getSpecialProperties
public int getSpecialProperties(Expression[] arguments)
Get the static properties of this expression (other than its type). The result is bit-signficant. These properties are used for optimizations. In general, if a property bit is set, it is true, but if it is unset, the value is unknown.- Overrides:
getSpecialProperties
in classSystemFunction
- Parameters:
arguments
- expressions supplied as arguments in the function call- Returns:
- the properties
-
copy
public SystemFunction copy()
Description copied from interface:StatefulSystemFunction
Make a copy of this SystemFunction. This is required only for system functions such as regex functions that maintain state on behalf of a particular caller.- Specified by:
copy
in interfaceStatefulSystemFunction
- Returns:
- a copy of the system function able to contain its own copy of the state on behalf of the caller.
-
fixArguments
public Expression fixArguments(Expression... arguments) throws XPathException
Allow the function to create an optimized call based on the values of the actual arguments. This binds the key definition in the common case where the key name is defined statically- Overrides:
fixArguments
in classSystemFunction
- Parameters:
arguments
- the supplied arguments to the function call. Note: modifying the contents of this array should not be attempted, it is likely to have no effect.- Returns:
- either a function call on this function, or an expression that delivers the same result, or null indicating that no optimization has taken place
- Throws:
XPathException
- if an error is detected
-
addToPathMap
public PathMap.PathMapNodeSet addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)
Add a representation of this expression to a PathMap. The PathMap captures a map of the nodes visited by an expression in a source tree.The default implementation of this method assumes that an expression does no navigation other than the navigation done by evaluating its subexpressions, and that the subexpressions are evaluated in the same context as the containing expression. The method must be overridden for any expression where these assumptions do not hold. For example, implementations exist for AxisExpression, ParentExpression, and RootExpression (because they perform navigation), and for the doc(), document(), and collection() functions because they create a new navigation root. Implementations also exist for PathExpression and FilterExpression because they have subexpressions that are evaluated in a different context from the calling expression.
- Parameters:
pathMap
- the PathMap to which the expression should be addedpathMapNodeSet
- the PathMapNodeSet to which the paths embodied in this expression should be added- Returns:
- the pathMapNodeSet representing the points in the source document that are both reachable by this expression, and that represent possible results of this expression. For an expression that does navigation, it represents the end of the arc in the path map that describes the navigation route. For other expressions, it is the same as the input pathMapNode.
-
call
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException
Evaluate the expression- Specified by:
call
in interfaceCallable
- Parameters:
context
- the dynamic evaluation contextarguments
- the values of the arguments, supplied as Sequences- Returns:
- the result of the evaluation, in the form of a Sequence
- Throws:
XPathException
- if a dynamic error occurs during the evaluation of the expression
-
search
protected static Sequence search(KeyManager keyManager, XPathContext context, Sequence sought, NodeInfo origin, KeyDefinitionSet selectedKeySet) throws XPathException
- Throws:
XPathException
-
-