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 Details

    • EMPTY_ARRAY

      public static final Filter<?>[] EMPTY_ARRAY
    • TRUE

      public static Filter TRUE
      The constantly true filter.
    • FALSE

      public static Filter FALSE
  • Constructor Details

    • Filters

      public Filters()
  • Method Details

    • and

      @SafeVarargs public static <T> Filter<T> and​(Filter<T>... f)
      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

      @SafeVarargs public static <T> Filter<T> or​(Filter<T>... f)
      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

      public static <T> Filter<T> not​(Filter<T> filter)
      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 ParseException
      Creates 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 with Filter.FILTER_PACKAGE_NAME) or a fully qualified classname.
      spec - the specification from which the filter will be created, using the valueOf(String) method (see Filter).
      tClass - the base class of the filter that is desired: it should coincide with T; if the base type D of the filter is wrong, it will try to adapt it by using a static method in the Filters class whose signature is
      public static Filter<T> adaptD2T(Filter<D>)
      .
      Returns:
      the filter.
      Throws:
      ParseException
    • adaptFilterString2URI

      public static Filter<URI> adaptFilterString2URI​(Filter<String> original)
      Adapts a filter with String base type to a filter with URI base type. For testing purposes only.
      Parameters:
      original - the original filter.
      Returns:
      the adapted filter.
    • adaptFilterURI2HttpResponse

      public static Filter<HttpResponse> adaptFilterURI2HttpResponse​(Filter<URI> original)
      Adapts a filter with URI base type to a filter with HttpResponse base type.
      Parameters:
      original - the original filter.
      Returns:
      the adapted filter.
    • adaptFilterURI2WarcRecord

      public static Filter<WarcRecord> adaptFilterURI2WarcRecord​(Filter<URI> original)
      Adapts a filter with URI base type to a filter with WarcRecord base type.
      Parameters:
      original - the original filter.
      Returns:
      the adapted filter.
    • standardFilters

      public static Class<? extends Filter<?>>[] standardFilters()
      Returns a list of the standard filter classes.
      Returns:
      a list of standard filter classes.