@@ -0,0 +1,3291 @@
+// $Id: $%0A/*%0A * Copyright 1997-2006 Unidata Program Center/University Corporation for%0A * Atmospheric Research, P.O. Box 3000, Boulder, CO 80307,%0A * support@unidata.ucar.edu.%0A *%0A * This library is free software; you can redistribute it and/or modify it%0A * under the terms of the GNU Lesser General Public License as published by%0A * the Free Software Foundation; either version 2.1 of the License, or (at%0A * your option) any later version.%0A *%0A * This library is distributed in the hope that it will be useful, but%0A * WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser%0A * General Public License for more details.%0A *%0A * You should have received a copy of the GNU Lesser General Public License%0A * along with this library; if not, write to the Free Software Foundation,%0A * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA%0A */%0A%0Apackage thredds.crawlabledataset.filter;%0A%0Aimport thredds.crawlabledataset.CrawlableDataset;%0Aimport thredds.crawlabledataset.CrawlableDatasetFile;%0A%0Aimport java.util.Date;%0A%0A/**%0A * Filter datasets based on their last modidified date.%0A *%0A * @author caron%0A */%0Apublic class LastModifiedLimitSelector implements Selector %7B%0A  private boolean includer;%0A  private boolean applyToAtomicDataset;%0A  private boolean applyToCollectionDataset;%0A%0A  private long lastModifiedLimit;%0A%0A  /**%0A   * Constructor. Can only be used for CrawlableDatasetFile that have a lastModified date.%0A   *%0A   * @param lastModifiedLimitMsecs match datasets whose lastModified() time is at least this many msecs in the past%0A   * @param includer if true, include files that match, else exclude%0A   * @param applyToAtomicDataset filter is applicable to atomic (leaf) datasets%0A   * @param applyToCollectionDataset filter is applicable to collection (directory) datasets%0A   */%0A  public LastModifiedLimitSelector(long lastModifiedLimitMsecs, boolean includer, boolean applyToAtomicDataset, boolean applyToCollectionDataset) %7B%0A    this.lastModifiedLimit = lastModifiedLimitMsecs;%0A%0A    this.includer = includer;%0A    this.applyToAtomicDataset = applyToAtomicDataset;%0A    this.applyToCollectionDataset = applyToCollectionDataset;%0A  %7D%0A%0A  public boolean isApplyToAtomicDataset() %7B%0A    return applyToAtomicDataset;%0A  %7D%0A%0A  public boolean isApplyToCollectionDataset() %7B%0A    return applyToCollectionDataset;%0A  %7D%0A%0A  /**%0A   * For now, we will match on negetive, but we need a way to combine AND and OR in a general way%0A   * @param dataset%0A   * @return%0A   */%0A  public boolean match(CrawlableDataset dataset) %7B%0A    if (dataset instanceof CrawlableDatasetFile) %7B%0A      CrawlableDatasetFile dsFile = (CrawlableDatasetFile) dataset;%0A      Date lastModified = dsFile.lastModified();%0A      if (lastModified != null) %7B%0A        long now = System.currentTimeMillis();%0A        if (now - lastModified.getTime() %3E lastModifiedLimit)%0A          return false;%0A      %7D%0A    %7D%0A    return true;%0A  %7D%0A%0A  public boolean isApplicable(CrawlableDataset dataset) %7B%0A    if (this.applyToAtomicDataset && ! dataset.isCollection()) return true;%0A    if (this.applyToCollectionDataset && dataset.isCollection()) return true;%0A    return false;%0A  %7D%0A%0A  public boolean isIncluder() %7B%0A    return includer;%0A  %7D%0A%0A  public boolean isExcluder() %7B%0A    return ! includer;%0A  %7D%0A%7D%0A%0A

add LastModifiedLimitSelector