| **where(condition)** | Defines a condition for the current pattern. To match the pattern, an event must satisfy the condition. Multiple consecutive where() clauses lead to their conditions being ANDed:
<figure class="highlight">
```
---
pattern.where(event => ... /* some condition */)
| **or(condition)** | Adds a new condition which is ORed with an existing one. An event can match the pattern only if it passes at least one of the conditions:
<figure class="highlight">
```
```
pattern.where(event => ... /* some condition */)
pattern.timesOrMore(2);
.or(event => ... /* alternative condition */)
```
```
</figure>
|
| **until(condition)** | Specifies a stop condition for looping pattern. Meaning if event matching the given condition occurs, no more events will be accepted into the pattern.Applicable only in conjunction with `oneOrMore()`**NOTE:** It allows for cleaning state for corresponding pattern on event-based condition.
<figure class="highlight">
---
```
模式算子操作:`次(#ofTimes)`
pattern.oneOrMore().until(event => ... /* some condition */)
| **subtype(subClass)** | Defines a subtype condition for the current pattern. An event can only match the pattern if it is of this subtype:
<figure class="highlight">
```
```
pattern.subtype(classOf[SubEvent])
pattern.times(2);
```
```
</figure>
|
| **oneOrMore()** | Specifies that this pattern expects at least one occurrence of a matching event.By default a relaxed internal contiguity (between subsequent events) is used. For more info on internal contiguity see [consecutive](#consecutive_scala).**NOTE:** It is advised to use either `until()` or `within()` to enable state clearing
| **timesOrMore(#times)** | Specifies that this pattern expects at least **#times** occurrences of a matching event.By default a relaxed internal contiguity (between subsequent events) is used. For more info on internal contiguity see [consecutive](#consecutive_scala).
<figure class="highlight">
```
```
pattern.timesOrMore(2)
pattern.times(2, 4);
```
```
</figure>
|
| **times(#ofTimes)** | Specifies that this pattern expects an exact number of occurrences of a matching event.By default a relaxed internal contiguity (between subsequent events) is used. For more info on internal contiguity see [consecutive](#consecutive_scala).
<figure class="highlight">
```
---
pattern.times(2)
```
</figure>
模式算子操作:`Optional()`
|
描述:指定此模式是可选的,即根本不会发生。这适用于所有上述量词。
| **times(#fromTimes, #toTimes)** | Specifies that this pattern expects occurrences between **#fromTimes** and **#toTimes** of a matching event.By default a relaxed internal contiguity (between subsequent events) is used. For more info on internal contiguity see [consecutive](#consecutive_java).
<figure class="highlight">
```
```
pattern.times(2, 4)
pattern.oneOrMore().optional();
```
```
</figure>
|
| **optional()** | Specifies that this pattern is optional, i.e. it may not occur at all. This is applicable to all aforementioned quantifiers.
<figure class="highlight">
---
```
模式算子操作:`greedy()`
pattern.oneOrMore().optional()
```
</figure>
描述:指定此模式是贪婪的,即它将尽可能多地重复。这仅适用于量词,目前不支持组模式。
|
| **greedy()** | Specifies that this pattern is greedy, i.e. it will repeat as many as possible. This is only applicable to quantifiers and it does not support group pattern currently.
| **consecutive()** | Works in conjunction with `oneOrMore()` and `times()` and imposes strict contiguity between the matching events, i.e. any non-matching element breaks the match (as in `next()`).If not applied a relaxed contiguity (as in `followedBy()`) is used.E.g. a pattern like:
| **consecutive()** | Works in conjunction with `oneOrMore()` and `times()` and imposes strict contiguity between the matching events, i.e. any non-matching element breaks the match (as in `next()`).If not applied a relaxed contiguity (as in `followedBy()`) is used.E.g. a pattern like:
Will generate the following matches for an input sequence: C D A1 A2 A3 D A4 Bwith consecutive applied: {C A1 B}, {C A1 A2 B}, {C A1 A2 A3 B}without consecutive applied: {C A1 B}, {C A1 A2 B}, {C A1 A2 A3 B}, {C A1 A2 A3 A4 B} |
Will generate the following matches for an input sequence: C D A1 A2 A3 D A4 Bwith consecutive applied: {C A1 B}, {C A1 A2 B}, {C A1 A2 A3 B}without consecutive applied: {C A1 B}, {C A1 A2 B}, {C A1 A2 A3 B}, {C A1 A2 A3 A4 B} |
| **allowCombinations()** | Works in conjunction with `oneOrMore()` and `times()` and imposes non-deterministic relaxed contiguity between the matching events (as in `followedByAny()`).If not applied a relaxed contiguity (as in `followedBy()`) is used.E.g. a pattern like:
| **allowCombinations()** | Works in conjunction with `oneOrMore()` and `times()` and imposes non-deterministic relaxed contiguity between the matching events (as in `followedByAny()`).If not applied a relaxed contiguity (as in `followedBy()`) is used.E.g. a pattern like:
| **begin(#pattern_sequence)** | Defines a starting pattern:
| **begin(#pattern_sequence)** | Defines a starting pattern:
<figure class="highlight">
```
```
val start = Pattern.begin(
val start = Pattern.begin(
...
@@ -1059,23 +928,19 @@ val start = Pattern.begin(
...
@@ -1059,23 +928,19 @@ val start = Pattern.begin(
)
)
```
```
</figure>
|
|
| **next(#name)** | Appends a new pattern. A matching event has to directly succeed the previous matching event (strict contiguity):
| **next(#name)** | Appends a new pattern. A matching event has to directly succeed the previous matching event (strict contiguity):
<figure class="highlight">
```
```
val next = start.next("middle")
val next = start.next("middle")
```
```
</figure>
|
|
| **next(#pattern_sequence)** | Appends a new pattern. A sequence of matching events have to directly succeed the previous matching event (strict contiguity):
| **next(#pattern_sequence)** | Appends a new pattern. A sequence of matching events have to directly succeed the previous matching event (strict contiguity):
<figure class="highlight">
```
```
val next = start.next(
val next = start.next(
...
@@ -1083,23 +948,19 @@ val next = start.next(
...
@@ -1083,23 +948,19 @@ val next = start.next(
)
)
```
```
</figure>
|
|
| **followedBy(#name)** | Appends a new pattern. Other events can occur between a matching event and the previous matching event (relaxed contiguity) :
| **followedBy(#name)** | Appends a new pattern. Other events can occur between a matching event and the previous matching event (relaxed contiguity) :
<figure class="highlight">
```
```
val followedBy = start.followedBy("middle")
val followedBy = start.followedBy("middle")
```
```
</figure>
|
|
| **followedBy(#pattern_sequence)** | Appends a new pattern. Other events can occur between a sequence of matching events and the previous matching event (relaxed contiguity) :
| **followedBy(#pattern_sequence)** | Appends a new pattern. Other events can occur between a sequence of matching events and the previous matching event (relaxed contiguity) :
<figure class="highlight">
```
```
val followedBy = start.followedBy(
val followedBy = start.followedBy(
...
@@ -1107,23 +968,19 @@ val followedBy = start.followedBy(
...
@@ -1107,23 +968,19 @@ val followedBy = start.followedBy(
)
)
```
```
</figure>
|
|
| **followedByAny(#name)** | Appends a new pattern. Other events can occur between a matching event and the previous matching event, and alternative matches will be presented for every alternative matching event (non-deterministic relaxed contiguity):
| **followedByAny(#name)** | Appends a new pattern. Other events can occur between a matching event and the previous matching event, and alternative matches will be presented for every alternative matching event (non-deterministic relaxed contiguity):
<figure class="highlight">
```
```
val followedByAny = start.followedByAny("middle")
val followedByAny = start.followedByAny("middle")
```
```
</figure>
|
|
| **followedByAny(#pattern_sequence)** | Appends a new pattern. Other events can occur between a sequence of matching events and the previous matching event, and alternative matches will be presented for every alternative sequence of matching events (non-deterministic relaxed contiguity):
| **followedByAny(#pattern_sequence)** | Appends a new pattern. Other events can occur between a sequence of matching events and the previous matching event, and alternative matches will be presented for every alternative sequence of matching events (non-deterministic relaxed contiguity):
<figure class="highlight">
```
```
val followedByAny = start.followedByAny(
val followedByAny = start.followedByAny(
...
@@ -1131,40 +988,33 @@ val followedByAny = start.followedByAny(
...
@@ -1131,40 +988,33 @@ val followedByAny = start.followedByAny(
)
)
```
```
</figure>
|
|
| **notNext()** | Appends a new negative pattern. A matching (negative) event has to directly succeed the previous matching event (strict contiguity) for the partial match to be discarded:
| **notNext()** | Appends a new negative pattern. A matching (negative) event has to directly succeed the previous matching event (strict contiguity) for the partial match to be discarded:
<figure class="highlight">
```
```
val notNext = start.notNext("not")
val notNext = start.notNext("not")
```
```
</figure>
|
|
| **notFollowedBy()** | Appends a new negative pattern. A partial matching event sequence will be discarded even if other events occur between the matching (negative) event and the previous matching event (relaxed contiguity):
| **notFollowedBy()** | Appends a new negative pattern. A partial matching event sequence will be discarded even if other events occur between the matching (negative) event and the previous matching event (relaxed contiguity):
<figure class="highlight">
```
```
val notFollowedBy = start.notFollowedBy("not")
val notFollowedBy = start.notFollowedBy("not")
```
```
</figure>
|
|
| **within(time)** | Defines the maximum time interval for an event sequence to match the pattern. If a non-completed event sequence exceeds this time, it is discarded:
| **within(time)** | Defines the maximum time interval for an event sequence to match the pattern. If a non-completed event sequence exceeds this time, it is discarded: