Class FocusContext

java.lang.Object
dev.metaschema.core.metapath.FocusContext

public final class FocusContext extends Object
Represents the focus context for Metapath evaluation, containing the context item, position, and size as defined in the XPath 3.1 evaluation context.

The focus context is established when evaluating predicates and provides the information needed by the fn:position() and fn:last() functions.

  • Method Details

    • of

      @NonNull public static FocusContext of(@NonNull IItem item, int position, int size)
      Create a new focus context for the given item at the specified position within a sequence.
      Parameters:
      item - the context item
      position - the 1-based position of the item within the sequence
      size - the total number of items in the sequence
      Returns:
      a new focus context
      Throws:
      IllegalArgumentException - if position is less than 1, size is less than 1, or position is greater than size
    • getContextItem

      @NonNull public IItem getContextItem()
      Get the context item.
      Returns:
      the context item
    • getPosition

      public int getPosition()
      Get the context position.

      This is the 1-based position of the context item within the sequence currently being processed, as returned by fn:position().

      Returns:
      the context position (1-based)
    • getSize

      public int getSize()
      Get the context size.

      This is the total number of items in the sequence currently being processed, as returned by fn:last().

      Returns:
      the context size