|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
IndexedParamsAssigner.java | 100% | 77.8% | 60% | 75% |
|
1 | /** | |
2 | * JTRunner is free software; you can redistribute it and/or modify it under the | |
3 | * terms of the GNU General Public License as published by the Free Software | |
4 | * Foundation; either version 2, or (at your option) any later version. | |
5 | */ | |
6 | ||
7 | package jtr.assigner.impl; | |
8 | ||
9 | import java.util.*; | |
10 | ||
11 | import jtr.runners.IRunnerClean; | |
12 | import jtr.config.RunnerConfig; | |
13 | import jtr.runners.IRunnerParameterized; | |
14 | import jtr.config.ParametersMap; | |
15 | import org.apache.log4j.Logger; | |
16 | ||
17 | /** | |
18 | * This class is a concrete <code>IParamsAssigner</code> implementation | |
19 | * providing an indexed parameters assignment policy.<br> | |
20 | * This means that should a configured runner have multiple parameters-sets | |
21 | * associated with it, this particular assigner would provide the i-th runner | |
22 | * instance with the i-th mod(n) parameter-set where n is the number of | |
23 | * configured parameters-sets.br> Each assignment will be performed at the | |
24 | * beginning of each run.<br> | |
25 | * | |
26 | * @author Francesco Russo (frusso@dev.java.net) | |
27 | * @version 4.0 | |
28 | * @since 1.0 | |
29 | */ | |
30 | public class IndexedParamsAssigner extends AbstractParamsAssigner { | |
31 | /** | |
32 | * Default constructor. | |
33 | */ | |
34 | 8 | public IndexedParamsAssigner() { |
35 | } | |
36 | ||
37 | /** | |
38 | * Performs the assignment of the <code>i-th mod(n)</code> parameter-set | |
39 | * to the <code>cRunners[i]</code>. | |
40 | * | |
41 | * @param cRunners | |
42 | * IRunnerClean[] | |
43 | * @param runnerConfig | |
44 | * RunnerConfig | |
45 | * @return IRunnerParameterized[] | |
46 | */ | |
47 | 8 | public IRunnerParameterized[] assign(IRunnerClean[] cRunners, RunnerConfig runnerConfig) { |
48 | 8 | Vector parameterMaps = runnerConfig.getParameterMaps(); |
49 | 8 | logger.debug("Assigning parameters to " + cRunners.length + " IRunners"); |
50 | 8 | for (int i = 0; i < cRunners.length; i++) { |
51 | // th i-th runner has to be initialized using i-th ParameterMap | |
52 | 68 | ParametersMap params = (ParametersMap) parameterMaps.get(i % parameterMaps.size()); |
53 | 68 | performStdAssignment(cRunners[i], runnerConfig, params, this); |
54 | } // end of for | |
55 | ||
56 | 8 | return (IRunnerParameterized[]) cRunners; |
57 | } | |
58 | ||
59 | /** | |
60 | * This method always return <code>false</code>. | |
61 | * | |
62 | * @return boolean | |
63 | */ | |
64 | 31812 | public boolean requiresReinitialization() { |
65 | 31812 | return false; |
66 | } | |
67 | ||
68 | /** | |
69 | * Nop. | |
70 | * | |
71 | * @param cRunner | |
72 | * IRunnerClean | |
73 | * @return IRunnerParameterized | |
74 | */ | |
75 | 0 | public IRunnerParameterized reAssign(IRunnerClean cRunner) { |
76 | // nop | |
77 | 0 | return null; |
78 | } | |
79 | ||
80 | /** | |
81 | * Nop. | |
82 | * | |
83 | * @param cRunner | |
84 | * IRunnerClean | |
85 | * @return IRunnerParameterized | |
86 | */ | |
87 | 0 | public IRunnerParameterized backToFirstAssignment(IRunnerClean cRunner) { |
88 | // nop | |
89 | 0 | return null; |
90 | } | |
91 | ||
92 | private static Logger logger = Logger.getLogger(IndexedParamsAssigner.class); | |
93 | } |
|