Class KeyFn

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

public class KeyFn extends SystemFunction implements StatefulSystemFunction
  • Constructor Details

    • KeyFn

      public KeyFn()
  • Method Details

    • getKeyManager

      public KeyManager getKeyManager()
    • getNamespaceResolver

      public NamespaceResolver getNamespaceResolver()
    • internalKeyCall

      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

      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

      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

      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
    • call

      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

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