View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.saxbenchmark;
17  
18  import java.io.File;
19  import java.io.FilenameFilter;
20  import java.io.IOException;
21  import java.util.ArrayList;
22  import java.util.List;
23  
24  /***
25   * @author JMcCrindle
26   */
27  public class FolderSourceFactorySupplier implements SourceFactorySupplier {
28  
29      private List factories = new ArrayList();
30      private String suffix = ".html";
31      
32      public FolderSourceFactorySupplier(String folder) throws IOException {
33          File dir = new File(folder);
34          File[] files = dir.listFiles(new FilenameFilter() {
35              public boolean accept(File dir, String name) {
36                  return name.endsWith(suffix);
37              }
38          });
39          for (int i = 0; i < files.length; i++) {
40              File file = files[i];
41              factories.add(new FileSourceFactory(file));
42          }
43      }
44      
45      /* (non-Javadoc)
46       * @see org.saxbenchmark.SourceFactorySupplier#getInputSourceFactories()
47       */
48      public List getSourceFactories() {
49          return factories;
50      }
51  
52  }