View Javadoc

1   /****************************************************************
2    * Licensed to the Apache Software Foundation (ASF) under one   *
3    * or more contributor license agreements.  See the NOTICE file *
4    * distributed with this work for additional information        *
5    * regarding copyright ownership.  The ASF licenses this file   *
6    * to you under the Apache License, Version 2.0 (the            *
7    * "License"); you may not use this file except in compliance   *
8    * with the License.  You may obtain a copy of the License at   *
9    *                                                              *
10   *   http://www.apache.org/licenses/LICENSE-2.0                 *
11   *                                                              *
12   * Unless required by applicable law or agreed to in writing,   *
13   * software distributed under the License is distributed on an  *
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
15   * KIND, either express or implied.  See the License for the    *
16   * specific language governing permissions and limitations      *
17   * under the License.                                           *
18   ****************************************************************/
19  
20  
21  
22  package org.apache.james.nntpserver;
23  
24  import java.io.File;
25  import java.io.FilenameFilter;
26  
27  /**
28   * Filters files according to their last modified date
29   *
30   */
31  public class DateSinceFileFilter implements FilenameFilter {
32  
33      /**
34       * The date that serves as the lower bound of the region of 
35       * interest
36       */
37      private final long m_date;
38  
39      /**
40       * Creates a new FileFilter that returns all Files that
41       * have been modified since the date specified.
42       *
43       * @param date the date that serves as the lower bound of the region of 
44       * interest
45       */
46      public DateSinceFileFilter( long date ) {
47          m_date = date;
48      }
49  
50      /**
51       * Tests if a specified file has been modified since a
52       * specified date.
53       *
54       * @param dir the directory in which the file was found
55       * @param name the name of the file
56       *
57       * @return true if the file meets the criteria, false otherwise
58       */
59      public boolean accept( final File dir, final String name ) {
60          return (new File(dir,name).lastModified() >= m_date);
61      }
62  }