fitnesse.wikitext.parser.SymbolStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fitnesse Show documentation
Show all versions of fitnesse Show documentation
The fully integrated standalone wiki, and acceptance testing framework.
package fitnesse.wikitext.parser;
import java.util.LinkedList;
public class SymbolStream {
public SymbolStream() {
symbols = new LinkedList<>();
}
public SymbolStream(SymbolStream other) {
symbols = new LinkedList<>(other.symbols);
}
public Symbol get(int position) {
return symbols.size() <= position ? Symbol.emptySymbol : symbols.get(position);
}
public void add(Symbol value) {
symbols.addFirst(value);
if (symbols.size() > streamCapacity) symbols.removeLast();
}
public boolean isEnd() { return symbols.isEmpty() || symbols.getFirst() == Symbol.emptySymbol; }
private static final int streamCapacity = 3;
private LinkedList symbols;
}