Package it.unimi.dsi.law.warc.filters
Class Filters
java.lang.Object
it.unimi.dsi.law.warc.filters.Filters
public class Filters extends Object
A collection of static methods to deal with
filters
.-
Field Summary
-
Constructor Summary
Constructors Constructor Description Filters()
-
Method Summary
Modifier and Type Method Description static Filter<URI>
adaptFilterString2URI(Filter<String> original)
static Filter<HttpResponse>
adaptFilterURI2HttpResponse(Filter<URI> original)
Adapts a filter withURI
base type to a filter withHttpResponse
base type.static Filter<WarcRecord>
adaptFilterURI2WarcRecord(Filter<URI> original)
Adapts a filter withURI
base type to a filter withWarcRecord
base type.static <T> Filter<T>
and(Filter<T>... f)
Produces the conjunction of the given filters.static <T> Filter<T>
getFilterFromSpec(String className, String spec, Class<T> tClass)
Creates a filter from a filter class name and an external form.static <T> Filter<T>
not(Filter<T> filter)
Produces the negation of the given filter.static <T> Filter<T>
or(Filter<T>... f)
Produces the disjunction of the given filters.static Class<? extends Filter<?>>[]
standardFilters()
Returns a list of the standard filter classes.
-
Field Details
-
EMPTY_ARRAY
-
TRUE
The constantly true filter. -
FALSE
-
-
Constructor Details
-
Filters
public Filters()
-
-
Method Details
-
and
Produces the conjunction of the given filters.- Type Parameters:
T
- the type of objects that the filters deal with.- Parameters:
f
- the filters.- Returns:
- the conjunction.
-
or
Produces the disjunction of the given filters.- Type Parameters:
T
- the type of objects that the filters deal with.- Parameters:
f
- the filters.- Returns:
- the disjunction.
-
not
Produces the negation of the given filter.- Type Parameters:
T
- the type of objects that the filter deal with.- Parameters:
filter
- the filter.- Returns:
- the negation of the given filter.
-
getFilterFromSpec
public static <T> Filter<T> getFilterFromSpec(String className, String spec, Class<T> tClass) throws ParseExceptionCreates a filter from a filter class name and an external form.- Parameters:
className
- the name of a filter class; it may either be a single class name (in which case it will be qualified withFilter.FILTER_PACKAGE_NAME
) or a fully qualified classname.spec
- the specification from which the filter will be created, using the valueOf(String) method (seeFilter
).tClass
- the base class of the filter that is desired: it should coincide withT
; if the base typeD
of the filter is wrong, it will try to adapt it by using a static method in the Filters class whose signature ispublic static Filter<T> adaptD2T(Filter<D>)
.- Returns:
- the filter.
- Throws:
ParseException
-
adaptFilterString2URI
- Parameters:
original
- the original filter.- Returns:
- the adapted filter.
-
adaptFilterURI2HttpResponse
Adapts a filter withURI
base type to a filter withHttpResponse
base type.- Parameters:
original
- the original filter.- Returns:
- the adapted filter.
-
adaptFilterURI2WarcRecord
Adapts a filter withURI
base type to a filter withWarcRecord
base type.- Parameters:
original
- the original filter.- Returns:
- the adapted filter.
-
standardFilters
Returns a list of the standard filter classes.- Returns:
- a list of standard filter classes.
-