Commit a20bbd77 authored by Kristof Szabados's avatar Kristof Szabados
Browse files

hopefully the code became somewhat more readable.


Signed-off-by: Kristof Szabados's avatarKristof Szabados <Kristof.Szabados@ericsson.com>
parent c71c9b26
......@@ -84,8 +84,10 @@ public final class HostJob extends Job {
final int exitVal = proc.waitFor();
if (0 == exitVal) {
executor.addNotification(new Notification((new Formatter()).format(BaseExecutor.PADDEDDATETIMEFORMAT, new Date()).toString(), EMPTY,
EMPTY, "Host Controller executed successfully"));
final Formatter formatter = new Formatter();
final String timestamp = formatter.format(BaseExecutor.PADDEDDATETIMEFORMAT, new Date()).toString();
formatter.close();
executor.addNotification(new Notification(timestamp, EMPTY, EMPTY, "Host Controller executed successfully"));
} else {
if (stderr.ready()) {
final Formatter formatter = new Formatter();
......@@ -148,7 +150,10 @@ public final class HostJob extends Job {
fastOffset = 0;
readFullLineOnly(stdout);
while (null != fastLine) {
executor.addNotification(new Notification((new Formatter()).format(BaseExecutor.PADDEDDATETIMEFORMAT, new Date()).toString(), "", "", fastLine));
final Formatter formatter = new Formatter();
final String timestamp = formatter.format(BaseExecutor.PADDEDDATETIMEFORMAT, new Date()).toString();
formatter.close();
executor.addNotification(new Notification(timestamp, "", "", fastLine));
builder.delete(0, fastOffset);
if (!firstOutput && null != Activator.getMainView()) {
Activator.getMainView().refreshIfSelected(executor.mainControllerRoot);
......
......@@ -317,11 +317,13 @@ public class NativeJavaExecutor extends BaseExecutor {
public void insertError(final int severity, final String msg) {
TITANConsole.println("Error: " + msg);
final Formatter formatter = new Formatter();
final String timestamp = formatter.format(PADDEDDATETIMEFORMAT, new Date()).toString();
formatter.close();
if (severityLevelExtraction) {
addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(),
SeverityResolver.getSeverityString(severity), EMPTY_STRING, msg));
addNotification(new Notification(timestamp, SeverityResolver.getSeverityString(severity), EMPTY_STRING, msg));
} else {
addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), EMPTY_STRING, EMPTY_STRING, msg));
addNotification(new Notification(timestamp, EMPTY_STRING, EMPTY_STRING, msg));
}
if (simpleExecutionRunning) {
shutdownRequested = true;
......
......@@ -297,11 +297,13 @@ public final class JniExecutor extends BaseExecutor implements IJNICallback {
public void insertError(final int severity, final String msg) {
TITANConsole.println("Error: " + msg);
final Formatter formatter = new Formatter();
final String timestamp = formatter.format(PADDEDDATETIMEFORMAT, new Date()).toString();
formatter.close();
if (severityLevelExtraction) {
addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), SeverityResolver
.getSeverityString(severity), EMPTY_STRING, msg));
addNotification(new Notification(timestamp, SeverityResolver.getSeverityString(severity), EMPTY_STRING, msg));
} else {
addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), EMPTY_STRING, EMPTY_STRING, msg));
addNotification(new Notification(timestamp, EMPTY_STRING, EMPTY_STRING, msg));
}
if (simpleExecutionRunning) {
shutdownRequested = true;
......
......@@ -960,7 +960,10 @@ public final class CliExecutor extends BaseExecutor {
} else if ( consoleTimeStampLength < fastLine.length() &&
fastLine.substring(consoleTimeStampLength).startsWith("MTC@")) {
fastLine = fastLine.substring(consoleTimeStampLength);
addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), "", "", fastLine));
final Formatter formatter = new Formatter();
final String timestamp = formatter.format(PADDEDDATETIMEFORMAT, new Date()).toString();
formatter.close();
addNotification(new Notification(timestamp, "", "", fastLine));
testExecution();
} else if ( consoleTimeStampLength < fastLine.length() &&
fastLine.substring(consoleTimeStampLength).startsWith("MC@")) {
......@@ -1012,7 +1015,10 @@ public final class CliExecutor extends BaseExecutor {
}
} else if ( consoleTimeStampLength < fastLine.length() && fastLine.substring(consoleTimeStampLength).startsWith("HC@")) {
fastLine = fastLine.substring(consoleTimeStampLength);
addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), "", "", fastLine));
final Formatter formatter = new Formatter();
final String timestamp = formatter.format(PADDEDDATETIMEFORMAT, new Date()).toString();
formatter.close();
addNotification(new Notification(timestamp, "", "", fastLine));
} else {
//to avoid expensive steps and using cheap comparisons instead, if possible:
if ( consoleTimeStampLength > 0 && consoleTimeStampLength < fastLine.length() ) {
......@@ -1021,7 +1027,10 @@ public final class CliExecutor extends BaseExecutor {
fastLine = fastLine.substring(consoleTimeStampLength);
}
}
addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), "", "", fastLine));
final Formatter formatter = new Formatter();
final String timestamp = formatter.format(PADDEDDATETIMEFORMAT, new Date()).toString();
formatter.close();
addNotification(new Notification(timestamp, "", "", fastLine));
}
builder.delete(0, fastOffset);
if (Activator.getMainView() != null) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment