Class KeyFn

All Implemented Interfaces:
Callable, StatefulSystemFunction, FunctionItem, GroundedValue, Item, Sequence

public class KeyFn extends SystemFunction implements StatefulSystemFunction
  • Constructor Details Link icon

    • KeyFn Link icon

      public KeyFn()
  • Method Details Link icon

    • getKeyManager Link icon

      public KeyManager getKeyManager()
    • getNamespaceResolver Link icon

      public NamespaceResolver getNamespaceResolver()
    • internalKeyCall Link icon

      public static Expression internalKeyCall(KeyManager keyManager, KeyDefinitionSet keySet, 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 Link icon

      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 class SystemFunction
      Parameters:
      arguments - expressions supplied as arguments in the function call
      Returns:
      the properties
    • copy Link icon

      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 interface StatefulSystemFunction
      Returns:
      a copy of the system function able to contain its own copy of the state on behalf of the caller.
    • fixArguments Link icon

      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 class SystemFunction
      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 Link icon

      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 added
      pathMapNodeSet - 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 Link icon

      public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException
      Evaluate the expression
      Specified by:
      call in interface Callable
      Parameters:
      context - the dynamic evaluation context
      arguments - 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 Link icon

      protected static Sequence search(KeyManager keyManager, XPathContext context, Sequence sought, NodeInfo origin, KeyDefinitionSet selectedKeySet) throws XPathException
      Throws:
      XPathException