net.sourceforge.plantuml.oregon.SmartKeyboard Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-mit Show documentation
Show all versions of plantuml-mit Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.oregon;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class SmartKeyboard {
private final Keyboard keyboard;
private final List history = new ArrayList<>();
public SmartKeyboard(Keyboard keyboard) {
this.keyboard = keyboard;
}
public String input(Screen screen) throws NoInputException {
final String s = keyboard.input();
history.add(s);
screen.print("? " + s);
return s;
}
public int inputInt(Screen screen) throws NoInputException {
final String s = input(screen);
if (s.matches("\\d+") == false) {
screen.print("Please enter a valid number instead of " + s);
throw new NoInputException();
}
return Integer.parseInt(s);
}
public boolean hasMore() {
return keyboard.hasMore();
}
public List getHistory() {
return Collections.unmodifiableList(history);
}
}