diff --git a/gclc/src/main/java/fr/bigeon/gclc/manager/ConsoleManager.java b/gclc/src/main/java/fr/bigeon/gclc/manager/ConsoleManager.java index 9a0d060..6bf3b45 100644 --- a/gclc/src/main/java/fr/bigeon/gclc/manager/ConsoleManager.java +++ b/gclc/src/main/java/fr/bigeon/gclc/manager/ConsoleManager.java @@ -74,12 +74,25 @@ public interface ConsoleManager extends AutoCloseable { * @throws InterruptedIOException if the prompt was interrupted */ String prompt() throws IOException; + /** @param timeout the time to wait in milliseconds + * @return the user inputed string, null if the timeout was reached + * @throws IOException if the manager is closed or could not read the prompt + * @throws InterruptedIOException if the prompt was interrupted */ + String prompt(long timeout) throws IOException; + /** @param message the message to prompt the user * @return the user inputed string * @throws IOException if the manager is closed or could not read the prompt * @throws InterruptedIOException if the prompt was interrupted */ String prompt(String message) throws IOException; + /** @param timeout the time to wait in milliseconds + * @param message the message to prompt the user + * @return the user inputed string, null if the timeout was reached + * @throws IOException if the manager is closed or could not read the prompt + * @throws InterruptedIOException if the prompt was interrupted */ + String prompt(String message, long timeout) throws IOException; + /**
* Set a prompting prefix.
*
diff --git a/gclc/src/main/java/fr/bigeon/gclc/manager/PipedConsoleManager.java b/gclc/src/main/java/fr/bigeon/gclc/manager/PipedConsoleManager.java
index c0390d8..c5ca922 100644
--- a/gclc/src/main/java/fr/bigeon/gclc/manager/PipedConsoleManager.java
+++ b/gclc/src/main/java/fr/bigeon/gclc/manager/PipedConsoleManager.java
@@ -121,11 +121,23 @@ public final class PipedConsoleManager
.prompt(innerManager.getPrompt() + System.lineSeparator());
}
+ /* (non-Javadoc)
+ * @see fr.bigeon.gclc.manager.ConsoleManager#prompt(long) */
+ @Override
+ public String prompt(long timeout) throws IOException {
+ return innerManager.prompt(timeout);
+ }
+
@Override
public String prompt(String message) throws IOException {
return innerManager.prompt(message + System.lineSeparator());
}
+ @Override
+ public String prompt(String message, long timeout) throws IOException {
+ return innerManager.prompt(message + System.lineSeparator(), timeout);
+ }
+
@Override
public void setPrompt(String prompt) {
innerManager.setPrompt(prompt);
diff --git a/gclc/src/main/java/fr/bigeon/gclc/manager/ReadingRunnable.java b/gclc/src/main/java/fr/bigeon/gclc/manager/ReadingRunnable.java
index dfd8a7d..80aceab 100644
--- a/gclc/src/main/java/fr/bigeon/gclc/manager/ReadingRunnable.java
+++ b/gclc/src/main/java/fr/bigeon/gclc/manager/ReadingRunnable.java
@@ -69,8 +69,7 @@ public class ReadingRunnable implements Runnable {
/** @param obj the object to lock on
* @param start the object to notify when ready to wait
* @param message the message to wait for */
- public ToWaitRunnable(Object obj, Object start,
- String message) {
+ public ToWaitRunnable(Object obj, Object start, String message) {
this.obj = obj;
this.start = start;
this.message = message;
@@ -91,8 +90,8 @@ public class ReadingRunnable implements Runnable {
return;
}
} catch (InterruptedException e) {
- LOGGER.log(Level.SEVERE,
- THREAD_INTERRUPTION_EXCEPTION, e);
+ LOGGER.log(Level.SEVERE, THREAD_INTERRUPTION_EXCEPTION,
+ e);
}
}
}
@@ -126,13 +125,9 @@ public class ReadingRunnable implements Runnable {
private final Object lock = new Object();
/** The waiting status for a message */
private boolean waiting;
- /**
- * The blocker for a given message
- */
+ /** The blocker for a given message */
private final Map