org.jbehave.core.parser
Interface StepPatternBuilder

All Known Implementing Classes:
PrefixCapturingPatternBuilder

public interface StepPatternBuilder

Builds a regex pattern from a template step, as provided in the annotations, which will in turn match real steps conforming to the template. Eg: "I give $money to $name" becomes "I give (.*) to (.*)", which matches "I give £10 to Fred". The captured arguments will be "£10" and "Fred".

To create your own pattern builder, the text in the annotation should be converted to a pattern that matches a real step in the core with any precursor words removed. The arguments in the real step should be the only captured groups.


Method Summary
 java.util.regex.Pattern buildPattern(java.lang.String matchThis)
          Builds a regexp pattern from a template step.
 java.lang.String[] extractGroupNames(java.lang.String string)
          Extract the parameter names from a template step
 

Method Detail

buildPattern

java.util.regex.Pattern buildPattern(java.lang.String matchThis)
Builds a regexp pattern from a template step.

Parameters:
matchThis - the template step
Returns:
a regexp pattern which will capture the arguments associated with a matching real step

extractGroupNames

java.lang.String[] extractGroupNames(java.lang.String string)
Extract the parameter names from a template step

Parameters:
step - the template step
Returns:
an array of parameter names


Copyright © 2003-2010. All Rights Reserved.