Update of /cvsroot/tail/Tail/src/java/net/sf/tail/strategy
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv4080/src/java/net/sf/tail/strategy
Added Files:
NotSoFastStrategy.java
Log Message:
NotSoFastStrategy
--- NEW FILE: NotSoFastStrategy.java ---
package net.sf.tail.strategy;
import net.sf.tail.Strategy;
public class NotSoFastStrategy extends AbstractStrategy {
private Strategy strategy;
private int numberOfTicks;
private int tickIndex;
public NotSoFastStrategy(Strategy strategy, int numberOfTicks) {
this.strategy = strategy;
this.numberOfTicks = numberOfTicks;
this.tickIndex = 0;
}
public String getName() {
return getClass().getSimpleName() + " over strategy: " + strategy.getName() + " number of ticks: " + numberOfTicks;
}
public boolean shouldEnter(int index) {
if(strategy.shouldEnter(index)) {
tickIndex = index;
return true;
}
return false;
}
public boolean shouldExit(int index) {
if(strategy.shouldExit(index) && (index - tickIndex) > numberOfTicks)
return true;
return false;
}
}
|