1 /*
2 * @(#)$Id: BatchForValue.java 689 2009-07-22 00:10:27Z bsigner $
3 *
4 * Author : Ueli Kurmann, igesture@uelikurmann.ch
5 *
6 * Purpose : Represents the for loop of the batch process.
7 *
8 * -----------------------------------------------------------------------
9 *
10 * Revision Information:
11 *
12 * Date Who Reason
13 *
14 * Dec 26, 2006 ukurmann Initial Release
15 * Mar 22, 2007 bsigner Cleanup
16 *
17 * -----------------------------------------------------------------------
18 *
19 * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
20 *
21 * This software is the proprietary information of ETH Zurich.
22 * Use is subject to license terms.
23 *
24 */
25
26
27 package org.ximtec.igesture.batch.core;
28
29 import java.util.ArrayList;
30 import java.util.List;
31
32
33 /**
34 * Represents the for loop of the batch process.
35 *
36 * @version 1.0 Dec 2006
37 * @author Ueli Kurmann, igesture@uelikurmann.ch
38 * @author Beat Signer, signer@inf.ethz.ch
39 */
40
41 public class BatchForValue {
42
43 private double start;
44
45 private double end;
46
47 private double step;
48
49
50 public BatchForValue() {
51 }
52
53
54 /**
55 * Sets the upper bound of the loop.
56 * @param end the upper bound of the loop.
57 */
58 public void setEnd(double end) {
59 this.end = end;
60 } // setEnd
61
62
63 /**
64 * Returns the upper bound of the loop.
65 * @return the upper bound of the loop.
66 */
67 public double getEnd() {
68 return end;
69 } // getEnd
70
71
72 /**
73 * Sets the lower bound of the loop.
74 * @param start the lower bound of the loop.
75 */
76 public void setStart(double start) {
77 this.start = start;
78 } // setStart
79
80
81 /**
82 * Returns the lower bound of the loop.
83 * @return the lower bound of the loop.
84 */
85 public double getStart() {
86 return start;
87 } // getStart
88
89
90 /**
91 * Sets the step size for iterating between the lower and upper bound.
92 * @param step the step size for iterating between the lower and upper bound.
93 */
94 public void setStep(double step) {
95 this.step = step;
96 } // setStep
97
98
99 /**
100 * Returns the step size for iterating between the lower and upper bound.
101 * @return the step size for iterating between the lower and upper bound.
102 */
103 public double getStep() {
104 return step;
105 } // getStep
106
107
108 /**
109 * Returns a list of all values matching the constraints.
110 * @return a list of all values matching the constraints.
111 */
112 public List<String> getValues() {
113 final List<String> result = new ArrayList<String>();
114
115 for (double value = getStart(); value <= getEnd(); value = value
116 + getStep()) {
117 result.add(String.valueOf(value));
118 }
119
120 return result;
121 } // getValues
122
123 }