##### Coverage Report - org.jbehave.core.parsers.RegexStepMatcher

Classes in this File | Line Coverage | Branch Coverage | Complexity
RegexStepMatcher |
100% | 14/14
N/A | N/A
| 1.0;1

1 |  |
     package org.jbehave.core.parsers;
2 |  |
3 |  |
     import java.util.regex.Matcher;
4 |  |
     import java.util.regex.Pattern;
5 |  |
6 |  |
     import org.jbehave.core.model.StepPattern;
7 |  |
     import org.jbehave.core.steps.StepType;
8 |  |
9 |  |
     public class RegexStepMatcher implements StepMatcher {
10 |  |
11 |  |
         private final Pattern regexPattern;
12 |  |
             private final String[] parameterNames;
13 |  |
         private final StepPattern stepPattern;
14 |  |
         private Matcher matcher;
15 |  |
16 | 126 |
             public RegexStepMatcher(StepType stepType, String annotatedPattern, Pattern regexPattern, String[] parameterNames) {
17 | 126 |
             this.regexPattern = regexPattern;
18 | 126 |
                     this.parameterNames = parameterNames;
19 | 126 |
             this.stepPattern = new StepPattern(stepType, annotatedPattern, regexPattern.pattern());
20 | 126 |
         }
21 |  |
22 |  |
             public boolean matches(String stepWithoutStartingWord){
23 | 73 |
                     matcher(stepWithoutStartingWord);
24 | 73 |
                     return matcher.matches();
25 |  |
             }
26 |  |
27 |  |
             public boolean find(String stepWithoutStartingWord){
28 | 86 |
                     matcher(stepWithoutStartingWord);
29 | 86 |
                     return matcher.find();
30 |  |
             }
31 |  |
32 |  |
             public String parameter(int matchedPosition) {
33 | 53 |
                     return matcher.group(matchedPosition);
34 |  |
             }
35 |  |
36 |  |
             private void matcher(String patternToMatch){
37 | 159 |
                     matcher = regexPattern.matcher(patternToMatch);
38 | 159 |
             }
39 |  |
40 |  |
             public String[] parameterNames(){
41 | 127 |
                     return parameterNames;
42 |  |
             }
43 |  |
44 |  |
         public StepPattern pattern() {
45 | 55 |
             return stepPattern;
46 |  |
         }
47 |  |
     }