private void chunkUpFeatureFile(final String fileContents, final FeatureFile ff) {
        // get the feature name / description
        // split the feature file up

        final String topLevelFeatureElements[] = fileContents
                .split("(?=Tags:)|(?=Feature:)|(?=Background:)|(?=Scenario:)|(?=Scenario Outline:)");

        Set<String> currentTags = null;

        if (topLevelFeatureElements != null) {
            String currentBackground = null;

            for (final String element : topLevelFeatureElements) {

                if (!Strings.isNullOrEmpty(element)) {

                    this.log.trace("topLevelElement:\n" + element);

                    // grab the identifer

                    final Matcher m = DIRECTIVE_PATTERN.matcher(element);
                    if (m.lookingAt()) {
                        final Directive directive = directiveMap.get(m.group(1));

                        switch (directive) {
                            case TAGS: {
                                if (currentTags == null) {
                                    currentTags = new HashSet<String>();
                                }
                                processTags(currentTags, element);
                                break;
                            }
                            case FEATURE: {
                                ff.setRawText(element);
                                if (currentTags != null) {
                                    ff.setTags(currentTags);
                                }
                                currentTags = null;
                                currentBackground = null;
                                break;
                            }
                            case BACKGROUND: {
                                // stash
                                currentBackground = element;
                                break;
                            }
                            case SCENARIO:
                            case SCENARIO_OUTLINE: {

                                final String firstLinePattern = getFirstLinePattern(element);

                                final Pattern finderPattern = Pattern.compile(firstLinePattern);

                                final Matcher matcher = finderPattern
                                        .matcher(this.currentFileContents.getFullContent());
                                int start = -1;

                                if (matcher.find()) {
                                    start = matcher.start(0);
                                    // start offsets of this elem into the
                                    // original file
                                }

                                processScenarioDirective(ff, currentTags, currentBackground, element,
                                        directive == Directive.SCENARIO_OUTLINE, start);

                                currentTags = null;
                                break;
                            }
                            default: {
                                this.log.error("unknown directive");
                                break;
                            }
                        }
                    }

                }
            }
        }
    }
private void chunkUpFeatureFile ( final String fileContents , final FeatureFile ff ) { final String topLevelFeatureElements [ ] = fileContents . split ( "(?=Tags:)|(?=Feature:)|(?=Background:)|(?=Scenario:)|(?=Scenario Outline:)" ) ; Set < String > currentTags = null ; if ( topLevelFeatureElements != null ) { String currentBackground = null ; for ( final String element : topLevelFeatureElements ) { if ( ! Strings . isNullOrEmpty ( element ) ) { this . log . trace ( "topLevelElement:\n" + element ) ; final Matcher m = DIRECTIVE_PATTERN . matcher ( element ) ; if ( m . lookingAt ( ) ) { final Directive directive = directiveMap . get ( m . group ( 1 ) ) ; switch ( directive ) { case TAGS : { if ( currentTags == null ) { currentTags = new HashSet < String > ( ) ; } processTags ( currentTags , element ) ; break ; } case FEATURE : { ff . setRawText ( element ) ; if ( currentTags != null ) { ff . setTags ( currentTags ) ; } currentTags = null ; currentBackground = null ; break ; } case BACKGROUND : { currentBackground = element ; break ; } case SCENARIO : case SCENARIO_OUTLINE : { final String firstLinePattern = getFirstLinePattern ( element ) ; final Pattern finderPattern = Pattern . compile ( firstLinePattern ) ; final Matcher matcher = finderPattern . matcher ( this . currentFileContents . getFullContent ( ) ) ; int start = - 1 ; if ( matcher . find ( ) ) { start = matcher . start ( 0 ) ; } processScenarioDirective ( ff , currentTags , currentBackground , element , directive == Directive . SCENARIO_OUTLINE , start ) ; currentTags = null ; break ; } default : { this . log . error ( "unknown directive" ) ; break ; } } } } } } }
@param fileContents
@param ff