legacy/src/main/java/thredds/cataloggen/config/DatasetFilter.java
public static boolean acceptDatasetByFilterGroup(List filters, InvDataset dataset, boolean isCollectionDataset) {
    if (filters == null) throw new NullPointerException("Given null list of filters.");
    if (dataset == null) throw new NullPointerException("Given null dataset.");

    // If not filters, accept all datasets.
    if (filters.isEmpty())
      return (true);

    // Loop through DatasetFilter list to check if current dataset should be accepted.
    // @todo If none of the filters apply to directories, accept all directories.
    boolean accept = false;
    boolean anyApplyToAtomic = false;
    boolean anyApplyToCollection = false;
    for (Iterator it = filters.iterator(); it.hasNext();) {
      DatasetFilter curFilter = (DatasetFilter) it.next();
      anyApplyToAtomic |= curFilter.isApplyToAtomicDatasets();
      anyApplyToCollection |= curFilter.isApplyToCollectionDatasets();

      if (curFilter.isAcceptMatchingDatasets()) {
        if (curFilter.accept(dataset)) {
          accept = true; // Dataset accepted by current DatasetFilter.
        }
      } else // if ( ! curFilter.isAcceptMatchingDatasets())
      {
        if (curFilter.reject(dataset)) {
          return (false); // Rejection takes precedence over accpetance
        }
      }
    }

    // At least one filter accepted (and none rejected), so accept.
    if (accept) return (true);

    // Check if any filters apply to dataset. If none apply, accept the dataset.
    if (isCollectionDataset) {
      if (!anyApplyToCollection) return (true); // Collection ds, no collection filters.
    } else {
      if (!anyApplyToAtomic) return (true); // Atomic ds, no atomic filters.
    }

    // Dataset not accepted or rejected by any DatasetFilter (so reject).
    return (false);
  }
public static boolean acceptDatasetByFilterGroup(List filters, InvDataset dataset, boolean isCollectionDataset) {
    if (filters == null) throw new NullPointerException("Given null list of filters.");
    if (dataset == null) throw new NullPointerException("Given null dataset.");

    // If not filters, accept all datasets.
    if (filters.isEmpty())
      return (true);

    // Loop through DatasetFilter list to check if current dataset should be accepted.
    // @todo If none of the filters apply to directories, accept all directories.
    boolean accept = false;
    boolean anyApplyToAtomic = false;
    boolean anyApplyToCollection = false;
    for (Iterator it = filters.iterator(); it.hasNext();) {
      DatasetFilter curFilter = (DatasetFilter) it.next();
      anyApplyToAtomic |= curFilter.isApplyToAtomicDatasets();
      anyApplyToCollection |= curFilter.isApplyToCollectionDatasets();

      if (curFilter.isAcceptMatchingDatasets()) {
        if (curFilter.accept(dataset)) {
          accept = true; // Dataset accepted by current DatasetFilter.
        }
      } else // if ( ! curFilter.isAcceptMatchingDatasets())
      {
        if (curFilter.reject(dataset)) {
          return (false); // Rejection takes precedence over accpetance
        }
      }
    }

    // At least one filter accepted (and none rejected), so accept.
    if (accept) return (true);

    // Check if any filters apply to dataset. If none apply, accept the dataset.
    if (isCollectionDataset) {
      if (!anyApplyToCollection) return (true); // Collection ds, no collection filters.
    } else {
      if (!anyApplyToAtomic) return (true); // Atomic ds, no atomic filters.
    }

    // Dataset not accepted or rejected by any DatasetFilter (so reject).
    return (false);
  }
public static boolean acceptDatasetByFilterGroup ( List filters , InvDataset dataset , boolean isCollectionDataset ) { if ( filters == null ) throw new NullPointerException ( "Given null list of filters." ) ; if ( dataset == null ) throw new NullPointerException ( "Given null dataset." ) ; // If not filters, accept all datasets. if ( filters . isEmpty ( ) ) return ( true ) ; // Loop through DatasetFilter list to check if current dataset should be accepted. // @todo If none of the filters apply to directories, accept all directories. boolean accept = false ; boolean anyApplyToAtomic = false ; boolean anyApplyToCollection = false ; for ( Iterator it = filters . iterator ( ) ; it . hasNext ( ) ; ) { DatasetFilter curFilter = ( DatasetFilter ) it . next ( ) ; anyApplyToAtomic |= curFilter . isApplyToAtomicDatasets ( ) ; anyApplyToCollection |= curFilter . isApplyToCollectionDatasets ( ) ; if ( curFilter . isAcceptMatchingDatasets ( ) ) { if ( curFilter . accept ( dataset ) ) { accept = true ; // Dataset accepted by current DatasetFilter. } } else // if ( ! curFilter.isAcceptMatchingDatasets()) { if ( curFilter . reject ( dataset ) ) { return ( false ) ; // Rejection takes precedence over accpetance } } } // At least one filter accepted (and none rejected), so accept. if ( accept ) return ( true ) ; // Check if any filters apply to dataset. If none apply, accept the dataset. if ( isCollectionDataset ) { if ( ! anyApplyToCollection ) return ( true ) ; // Collection ds, no collection filters. } else { if ( ! anyApplyToAtomic ) return ( true ) ; // Atomic ds, no atomic filters. } // Dataset not accepted or rejected by any DatasetFilter (so reject). return ( false ) ; }
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.
<p/>
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.
<p/>
If the filter group is empty, the dataset will be accepted.

@param filters             - the group of filters to apply to the dataset.
@param dataset             - the dataset on which to apply the filter group.
@param isCollectionDataset
@return 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.
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 . <p / > 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 . <p / > If the filter group is empty the dataset will be accepted .