From c1692019a6036ddc0edda70e216b8beaf47a7f41 Mon Sep 17 00:00:00 2001 From: Emmanuel Bigeon Date: Wed, 30 Nov 2016 09:53:20 -0500 Subject: [PATCH] Commentings and minors Signed-off-by: Emmanuel Bigeon --- .../fr/bigeon/gclc/manager/PipedConsoleManager.java | 10 ++++++---- .../java/fr/bigeon/gclc/manager/ReadingRunnable.java | 4 ++-- .../java/fr/bigeon/gclc/manager/WritingRunnable.java | 8 +++++--- 3 files changed, 13 insertions(+), 9 deletions(-) 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 5e9c441..96f49d9 100644 --- a/gclc/src/main/java/fr/bigeon/gclc/manager/PipedConsoleManager.java +++ b/gclc/src/main/java/fr/bigeon/gclc/manager/PipedConsoleManager.java @@ -56,6 +56,8 @@ import java.nio.charset.Charset; public final class PipedConsoleManager implements ConsoleManager, AutoCloseable { + /** The encoding between streams */ + private static final String UTF_8 = "UTF-8"; //$NON-NLS-1$ /** THe inner manager */ private final SystemConsoleManager innerManager; /** The stream to pipe commands into */ @@ -80,11 +82,11 @@ public final class PipedConsoleManager commandOutput = new PipedInputStream(); PipedOutputStream out = new PipedOutputStream(commandOutput); commandBuffOutput = new BufferedReader( - new InputStreamReader(commandOutput, Charset.forName("UTF-8"))); - outPrint = new PrintStream(out, true, "UTF-8"); + new InputStreamReader(commandOutput, Charset.forName(UTF_8))); + outPrint = new PrintStream(out, true, UTF_8); innerManager = new SystemConsoleManager(outPrint, in, - Charset.forName("UTF-8")); //$NON-NLS-1$ - writing = new WritingRunnable(commandInput, Charset.forName("UTF-8")); + Charset.forName(UTF_8)); + writing = new WritingRunnable(commandInput, Charset.forName(UTF_8)); reading = new ReadingRunnable(commandBuffOutput); Thread th = new Thread(writing, "write"); //$NON-NLS-1$ th.start(); 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 0f1bf45..e0acf28 100644 --- a/gclc/src/main/java/fr/bigeon/gclc/manager/ReadingRunnable.java +++ b/gclc/src/main/java/fr/bigeon/gclc/manager/ReadingRunnable.java @@ -105,11 +105,11 @@ public class ReadingRunnable implements Runnable { * * @param line the line to strip the null character from * @return the resulting string */ - private String stripNull(String line) { + private static String stripNull(String line) { String res = line; while (res.length() > 0 && res.charAt(0) == 0) { LOGGER.severe( - "NULL character heading the result of the read. This is a stream problem..."); + "NULL character heading the result of the read. This is a stream problem..."); //$NON-NLS-1$ res = res.substring(1); } return res; diff --git a/gclc/src/main/java/fr/bigeon/gclc/manager/WritingRunnable.java b/gclc/src/main/java/fr/bigeon/gclc/manager/WritingRunnable.java index 3280a56..82ce2fb 100644 --- a/gclc/src/main/java/fr/bigeon/gclc/manager/WritingRunnable.java +++ b/gclc/src/main/java/fr/bigeon/gclc/manager/WritingRunnable.java @@ -47,8 +47,9 @@ import java.util.Deque; import java.util.logging.Level; import java.util.logging.Logger; -/**

- * TODO +/** The runnable in charge of writing messages as they are read. + *

+ * Messages are queued to be retrieved latter on. * * @author Emmanuel Bigeon */ public class WritingRunnable implements Runnable { @@ -70,7 +71,8 @@ public class WritingRunnable implements Runnable { /** Synchro object */ private final Object lock = new Object(); - /** @param outPrint the output to print to */ + /** @param outPrint the output to print to + * @param charset the charset of the stream */ public WritingRunnable(PipedOutputStream outPrint, Charset charset) { super(); this.outPrint = outPrint;