Package com.saxonica.ee.stream

## Class CurrentGroupPattern

- java.lang.Object
- - net.sf.saxon.expr.Expression
  - - net.sf.saxon.expr.PseudoExpression
    - - net.sf.saxon.pattern.Pattern
      - - net.sf.saxon.pattern.AnchorPattern
        - - com.saxonica.ee.stream.CurrentGroupPattern

- All Implemented Interfaces:
    `ExportAgent`, `Locatable`, `IdentityComparable`, `Traceable`

      public class CurrentGroupPattern
      extends AnchorPattern

  This is a special pattern that matches the "anchor node". It is used for the selectors that arise when evaluating XPath expressions in streaming mode; the anchor node is the context node for the streamed XPath evaluation. Given a streamed evaluation of an expression such as ./BOOKS/BOOK/PRICE, the way we evaluate this is to turn it into a pattern, which is then tested against all descendant nodes. Conceptually the pattern is $A/BOOKS/BOOK/PRICE, where $A is referred to as the anchor node. When we evaluate the pattern against (say) a PRICE element, the match will only succeed if the name of the element is "PRICE" and its ancestors are, in order, a BOOK element, a BOOKS element, and the anchor node $A.

- - ### Field Summary

    - ### Fields inherited from class net.sf.saxon.expr.Expression

      `EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_COST, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `CurrentGroupPattern()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `export​(ExpressionPresenter presenter)` | Diagnostic print of expression structure.
    `static CurrentGroupPattern` | `getInstance()` |
    `boolean` | `matchesBeneathAnchor​(NodeInfo node, NodeInfo anchor, XPathContext context)` | Determine whether this pattern matches a given Node within the subtree rooted at a given anchor node.
    `boolean` | `matchesCurrentGroup()` | Ask whether the pattern is anchored on a call on current-group()

    - ### Methods inherited from class net.sf.saxon.pattern.AnchorPattern

      `copy, getItemType, getUType, matches, reconstruct, typeCheck`

    - ### Methods inherited from class net.sf.saxon.pattern.Pattern

      `allocateSlots, bindCurrent, convertToTypedPattern, effectiveBooleanValue, getDefaultPriority, getDependencies, getFingerprint, getHostLanguage, getOriginalText, handleDynamicError, isLiftable, isMotionless, isRecoverable, make, optimize, patternContainsVariable, replaceCurrent, selectNodes, setOriginalText, setPriority, setRecoverable, simplify, toPattern, toShortString, toString`

    - ### Methods inherited from class net.sf.saxon.expr.PseudoExpression

      `computeCardinality, evaluateAsString, evaluateItem, getImplementationMethod, iterate, process`

    - ### Methods inherited from class net.sf.saxon.expr.Expression

      `addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeHashCode, computeSpecialProperties, computeStaticProperties, dynamicError, equals, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getCost, getEvaluationMethod, getExpressionName, getExtraProperty, getIntegerBounds, getInterpretedExpression, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getStreamerName, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, markTailFunctionCalls, operandList, operands, operandSparseList, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplifyChildren, staticTypeCheck, suppressValidation, typeCheckChildren, typeError, unordered, verifyParentPointers`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface net.sf.saxon.trace.Traceable

      `gatherProperties`

- - ### Constructor Detail

    - #### CurrentGroupPattern

          protected CurrentGroupPattern()

  - ### Method Detail

    - #### getInstance

          public static CurrentGroupPattern getInstance()

    - #### matchesCurrentGroup

          public boolean matchesCurrentGroup()

      Ask whether the pattern is anchored on a call on current-group()
      Overrides:
        `matchesCurrentGroup` in class `Pattern`
      Returns:
        true if calls on matchesBeneathAnchor should test with all nodes in the current group as anchor nodes. If false, only the first node in a group is treated as the anchor node

    - #### matchesBeneathAnchor

          public boolean matchesBeneathAnchor​(NodeInfo node,
                                              NodeInfo anchor,
                                              XPathContext context)
                                       throws XPathException

      Description copied from class: `AnchorPattern`
      Determine whether this pattern matches a given Node within the subtree rooted at a given anchor node. This method is used when the pattern is used for streaming.
      Overrides:
        `matchesBeneathAnchor` in class `AnchorPattern`
      Parameters:
        `node` - The NodeInfo representing the Element or other node to be tested against the Pattern
        `anchor` - The anchor node, which must match any AnchorPattern subpattern
        `context` - The dynamic context. Only relevant if the pattern uses variables, or contains calls on functions such as document() or key().
      Returns:
        true if the node matches the Pattern, false otherwise
      Throws:
        `XPathException` - if an error occurs while matching the pattern (the caller will usually treat this the same as a false result)

    - #### export

          public void export​(ExpressionPresenter presenter)
                      throws XPathException

      Description copied from class: `Expression`
      Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
      Specified by:
        `export` in interface `ExportAgent`
      Overrides:
        `export` in class `AnchorPattern`
      Parameters:
        `presenter` - the expression presenter used to display the structure
      Throws:
        `XPathException` - if the export fails, for example if an expression is found that won't work in the target environment.