Commentings and minors
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
parent
72362936be
commit
c1692019a6
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -47,8 +47,9 @@ import java.util.Deque;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/** <p>
|
||||
* TODO
|
||||
/** The runnable in charge of writing messages as they are read.
|
||||
* <p>
|
||||
* 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;
|
||||
|
Loading…
Reference in New Issue
Block a user