001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.jmeter.timers;
020:
021: import java.io.Serializable;
022:
023: import org.apache.jmeter.engine.event.LoopIterationEvent;
024: import org.apache.jmeter.engine.event.LoopIterationListener;
025: import org.apache.jmeter.testelement.AbstractTestElement;
026: import org.apache.jmeter.util.JMeterUtils;
027:
028: /**
029: * This class implements a constant timer with its own panel and fields for
030: * value update and user interaction.
031: *
032: * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
033: * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
034: */
035: public class ConstantTimer extends AbstractTestElement implements
036: Timer, Serializable, LoopIterationListener {
037:
038: public final static String DELAY = "ConstantTimer.delay"; //$NON-NLS-1$
039:
040: private long delay = 0;
041:
042: /**
043: * No-arg constructor.
044: */
045: public ConstantTimer() {
046: }
047:
048: /**
049: * Set the delay for this timer.
050: *
051: */
052: public void setDelay(String delay) {
053: setProperty(DELAY, delay);
054: }
055:
056: /**
057: * Set the range (not used for this timer).
058: *
059: */
060: public void setRange(double range) {
061: }
062:
063: /**
064: * Get the delay value for display.
065: *
066: * @return the delay value for display.
067: */
068: public String getDelay() {
069: return getPropertyAsString(DELAY);
070: }
071:
072: /**
073: * Retrieve the range (not used for this timer).
074: *
075: * @return the range (always zero for this timer).
076: */
077: public double getRange() {
078: return 0;
079: }
080:
081: /**
082: * Retrieve the delay to use during test execution.
083: *
084: * @return the delay.
085: */
086: public long delay() {
087: return delay;
088: }
089:
090: /**
091: * Provide a description of this timer class.
092: *
093: * @return the description of this timer class.
094: */
095: public String toString() {
096: return JMeterUtils.getResString("constant_timer_memo"); //$NON-NLS-1$
097: }
098:
099: /**
100: * Gain access to any variables that have been defined.
101: *
102: * @see LoopIterationListener#iterationStart(LoopIterationEvent)
103: */
104: public void iterationStart(LoopIterationEvent event) {
105: delay = getPropertyAsLong(DELAY);
106:
107: }
108: }
|