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.util.ArrayList;
19  import java.util.Iterator;
20  import java.util.List;
21  
22  /***
23   * @author JMcCrindle
24   */
25  public class DefaultBenchmarkFactory implements BenchmarkFactory {
26  
27      private ReaderSupplier readerSupplier = null;
28      private SourceFactorySupplier sourceFactorySupplier = null;
29      private int count = 0;
30      
31      /* (non-Javadoc)
32       * @see org.saxbenchmark.BenchmarkFactory#getBenchmarks()
33       */
34      public List getBenchmarks() throws Throwable {
35          
36          List results = new ArrayList();
37          
38          List benchmarkReaders = readerSupplier.getBenchmarkReaders();
39          List sourceFactories = sourceFactorySupplier.getSourceFactories();
40          for (Iterator iter = benchmarkReaders.iterator(); iter.hasNext();) {
41              BenchmarkReaderWriter reader = (BenchmarkReaderWriter) iter.next();
42              for (Iterator sourceIterator = sourceFactories.iterator(); sourceIterator
43                      .hasNext();) {
44                  SourceFactory sourceFactory = (SourceFactory) sourceIterator.next();
45                  results.add(new Benchmark(reader.getName(), reader.getReader(), sourceFactory, count));
46              }
47          }
48          return results;
49      }
50  
51      public int getCount() {
52          return count;
53      }
54      public void setCount(int count) {
55          this.count = count;
56      }
57      public ReaderSupplier getReaderSupplier() {
58          return readerSupplier;
59      }
60      public void setReaderSupplier(ReaderSupplier readerSupplier) {
61          this.readerSupplier = readerSupplier;
62      }
63      public SourceFactorySupplier getSourceFactorySupplier() {
64          return sourceFactorySupplier;
65      }
66      public void setSourceFactorySupplier(
67              SourceFactorySupplier sourceFactorySupplier) {
68          this.sourceFactorySupplier = sourceFactorySupplier;
69      }
70  }