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 the Configuration.useStoryExecutionComparator(Comparator) instead.

  • Constructor Details

    • 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 Details

    • 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 in
      includes - the List of include patterns, or null if none
      excludes - the List of exclude patterns, or null 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 by normalise(List).
      Parameters:
      searchIn - the source URL to search in
      include - the include pattern, or "" if none
      exclude - 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 by normalise(List).
      Parameters:
      searchIn - the source URL to search in
      includes - the Array of include patterns, or null if none
      excludes - the Array of exclude patterns, or null 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 by normalise(List).
      Parameters:
      searchIn - the source path to search in
      include - the CSV include pattern, or null if none
      exclude - the CSV exclude pattern, or null 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 by normalise(List).
      Parameters:
      searchIn - the source path to search in
      includes - the Array of include patterns, or null if none
      excludes - the Array of exclude patterns, or null 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 by normalise(List).
      Parameters:
      searchIn - the source URL to search in
      includes - the List of include patterns, or null if none
      excludes - the List of exclude patterns, or null 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 by normalise(List). .
      Parameters:
      searchIn - the source path to search in
      includes - the List of include patterns, or null if none
      excludes - the List of exclude patterns, or null 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 by prefix(String, List) and normalised by normalise(List).
      Parameters:
      searchIn - the source path to search in
      includes - the List of include patterns, or null if none
      excludes - the List of exclude patterns, or null if none
      prefixWith - the root path prefixed to all paths found, or null if none
      Returns:
      A List of paths found
    • normalise

      protected List<String> normalise(List<String> paths)
    • prefix

      protected List<String> prefix(String prefixWith, List<String> paths)
    • classNames

      protected List<String> classNames(List<String> paths)
    • classNameExtension

      protected String classNameExtension()
    • sort

      protected List<String> sort(List<String> input)
    • sortingComparator

      protected Comparator<? super String> sortingComparator()
      Comparator used for sorting. A null comparator means that Collections.sort(List) will use natural ordering.
      Returns:
      A Comparator or null for natural ordering.
    • scan

      protected List<String> scan(String source, List<String> includes, List<String> excludes)
    • scanJar

      protected List<String> scanJar(String jarPath, List<String> includes, List<String> excludes)