Package org.jbehave.core.io
Class StoryFinder
- java.lang.Object
-
- org.jbehave.core.io.StoryFinder
-
public class StoryFinder extends Object
Finds stories by scanning source paths, which can be either filesystem directories or jars. Jars are identified by paths ending in ".jar".
Stories can be either in the form of class names or story paths.
The default class name extension is ".java".
Stories can be sorted by providing a sorting
Comparator
. Alternatively, stories can be sorted at execution-time using theConfiguration.useStoryExecutionComparator(Comparator)
instead.
-
-
Constructor Summary
Constructors Constructor Description StoryFinder()
Creates default StoryFinder for ".java" class names and no sorting.StoryFinder(String classNameExtension)
Creates a StoryFinder with a given class name extension and no sorting.StoryFinder(Comparator<? super String> sortingComparator)
Creates a StoryFinder with a given sorting comparator.
-
Method Summary
Modifier and Type Method Description protected String
classNameExtension()
protected List<String>
classNames(List<String> paths)
List<String>
findClassNames(String searchIn, List<String> includes, List<String> excludes)
Finds Java classes from a source path, allowing for includes/excludes, and converts them to class names.List<String>
findPaths(String searchIn, String[] includes, String[] excludes)
Finds paths from a source path, allowing for include/exclude patterns.List<String>
findPaths(String searchIn, String include, String exclude)
Finds paths from a source path, allowing for include/exclude patterns, which can be comma-separated values of multiple patterns.List<String>
findPaths(String searchIn, List<String> includes, List<String> excludes)
Finds paths from a source path, allowing for include/exclude patterns.List<String>
findPaths(String searchIn, List<String> includes, List<String> excludes, String prefixWith)
Finds paths from a source path, allowing for includes/excludes.List<String>
findPaths(URL searchIn, String[] includes, String[] excludes)
Finds paths from a source URL, allowing for includes/excludes patterns.List<String>
findPaths(URL searchIn, String include, String exclude)
Finds paths from a source URL, allowing for single include/exclude pattern.List<String>
findPaths(URL searchIn, List<String> includes, List<String> excludes)
Finds paths from a source URL, allowing for includes/excludes patterns.protected List<String>
normalise(List<String> paths)
protected List<String>
prefix(String prefixWith, List<String> paths)
protected List<String>
scan(String source, List<String> includes, List<String> excludes)
protected List<String>
scanJar(String jarPath, List<String> includes, List<String> excludes)
protected List<String>
sort(List<String> input)
protected Comparator<? super String>
sortingComparator()
Comparator used for sorting.
-
-
-
Constructor Detail
-
StoryFinder
public StoryFinder()
Creates default StoryFinder for ".java" class names and no sorting.
-
StoryFinder
public StoryFinder(String classNameExtension)
Creates a StoryFinder with a given class name extension and no sorting.- Parameters:
classNameExtension
- the extension
-
StoryFinder
public StoryFinder(Comparator<? super String> sortingComparator)
Creates a StoryFinder with a given sorting comparator.- Parameters:
sortingComparator
- comparator to sort stories by path
-
-
Method Detail
-
findClassNames
public List<String> findClassNames(String searchIn, List<String> includes, List<String> excludes)
Finds Java classes from a source path, allowing for includes/excludes, and converts them to class names.- Parameters:
searchIn
- the path to search inincludes
- the List of include patterns, ornull
if noneexcludes
- the List of exclude patterns, ornull
if none- Returns:
- A List of class names found
-
findPaths
public List<String> findPaths(URL searchIn, String include, String exclude)
Finds paths from a source URL, allowing for single include/exclude pattern. Paths found are normalised bynormalise(List)
.- Parameters:
searchIn
- the source URL to search ininclude
- the include pattern, or""
if noneexclude
- the exclude pattern, or""
if none- Returns:
- A List of paths found
-
findPaths
public List<String> findPaths(URL searchIn, String[] includes, String[] excludes)
Finds paths from a source URL, allowing for includes/excludes patterns. Paths found are normalised bynormalise(List)
.- Parameters:
searchIn
- the source URL to search inincludes
- the Array of include patterns, ornull
if noneexcludes
- the Array of exclude patterns, ornull
if none- Returns:
- A List of paths found
-
findPaths
public List<String> findPaths(String searchIn, String include, String exclude)
Finds paths from a source path, allowing for include/exclude patterns, which can be comma-separated values of multiple patterns. Paths found are normalised bynormalise(List)
.- Parameters:
searchIn
- the source path to search ininclude
- the CSV include pattern, ornull
if noneexclude
- the CSV exclude pattern, ornull
if none- Returns:
- A List of paths found
-
findPaths
public List<String> findPaths(String searchIn, String[] includes, String[] excludes)
Finds paths from a source path, allowing for include/exclude patterns. Paths found are normalised bynormalise(List)
.- Parameters:
searchIn
- the source path to search inincludes
- the Array of include patterns, ornull
if noneexcludes
- the Array of exclude patterns, ornull
if none- Returns:
- A List of paths found
-
findPaths
public List<String> findPaths(URL searchIn, List<String> includes, List<String> excludes)
Finds paths from a source URL, allowing for includes/excludes patterns. Paths found are normalised bynormalise(List)
.- Parameters:
searchIn
- the source URL to search inincludes
- the List of include patterns, ornull
if noneexcludes
- the List of exclude patterns, ornull
if none- Returns:
- A List of paths found
-
findPaths
public List<String> findPaths(String searchIn, List<String> includes, List<String> excludes)
Finds paths from a source path, allowing for include/exclude patterns. Paths found are normalised bynormalise(List)
. .- Parameters:
searchIn
- the source path to search inincludes
- the List of include patterns, ornull
if noneexcludes
- the List of exclude patterns, ornull
if none- Returns:
- A List of paths found
-
findPaths
public List<String> findPaths(String searchIn, List<String> includes, List<String> excludes, String prefixWith)
Finds paths from a source path, allowing for includes/excludes. Paths found are prefixed with specified path byprefix(String, List)
and normalised bynormalise(List)
.- Parameters:
searchIn
- the source path to search inincludes
- the List of include patterns, ornull
if noneexcludes
- the List of exclude patterns, ornull
if noneprefixWith
- the root path prefixed to all paths found, ornull
if none- Returns:
- A List of paths found
-
classNameExtension
protected String classNameExtension()
-
sortingComparator
protected Comparator<? super String> sortingComparator()
Comparator used for sorting. Anull
comparator means thatCollections.sort(List)
will use natural ordering.- Returns:
- A Comparator or
null
for natural ordering.
-
-