net.sf.saxon.pattern

## Class BooleanExpressionPattern

- java.lang.Object
- - net.sf.saxon.pattern.Pattern
  - - net.sf.saxon.pattern.BooleanExpressionPattern

- All Implemented Interfaces:
    Serializable, SourceLocator, Container, PatternFinder

      public class BooleanExpressionPattern
      extends Pattern

  A BooleanExpressionPattern is a pattern of the form ?{ Expr } introduced in XSLT 3.0. It matches an item if the expression has an effective boolean value of true() when evaluated with that item as the singleton focus.
  Author:
    Michael H. Kay
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BooleanExpressionPattern(Expression expression)` Create a BooleanExpressionPattern

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `allocateSlots(SlotManager slotManager, int nextFree)` Allocate slots to any variables used within the pattern
    `Pattern` | `analyze(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType)` Type-check the pattern.
    `boolean` | `equals(Object other)` Determine whether this pattern is the same as another pattern
    `double` | `getDefaultPriority()` Determine the default priority of this item type test when used on its own as a Pattern
    `int` | `getFingerprint()` Determine the name fingerprint of nodes to which this pattern applies.
    `ItemType` | `getItemType()` Get an Itemtype that all the items matching this pattern must satisfy
    `int` | `getNodeKind()` Determine the types of nodes to which this pattern applies.
    `int` | `hashCode()` Hashcode supporting equals()
    `Iterator<Expression>` | `iterateSubExpressions()` Iterate over the subexpressions within this pattern
    `boolean` | `matches(Item item, XPathContext context)` Determine whether this Pattern matches the given item.
    `String` | `toString()` Display the pattern for diagnostics

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

      `bindCurrent, getColumnNumber, getContainerGranularity, getDependencies, getExecutable, getHostLanguage, getLineNumber, getLocationProvider, getPublicId, getSystemId, isMotionless, make, matchesBeneathAnchor, promote, replaceCurrent, replaceSubExpression, selectNodes, setExecutable, setLineNumber, setOriginalText, setSystemId, simplify`

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

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

- - ### Constructor Detail

    - #### BooleanExpressionPattern

          public BooleanExpressionPattern(Expression expression)

      Create a BooleanExpressionPattern
      Parameters:
        `expression` - the expression to be evaluated

  - ### Method Detail

    - #### allocateSlots

          public int allocateSlots(SlotManager slotManager,
                          int nextFree)

      Allocate slots to any variables used within the pattern
      Overrides:
        `allocateSlots` in class `Pattern`
      Parameters:
        `slotManager` - holds details of the allocated slots
        `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

    - #### iterateSubExpressions

          public Iterator<Expression> iterateSubExpressions()

      Iterate over the subexpressions within this pattern
      Overrides:
        `iterateSubExpressions` in class `Pattern`
      Returns:
        an iterator over the subexpressions. Default implementation returns an empty sequence

    - #### analyze

          public Pattern analyze(ExpressionVisitor visitor,
                        ExpressionVisitor.ContextItemType contextItemType)
                          throws XPathException

      Type-check the pattern.
      Overrides:
        `analyze` 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`

    - #### matches

          public boolean matches(Item item,
                        XPathContext context)

      Determine whether this Pattern matches the given item. This is the main external interface for matching patterns: it sets current() to the node being tested
      Specified by:
        `matches` in class `Pattern`
      Parameters:
        `item` - The item to be tested against the Pattern
        `context` - The context in which the match is to take place. Only relevant if the pattern uses variables, or contains calls on functions such as document() or key().
      Returns:
        true if the item matches the Pattern, false otherwise

    - #### getItemType

          public ItemType getItemType()

      Get an Itemtype that all the items matching this pattern must satisfy
      Specified by:
        `getItemType` in class `Pattern`
      Returns:
        an ItemType, as specific as possible, which all the matching items satisfy

    - #### getDefaultPriority

          public final double getDefaultPriority()

      Determine the default priority of this item type test when used on its own as a Pattern
      Overrides:
        `getDefaultPriority` in class `Pattern`
      Returns:
        the default priority for the pattern

    - #### getNodeKind

          public int getNodeKind()

      Determine the types of nodes to which this pattern applies. Used for optimisation. For patterns that match nodes of several types, return Type.NODE. For patterns that do not match nodes, return -1.
      Overrides:
        `getNodeKind` in class `Pattern`
      Returns:
        the type of node matched by this pattern. e.g. Type.ELEMENT or Type.TEXT

    - #### getFingerprint

          public int getFingerprint()

      Determine the name fingerprint of nodes to which this pattern applies. Used for optimisation.
      Overrides:
        `getFingerprint` in class `Pattern`
      Returns:
        A fingerprint that the nodes must match, or -1 if it can match multiple fingerprints

    - #### toString

          public String toString()

      Display the pattern for diagnostics
      Overrides:
        `toString` in class `Pattern`

    - #### equals

          public boolean equals(Object other)

      Determine whether this pattern is the same as another pattern
      Overrides:
        `equals` in class `Object`
      Parameters:
        `other` - the other object

    - #### hashCode

          public int hashCode()

      Hashcode supporting equals()
      Overrides:
        `hashCode` in class `Object`

Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.