| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.fest.swing.util; |
| 17 |
|
|
| 18 |
|
import static org.fest.swing.util.Patterns.format; |
| 19 |
|
import static org.fest.swing.util.Strings.match; |
| 20 |
|
import static org.fest.util.Arrays.isEmpty; |
| 21 |
|
import static org.fest.util.Strings.quote; |
| 22 |
|
|
| 23 |
|
import java.util.regex.Pattern; |
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
@author |
| 30 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 10 |
Complexity Density: 0.62 |
|
| 31 |
|
public class PatternTextMatcher implements TextMatcher { |
| 32 |
|
|
| 33 |
|
private final Pattern[] patterns; |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
@link |
| 37 |
|
@param |
| 38 |
|
@throws |
| 39 |
|
@throws |
| 40 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 41 |
59
|
public PatternTextMatcher(Pattern...patterns) {... |
| 42 |
3
|
if (patterns == null) throw new NullPointerException("The array of patterns should not be null"); |
| 43 |
3
|
if (isEmpty(patterns)) throw new IllegalArgumentException("The array of patterns should not be empty"); |
| 44 |
53
|
this.patterns = patterns; |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
@param |
| 50 |
|
@return |
| 51 |
|
|
| 52 |
|
@throws |
| 53 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 54 |
146
|
public boolean isMatching(String text) {... |
| 55 |
146
|
for (Pattern pattern : patterns) |
| 56 |
36
|
if (match(pattern, text)) return true; |
| 57 |
109
|
return false; |
| 58 |
|
} |
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
|
@return |
| 64 |
|
|
| 65 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 66 |
9
|
public String description() {... |
| 67 |
8
|
if (onlyOnePattern()) return "pattern"; |
| 68 |
1
|
return "patterns"; |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
@return |
| 74 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 75 |
9
|
public String formattedValues() {... |
| 76 |
8
|
if (onlyOnePattern()) return quote(patterns[0].pattern()); |
| 77 |
1
|
return format(patterns); |
| 78 |
|
} |
| 79 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 80 |
18
|
private boolean onlyOnePattern() {... |
| 81 |
18
|
return patterns.length == 1; |
| 82 |
|
} |
| 83 |
|
} |