public class Glob extends Object
Glob allows glob-like wildcard expansion in pathnames, specifically the use of * to represent any sequence of non-/ characters. A Glob is initialised with a FileSystemInterface instance that encapsulates the test for isDirectory() and listing files in a given directory; typically this just falls back to the usual File primitives.
note Future versions of this class may implement more globbing features.
Modifier and Type | Class and Description |
---|---|
static interface |
Glob.FileSystemInterface
A FileSystemInterface provides an interface onto a file system
that allows querying for a name being a directory name and extracting
from a directory a list of names that match a given pattern.
|
Modifier and Type | Field and Description |
---|---|
protected Glob.FileSystemInterface |
fs
The FileSystemInterface for querying the filesystem.
|
Constructor and Description |
---|
Glob()
Initialise this Glob with the default FileSystemInterface.
|
Glob(Glob.FileSystemInterface fs)
Initialise this Glob with the specified FileSystemInterface.
|
Modifier and Type | Method and Description |
---|---|
String |
extract(String glob,
String name)
Return the portion(s) of name that is matched by the wildcard(s) in
glob, or null if there is no match.
|
String |
extract(String glob,
String join,
String name) |
List<File> |
filesMatching(List<File> files,
String path)
filesMatching(files,path) appends to the files list all the files
whose names match the provided path (as above) and returns that
same list.
|
List<File> |
filesMatching(String path)
filesMatching(path) returns a list of all the files whose names match
the provided path.
|
static boolean |
isPathSeparator(char ch) |
List<String> |
splitFilePath(File f)
Split a file into components such that the components are differences in
reverse order of repeated getParentFile() calls, with file separators
stripped if present.
|
protected final Glob.FileSystemInterface fs
public Glob()
public Glob(Glob.FileSystemInterface fs)
public List<File> filesMatching(String path)
public List<File> filesMatching(List<File> files, String path)
public String extract(String glob, String name)
public static boolean isPathSeparator(char ch)
Copyright © 2014. All Rights Reserved.