Class DatasetFilter


  • public class DatasetFilter
    extends Object
    Provides filtering capabilities for InvDatasets.

    The static method acceptDatasetByFilterGroup() is provided to allow filtering with a group of filters. To make filtering out a set of datasets as easy as allowing a set of datasets, DatasetFilter provides a dataset reject mode as well as a dataset accept mode. [Notes: 1) rejection of a dataset takes precedence over acceptance; and 2) all datasets are accepted if the filter group is empty.]

    A DatasetFilter instance contains information on how to filter datasets and can be set to either accept or reject datasets that match the filter criteria (accept is the default). The accept() method should only be called if the isAcceptMatchingDatasets() method returns true. Similarly, the reject() method should only be called if the isRejectMatchingDatasets() method returns true.

    Since:
    2002-12-11T15:27+0700
    • Field Detail

      • regExpPattern

        protected Pattern regExpPattern
    • Constructor Detail

      • DatasetFilter

        public DatasetFilter​(DatasetSource parentDsSource,
                             String name,
                             thredds.cataloggen.config.DatasetFilter.Type type,
                             String matchPattern)
        Constructor
        Parameters:
        parentDsSource -
        name -
        type -
        matchPattern -
      • DatasetFilter

        public DatasetFilter​(DatasetSource parentDsSource,
                             String name,
                             thredds.cataloggen.config.DatasetFilter.Type type,
                             String matchPattern,
                             boolean applyToCollectionDatasets,
                             boolean applyToAtomicDatasets,
                             boolean rejectMatchingDatasets)
    • Method Detail

      • getParentDatasetSource

        public DatasetSource getParentDatasetSource()
        Return the parent DatasetSource of this DatasetFilter
      • getName

        public String getName()
        Return the name of this DatasetFilter
        Returns:
        String the name of this.
      • getType

        public thredds.cataloggen.config.DatasetFilter.Type getType()
        Return the type of this DatasetFilter
        Returns:
        DatasetFilter.Type the type of this.
      • getMatchPattern

        public String getMatchPattern()
        Return the matchPattern of this DatasetFilter
        Returns:
        String the matchPattern of this.
      • getMatchPatternTarget

        public String getMatchPatternTarget()
      • setMatchPatternTarget

        public void setMatchPatternTarget​(String matchPatternTarget)
      • isApplyToCollectionDatasets

        public boolean isApplyToCollectionDatasets()
      • setApplyToCollectionDatasets

        public void setApplyToCollectionDatasets​(boolean applyToCollectionDatasets)
      • isApplyToAtomicDatasets

        public boolean isApplyToAtomicDatasets()
      • setApplyToAtomicDatasets

        public void setApplyToAtomicDatasets​(boolean applyToAtomicDatasets)
      • isRejectMatchingDatasets

        public boolean isRejectMatchingDatasets()
      • isAcceptMatchingDatasets

        public boolean isAcceptMatchingDatasets()
      • setRejectMatchingDatasets

        public void setRejectMatchingDatasets​(boolean rejectMatchingDatasets)
      • reject

        public boolean reject​(InvDataset dataset)
        Test whether the given dataset should be excluded from the dataset collection.
        Parameters:
        dataset - - the dataset to be tested
        Returns:
        true if and only if the dataset should be excluded
        Throws:
        IllegalStateException - if the filter accepts rather than rejects datasets.
      • accept

        public boolean accept​(InvDataset dataset)
        Test whether the given dataset should be included in a dataset collection.
        Parameters:
        dataset - - the dataset to be tested
        Returns:
        true if and only if the dataset should be included
        Throws:
        IllegalStateException - if the filter rejects rather than accepts datasets.
      • appliesToDataset

        protected boolean appliesToDataset​(InvDataset dataset)
      • acceptDatasetByFilterGroup

        public static boolean acceptDatasetByFilterGroup​(List filters,
                                                         InvDataset dataset,
                                                         boolean isCollectionDataset)
        Given a dataset and a group of filters, return true if the group of filters indicates that the dataset should be accepted, false if it should be rejected.

        To make filtering out a set of datasets as easy as allowing a set of datasets, DatasetFilter provides a dataset reject mode as well as a dataset accept mode. Rejection of a dataset by any filter overrides acceptance by any number of filters. Therefore, to be accepted by the group a dataset needs to be accepted by at least one filter, however, rejection by a single filter will cause rejection by the group.

        If the filter group is empty, the dataset will be accepted.

        Parameters:
        filters - - the group of filters to apply to the dataset.
        dataset - - the dataset on which to apply the filter group.
        isCollectionDataset -
        Returns:
        true if the group of filters indicates that the dataset should be accepted, false otherwise.
        Throws:
        NullPointerException - if the filter list or the dataset is null.