Package net.sf.saxon.pattern

## Class VennPattern

- java.lang.Object
- - net.sf.saxon.expr.Expression
  - - net.sf.saxon.expr.PseudoExpression
    - - net.sf.saxon.pattern.Pattern
      - - net.sf.saxon.pattern.VennPattern

- All Implemented Interfaces:
    `ExportAgent`, `Locatable`, `IdentityComparable`, `Traceable`
  Direct Known Subclasses:
    `ExceptPattern`, `IntersectPattern`, `UnionPattern`

      public abstract class VennPattern
      extends Pattern

  Abstract pattern formed as the union, intersection, or difference of two other patterns; concrete subclasses are used for the different operators

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected Pattern` | `p1` |
    `protected Pattern` | `p2` |

    - ### 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
    Constructor | Description
    --- | ---
    `VennPattern​(Pattern p1, Pattern p2)` | Constructor

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `int` | `allocateSlots​(SlotManager slotManager, int nextFree)` | Allocate slots to any variables used within the pattern
    `void` | `bindCurrent​(LocalBinding binding)` | Replace any calls on current() by a variable reference bound to the supplied binding
    `int` | `computeHashCode()` | Hashcode supporting equals()
    `boolean` | `equals​(java.lang.Object other)` | Determine whether this pattern is the same as another pattern
    `void` | `export​(ExpressionPresenter presenter)` | Diagnostic print of expression structure.
    `void` | `gatherComponentPatterns​(java.util.Set<Pattern> set)` | Gather the component (non-Venn) patterns of this Venn pattern
    `int` | `getDependencies()` | Get the dependencies of the pattern.
    `Pattern` | `getLHS()` | Get the LHS of the union
    `protected abstract java.lang.String` | `getOperatorName()` | Get the relevant operator: "union", "intersect", or "except"
    `Pattern` | `getRHS()` | Get the RHS of the union
    `boolean` | `isMotionless()` | Test whether a pattern is motionless, that is, whether it can be evaluated against a node without repositioning the input stream.
    `boolean` | `matchesCurrentGroup()` | Ask whether the pattern is anchored on a call on current-group()
    `java.lang.Iterable<Operand>` | `operands()` | Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.
    `java.lang.String` | `reconstruct()` | Get the pattern text for diagnostics
    `Pattern` | `simplify()` | Simplify the pattern: perform any context-independent optimisations
    `Pattern` | `typeCheck​(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType)` | Type-check the pattern.

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

      `convertToTypedPattern, copy, effectiveBooleanValue, getDefaultPriority, getFingerprint, getHostLanguage, getItemType, getOriginalText, getUType, handleDynamicError, isLiftable, isRecoverable, make, matches, matchesBeneathAnchor, optimize, patternContainsVariable, replaceCurrent, selectNodes, setOriginalText, setPriority, setRecoverable, 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, computeSpecialProperties, computeStaticProperties, dynamicError, 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, 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`

- - ### Field Detail

    - #### p1

          protected Pattern p1

    - #### p2

          protected Pattern p2

  - ### Constructor Detail

    - #### VennPattern

          public VennPattern​(Pattern p1,
                             Pattern p2)

      Constructor
      Parameters:
        `p1` - the left-hand operand
        `p2` - the right-hand operand

  - ### Method Detail

    - #### operands

          public java.lang.Iterable<Operand> operands()

      Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression. Default implementation works off the results of iterateSubExpressions()

      If the expression is a Callable, then it is required that the order of the operands returned by this function is the same as the order of arguments supplied to the corresponding call() method.

      Overrides:
        `operands` in class `Expression`
      Returns:
        an iterator containing the sub-expressions of this expression

    - #### simplify

          public Pattern simplify()
                           throws XPathException

      Simplify the pattern: perform any context-independent optimisations
      Overrides:
        `simplify` in class `Pattern`
      Returns:
        the simplified expression (or the original if unchanged, or if modified in-situ)
      Throws:
        `XPathException` - if an error is discovered during expression rewriting

    - #### typeCheck

          public Pattern typeCheck​(ExpressionVisitor visitor,
                                   ContextItemStaticInfo contextItemType)
                            throws XPathException

      Type-check the pattern. This is only needed for patterns that contain variable references or function calls.
      Overrides:
        `typeCheck` in class `Pattern`
      Parameters:
        `visitor` - the expression visitor
        `contextItemType` - the type of the context item at the point where the pattern is defined. Set to null if it is known that the context item is undefined.
      Returns:
        the optimised Pattern
      Throws:
        `XPathException` - if an error is discovered during this phase (typically a type error)

    - #### bindCurrent

          public void bindCurrent​(LocalBinding binding)

      Replace any calls on current() by a variable reference bound to the supplied binding
      Overrides:
        `bindCurrent` in class `Pattern`

    - #### isMotionless

          public boolean isMotionless()

      Test whether a pattern is motionless, that is, whether it can be evaluated against a node without repositioning the input stream. This is a necessary condition for patterns used as the match pattern of a streamed template rule.
      Overrides:
        `isMotionless` in class `Pattern`
      Returns:
        true if the pattern is motionless, that is, if it can be evaluated against a streamed node without changing the position in the streamed input file

    - #### allocateSlots

          public int allocateSlots​(SlotManager slotManager,
                                   int nextFree)

      Allocate slots to any variables used within the pattern
      Overrides:
        `allocateSlots` in class `Pattern`
      Parameters:
        `slotManager` - represents the stack frame on which slots are allocated
        `nextFree` - the next slot that is free to be allocated @return the next slot that is free to be allocated
      Returns:
        the next slot that is free to be allocated

    - #### gatherComponentPatterns

          public void gatherComponentPatterns​(java.util.Set<Pattern> set)

      Gather the component (non-Venn) patterns of this Venn pattern
      Parameters:
        `set` - the set into which the components will be added

    - #### getDependencies

          public int getDependencies()

      Get the dependencies of the pattern. The only possible dependency for a pattern is on local variables. This is analyzed in those patterns where local variables may appear.
      Overrides:
        `getDependencies` in class `Pattern`
      Returns:
        the dependencies, as a bit-significant mask

    - #### getLHS

          public Pattern getLHS()

      Get the LHS of the union
      Returns:
        the first operand of the union

    - #### getRHS

          public Pattern getRHS()

      Get the RHS of the union
      Returns:
        the second operand of the union

    - #### 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

    - #### equals

          public boolean equals​(java.lang.Object other)

      Determine whether this pattern is the same as another pattern
      Overrides:
        `equals` in class `Expression`
      Parameters:
        `other` - the other object
      Returns:
        true if the other operand is an expression and if it can be determined that the two expressions are equivalent, in the sense that they will always return the same result.

    - #### computeHashCode

          public int computeHashCode()

      Hashcode supporting equals()
      Overrides:
        `computeHashCode` in class `Expression`
      Returns:
        a computed hash code

    - #### getOperatorName

          protected abstract java.lang.String getOperatorName()

      Get the relevant operator: "union", "intersect", or "except"
      Returns:
        the operator, as a string

    - #### reconstruct

          public java.lang.String reconstruct()

      Get the pattern text for diagnostics
      Overrides:
        `reconstruct` in class `Pattern`

    - #### 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`
      Specified by:
        `export` in class `Pattern`
      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.