Package org.jboss.modules.filter
Class PathFilters
- java.lang.Object
-
- org.jboss.modules.filter.PathFilters
-
public final class PathFilters extends java.lang.Object
Static factory methods for path filter types.
-
-
Field Summary
Fields Modifier and Type Field Description private static PathFilter
defaultImportFilter
private static PathFilter
defaultImportFilterWithServices
private static PathFilter
metaInfFilter
private static PathFilter
metaInfServicesFilter
private static PathFilter
metaInfSubdirectoriesFilter
private static PathFilter
metaInfSubdirectoriesWithoutMetaInfFilter
-
Constructor Summary
Constructors Modifier Constructor Description private
PathFilters()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PathFilter
acceptAll()
Get a filter which always returnstrue
.static PathFilter
all(java.util.Collection<PathFilter> filters)
Get a path filter which returnstrue
if all of the given filters returntrue
.static PathFilter
all(PathFilter... filters)
Get a path filter which returnstrue
if all of the given filters returntrue
.static PathFilter
any(java.util.Collection<PathFilter> filters)
Get a path filter which returnstrue
if any of the given filters returntrue
.static PathFilter
any(PathFilter... filters)
Get a path filter which returnstrue
if any of the given filters returntrue
.private static BooleanPathFilter
booleanFilter(boolean val)
static java.util.Iterator<Resource>
filtered(PathFilter filter, java.util.Iterator<Resource> original)
Get a filtered view of a resource iteration.static PathFilter
getDefaultImportFilter()
Get the default import path filter, which excludes all ofMETA-INF
and its subdirectories.static PathFilter
getDefaultImportFilterWithServices()
Get the default import-with-services path filter which excludes all ofMETA-INF
and its subdirectories, with the exception ofMETA-INF/services
.static PathFilter
getMetaInfFilter()
Get a filter which matches the path"META-INF"
.static PathFilter
getMetaInfServicesFilter()
Get a filter which matches the path"META-INF/services"
.static PathFilter
getMetaInfSubdirectoriesFilter()
Get a filter which matches any subdirectory of the path"META-INF"
.static PathFilter
getMetaInfSubdirectoriesWithoutMetaInfFilter()
Get a filter which matches all ofMETA-INF
's subdirectories, but notMETA-INF
itself.static PathFilter
in(java.util.Collection<java.lang.String> paths)
Get a filter which returnstrue
if the tested path is contained within the given collection.static PathFilter
in(java.util.Set<java.lang.String> paths)
Get a filter which returnstrue
if the tested path is contained within the given set.static PathFilter
is(java.lang.String path)
Get a path filter which matches an exact path name.static PathFilter
isChildOf(java.lang.String path)
Get a path filter which matches any path which is a child of the given path name (not including the path name itself).static PathFilter
isOrIsChildOf(java.lang.String path)
Get a path filter which matches any path which is equal to, or a child of, the given path name.static PathFilter
match(java.lang.String glob)
Get a path filter which matches a glob.static MultiplePathFilterBuilder
multiplePathFilterBuilder(boolean defaultValue)
Get a builder for a multiple-path filter.static PathFilter
none(java.util.Collection<PathFilter> filters)
Get a path filter which returnstrue
if none of the given filters returntrue
.static PathFilter
none(PathFilter... filters)
Get a path filter which returnstrue
if none of the given filters returntrue
.static PathFilter
not(PathFilter filter)
Get a path filter which istrue
when the given filter isfalse
, and vice-versa.static PathFilter
rejectAll()
Get a filter which always returnsfalse
.
-
-
-
Field Detail
-
defaultImportFilter
private static final PathFilter defaultImportFilter
-
defaultImportFilterWithServices
private static final PathFilter defaultImportFilterWithServices
-
metaInfFilter
private static final PathFilter metaInfFilter
-
metaInfSubdirectoriesFilter
private static final PathFilter metaInfSubdirectoriesFilter
-
metaInfServicesFilter
private static final PathFilter metaInfServicesFilter
-
metaInfSubdirectoriesWithoutMetaInfFilter
private static final PathFilter metaInfSubdirectoriesWithoutMetaInfFilter
-
-
Method Detail
-
all
public static PathFilter all(PathFilter... filters)
Get a path filter which returnstrue
if all of the given filters returntrue
.- Parameters:
filters
- the filters- Returns:
- the "all" filter
-
all
public static PathFilter all(java.util.Collection<PathFilter> filters)
Get a path filter which returnstrue
if all of the given filters returntrue
.- Parameters:
filters
- the filters- Returns:
- the "all" filter
-
any
public static PathFilter any(PathFilter... filters)
Get a path filter which returnstrue
if any of the given filters returntrue
.- Parameters:
filters
- the filters- Returns:
- the "any" filter
-
any
public static PathFilter any(java.util.Collection<PathFilter> filters)
Get a path filter which returnstrue
if any of the given filters returntrue
.- Parameters:
filters
- the filters- Returns:
- the "any" filter
-
none
public static PathFilter none(PathFilter... filters)
Get a path filter which returnstrue
if none of the given filters returntrue
.- Parameters:
filters
- the filters- Returns:
- the "none" filter
-
none
public static PathFilter none(java.util.Collection<PathFilter> filters)
Get a path filter which returnstrue
if none of the given filters returntrue
.- Parameters:
filters
- the filters- Returns:
- the "none" filter
-
not
public static PathFilter not(PathFilter filter)
Get a path filter which istrue
when the given filter isfalse
, and vice-versa.- Parameters:
filter
- the filter- Returns:
- the inverting filter
-
match
public static PathFilter match(java.lang.String glob)
Get a path filter which matches a glob. The given glob is a path separated by "/
" characters, which may include the special "*
" and "**
" segment strings which match any directory and any number of nested directories, respectively.- Parameters:
glob
- the glob- Returns:
- a filter which returns
true
if the glob matches
-
is
public static PathFilter is(java.lang.String path)
Get a path filter which matches an exact path name.- Parameters:
path
- the path name- Returns:
- a filter which returns
true
if the path name is an exact match
-
isChildOf
public static PathFilter isChildOf(java.lang.String path)
Get a path filter which matches any path which is a child of the given path name (not including the path name itself).- Parameters:
path
- the path name- Returns:
- a filter which returns
true
if the path name is a child of the given path
-
isOrIsChildOf
public static PathFilter isOrIsChildOf(java.lang.String path)
Get a path filter which matches any path which is equal to, or a child of, the given path name.- Parameters:
path
- the path name- Returns:
- a filter which returns
true
if the path name is equal to, or a child of, the given path
-
multiplePathFilterBuilder
public static MultiplePathFilterBuilder multiplePathFilterBuilder(boolean defaultValue)
Get a builder for a multiple-path filter. Such a filter contains multiple filters, each associated with a flag which indicates that matching paths should be included or excluded.- Parameters:
defaultValue
- the value to return if none of the nested filters match- Returns:
- the builder
-
booleanFilter
private static BooleanPathFilter booleanFilter(boolean val)
-
acceptAll
public static PathFilter acceptAll()
Get a filter which always returnstrue
.- Returns:
- the accept-all filter
-
rejectAll
public static PathFilter rejectAll()
Get a filter which always returnsfalse
.- Returns:
- the reject-all filter
-
in
public static PathFilter in(java.util.Set<java.lang.String> paths)
Get a filter which returnstrue
if the tested path is contained within the given set. Each member of the set is a path separated by "/
" characters;null
s are disallowed.- Parameters:
paths
- the path set- Returns:
- the filter
-
in
public static PathFilter in(java.util.Collection<java.lang.String> paths)
Get a filter which returnstrue
if the tested path is contained within the given collection. Each member of the collection is a path separated by "/
" characters;null
s are disallowed.- Parameters:
paths
- the path collection- Returns:
- the filter
-
filtered
public static java.util.Iterator<Resource> filtered(PathFilter filter, java.util.Iterator<Resource> original)
Get a filtered view of a resource iteration. Only resources which pass the given filter are accepted.- Parameters:
filter
- the filter to checkoriginal
- the original iterator- Returns:
- the filtered iterator
-
getDefaultImportFilter
public static PathFilter getDefaultImportFilter()
Get the default import path filter, which excludes all ofMETA-INF
and its subdirectories.- Returns:
- the default import path filter
-
getDefaultImportFilterWithServices
public static PathFilter getDefaultImportFilterWithServices()
Get the default import-with-services path filter which excludes all ofMETA-INF
and its subdirectories, with the exception ofMETA-INF/services
.- Returns:
- the default import-with-services path filter
-
getMetaInfFilter
public static PathFilter getMetaInfFilter()
Get a filter which matches the path"META-INF"
.- Returns:
- the filter
-
getMetaInfSubdirectoriesFilter
public static PathFilter getMetaInfSubdirectoriesFilter()
Get a filter which matches any subdirectory of the path"META-INF"
.- Returns:
- the filter
-
getMetaInfServicesFilter
public static PathFilter getMetaInfServicesFilter()
Get a filter which matches the path"META-INF/services"
.- Returns:
- the filter
-
getMetaInfSubdirectoriesWithoutMetaInfFilter
public static PathFilter getMetaInfSubdirectoriesWithoutMetaInfFilter()
Get a filter which matches all ofMETA-INF
's subdirectories, but notMETA-INF
itself.- Returns:
- the filter
-
-