View Javadoc
1 /* Reattore HTTP Server 2 3 Copyright (C) 2002 Michael Hope <michaelh@juju.net.nz> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 $Id: RangeVar.java,v 1.3 2003/03/05 04:31:57 michaelh Exp $ 20 */ 21 22 package juju.reattore.perfcap.var.impl; 23 24 import org.apache.commons.beanutils.BeanUtils; 25 26 import juju.reattore.perfcap.var.Variable; 27 28 /*** Integer variable that goes from a start to an end value at a 29 certain step. 30 31 @tag range 32 @group Variable 33 */ 34 public class RangeVar 35 implements Variable { 36 37 private String name = "X"; 38 private int start = 0; 39 private int end = 10; 40 private int step = 1; 41 42 private int cur; 43 44 /*** The name to identify this variable. 45 46 @param name The name. 47 @default X 48 */ 49 public void setName(String name) { 50 this.name = name; 51 } 52 53 /*** Start/initial value. 54 55 @param start The initial value. 56 @default 0 57 */ 58 public void setStart(int start) { 59 this.start = start; 60 } 61 62 /*** Final, inclusive value. 63 64 @param end End value. 65 @default 10 66 */ 67 public void setEnd(int end) { 68 this.end = end; 69 } 70 71 /*** Step to increment this value as. May be negative. 72 73 @param val The step. 74 @default 1 75 */ 76 public void setStep(int val) { 77 this.step = val; 78 } 79 80 /*** @see Variable */ 81 public String getName() { 82 return name; 83 } 84 85 /*** @see Variable */ 86 public Object getValue() { 87 return new Integer(cur); 88 } 89 90 /*** @see Variable */ 91 public boolean hasNext() { 92 return (step <= 0 && cur > end) 93 || (step > 0 && cur < end); 94 } 95 96 /*** @see Variable */ 97 public void next() { 98 if (hasNext()) { 99 cur += step; 100 } 101 } 102 103 /*** @see Variable */ 104 public void begin() { 105 cur = start - step; 106 } 107 108 /*** @see Variable */ 109 public void end() { 110 } 111 }

This page was automatically generated by Maven