Package com.owenfeehan.pathpatternfinder
Class PathPatternFinder
Object
com.owenfeehan.pathpatternfinder.PathPatternFinder
public class PathPatternFinder extends Object
Finds a pattern in a list of paths via a set of rules.
The rules are (in order):
- finds any common file-path roots
- then treats the remaining file-paths as a list of strings with / or \ as directory seperators (OS dependent)
- repeat until no more operations possible
- from the left:
- looks for maximum-constant strings
- looks for maximally-sized integer patterns
- looks for any variable strings, which are ended by constant character always at the same index
- do the same from the right
- from the left:
- if there is a remaining "unmatched" strings, consider splitting by special characters _ or - or ( or ) into tokens
- apply step 3 to each of the split tokens
- Author:
- Owen Feehan
-
Constructor Summary
Constructors Constructor Description PathPatternFinder()
-
Method Summary
Modifier and Type Method Description static Pattern
findPatternPaths(List<Path> paths, IOCase ioCase, boolean avoidExtensionSplit)
Finds the pattern in a list of paths, using rules outlined above.static Pattern
findPatternStrings(List<String> strings, IOCase ioCase)
Finds the pattern in a list of strings, using rules outlined above (from Step 3 onwards).static void
main(String[] args)
Derives a pattern from the paths passed as command-line arguments.
-
Constructor Details
-
PathPatternFinder
public PathPatternFinder()
-
-
Method Details
-
findPatternPaths
public static Pattern findPatternPaths(List<Path> paths, IOCase ioCase, boolean avoidExtensionSplit)Finds the pattern in a list of paths, using rules outlined above.- Parameters:
paths
- a list of paths to match againstioCase
- how to treat the case in pathsavoidExtensionSplit
- if true, splits will be avoided in file extensions in the paths (defined as anything after the right-most period)- Returns:
- the pattern-found
-
findPatternStrings
Finds the pattern in a list of strings, using rules outlined above (from Step 3 onwards).- Parameters:
strings
- a list of strings to match againstioCase
- how to treat the case in paths- Returns:
- the pattern-found
-
main
Derives a pattern from the paths passed as command-line arguments.- Accepts a globs or file/directory paths as command-line arguments
- Derives a list of paths from these parameters
- Derives a pattern from the list of paths
- Parameters:
args
- command-line arguments
-