org.eclipse.incquery.runtime.rete.matcher

## Class RetePatternMatcher

- java.lang.Object
- - org.eclipse.incquery.runtime.rete.network.BaseNode
  - - org.eclipse.incquery.runtime.rete.network.StandardNode
    - - org.eclipse.incquery.runtime.rete.single.SingleInputNode
      - - org.eclipse.incquery.runtime.rete.single.TransformerNode
        - - org.eclipse.incquery.runtime.rete.matcher.RetePatternMatcher

- All Implemented Interfaces:
    IQueryResultProvider, Node, Receiver, Supplier, Tunnel

      public class RetePatternMatcher
      extends TransformerNode
      implements IQueryResultProvider

  Author:
    Gabor Bergmann

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RetePatternMatcher(ReteEngine engine, RecipeTraceInfo productionNodeTrace)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addUpdateListener(IUpdateable listener, java.lang.Object listenerTag, boolean fireNow)` Internal method that registers low-level callbacks for match appearance and disappearance.
    `void` | `connect(Receiver receiver, boolean synchronize)` Connects a new external receiver that will receive update notifications from now on.
    `void` | `connect(Receiver receiver, java.lang.Object tag, boolean synchronize)` Connects a new external receiver that will receive update notifications from now on.
    `int` | `count(java.lang.Object[] inputMapping, boolean[] fixed)` Counts the number of occurrences of the pattern that match inputMapping on positions where fixed is true.
    `int` | `countMatches(java.lang.Object[] parameters)` Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
    `void` | `disconnect(Receiver receiver)` Disconnects a child node.
    `boolean` | `disconnectByTag(java.lang.Object tag)` Disconnects the child node that was connected by specifying the given tag.
    `java.util.Collection<? extends Tuple>` | `getAllMatches(java.lang.Object[] parameters)` Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
    `Tuple` | `getOneArbitraryMatch(java.lang.Object[] parameters)` Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
    `IQueryBackend` | `getQueryBackend()` The underlying query evaluator backend.
    `java.util.ArrayList<Tuple>` | `matchAll(java.lang.Object[] inputMapping, boolean[] fixed)`
    `Tuple` | `matchOne(java.lang.Object[] inputMapping, boolean[] fixed)`
    `Tuple` | `matchOneRandomly(java.lang.Object[] inputMapping, boolean[] fixed)`
    `void` | `removeUpdateListener(java.lang.Object listenerTag)` Removes an existing listener previously registered with the given tag.

    - ### Methods inherited from class org.eclipse.incquery.runtime.rete.single.TransformerNode

      `pullInto, update`

    - ### Methods inherited from class org.eclipse.incquery.runtime.rete.single.SingleInputNode

      `appendParent, assignTraceInfo, getParents, propagatePullInto, removeParent`

    - ### Methods inherited from class org.eclipse.incquery.runtime.rete.network.StandardNode

      `appendChild, constructIndex, getPulledContents, getReceivers, removeChild`

    - ### Methods inherited from class org.eclipse.incquery.runtime.rete.network.BaseNode

      `acceptPropagatedTraceInfo, getContainer, getNodeId, getTag, getTraceInfos, setTag, toString`

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

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.incquery.runtime.rete.network.Supplier

      `appendChild, constructIndex, getPulledContents, getReceivers, removeChild`

    - ### Methods inherited from interface org.eclipse.incquery.runtime.rete.network.Node

      `acceptPropagatedTraceInfo, getContainer, getNodeId, getTag, getTraceInfos, setTag`

- - ### Constructor Detail

    - #### RetePatternMatcher

          public RetePatternMatcher(ReteEngine engine,
                                    RecipeTraceInfo productionNodeTrace)

      Parameters:
        `productionNode` - a production node that matches this pattern without any parameter bindings

  - ### Method Detail

    - #### matchOneRandomly

          public Tuple matchOneRandomly(java.lang.Object[] inputMapping,
                                        boolean[] fixed)

    - #### matchAll

          public java.util.ArrayList<Tuple> matchAll(java.lang.Object[] inputMapping,
                                                     boolean[] fixed)

    - #### matchOne

          public Tuple matchOne(java.lang.Object[] inputMapping,
                                boolean[] fixed)

    - #### count

          public int count(java.lang.Object[] inputMapping,
                           boolean[] fixed)

      Counts the number of occurrences of the pattern that match inputMapping on positions where fixed is true.
      Returns:
        the number of occurrences

    - #### connect

          public void connect(Receiver receiver,
                              boolean synchronize)

      Connects a new external receiver that will receive update notifications from now on. The receiver will practically connect to the production node, the added value is unwrapping the updates for external use.
      Parameters:
        `synchronize` - if true, the contents of the production node will be inserted into the receiver after the connection is established.

    - #### connect

          public void connect(Receiver receiver,
                              java.lang.Object tag,
                              boolean synchronize)

      Connects a new external receiver that will receive update notifications from now on. The receiver will practically connect to the production node, the added value is unwrapping the updates for external use. The external receiver will be disconnectable later based on its tag.
      Parameters:
        `tag` - an identifier to recognize the child node by.
        `synchronize` - if true, the contents of the production node will be inserted into the receiver after the connection is established.

    - #### disconnect

          public void disconnect(Receiver receiver)

      Disconnects a child node.

    - #### disconnectByTag

          public boolean disconnectByTag(java.lang.Object tag)

      Disconnects the child node that was connected by specifying the given tag.
      Returns:
        if a child node was found registered with this tag.

    - #### countMatches

          public int countMatches(java.lang.Object[] parameters)

      Description copied from interface: `IQueryResultProvider`
      Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
      Specified by:
        `countMatches` in interface `IQueryResultProvider`
      Parameters:
        `parameters` - array where each non-null element binds the corresponding pattern parameter to a fixed value.
      Returns:
        the number of pattern matches found.

    - #### getOneArbitraryMatch

          public Tuple getOneArbitraryMatch(java.lang.Object[] parameters)

      Description copied from interface: `IQueryResultProvider`
      Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. Neither determinism nor randomness of selection is guaranteed.
      Specified by:
        `getOneArbitraryMatch` in interface `IQueryResultProvider`
      Parameters:
        `parameters` - array where each non-null element binds the corresponding pattern parameter to a fixed value.
      Returns:
        a match represented in the internal `Tuple` representation.

    - #### getAllMatches

          public java.util.Collection<? extends Tuple> getAllMatches(java.lang.Object[] parameters)

      Description copied from interface: `IQueryResultProvider`
      Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
      Specified by:
        `getAllMatches` in interface `IQueryResultProvider`
      Parameters:
        `parameters` - array where each non-null element binds the corresponding pattern parameter to a fixed value.
      Returns:
        matches represented in the internal `Tuple` representation.

    - #### getQueryBackend

          public IQueryBackend getQueryBackend()

      Description copied from interface: `IQueryResultProvider`
      The underlying query evaluator backend.
      Specified by:
        `getQueryBackend` in interface `IQueryResultProvider`

    - #### addUpdateListener

          public void addUpdateListener(IUpdateable listener,
                                        java.lang.Object listenerTag,
                                        boolean fireNow)

      Description copied from interface: `IQueryResultProvider`
      Internal method that registers low-level callbacks for match appearance and disappearance.

      Caution: This is a low-level callback that is invoked when the pattern matcher is not necessarily in a consistent state yet. Importantly, no model modification permitted during the callback.

      The callback can be unregistered via invoking `IQueryResultProvider.removeUpdateListener(Object)` with the same tag.

      Specified by:
        `addUpdateListener` in interface `IQueryResultProvider`
      Parameters:
        `listener` - the listener that will be notified of each new match that appears or disappears, starting from now.
        `listenerTag` - a tag by which to identify the listener for later removal by `IQueryResultProvider.removeUpdateListener(Object)`.
        `fireNow` - if true, the insertion update allback will be immediately invoked on all current matches as a one-time effect.

    - #### removeUpdateListener

          public void removeUpdateListener(java.lang.Object listenerTag)

      Description copied from interface: `IQueryResultProvider`
      Removes an existing listener previously registered with the given tag.
      Specified by:
        `removeUpdateListener` in interface `IQueryResultProvider`