| | |
| | | |
| | | /** |
| | | * Class used to add points periodically to the end of the output. |
| | | * |
| | | */ |
| | | public class PointAdder implements Runnable |
| | | { |
| | |
| | | |
| | | /** |
| | | * Default constructor. |
| | | * @param app the console application to be used. |
| | | * Creates a PointAdder that writes to the standard output with the default |
| | | * period time. |
| | | * |
| | | * @param app |
| | | * The console application to be used. Creates a PointAdder that |
| | | * writes to the standard output with the default period time. |
| | | */ |
| | | public PointAdder(ConsoleApplication app) |
| | | { |
| | |
| | | |
| | | /** |
| | | * Default constructor. |
| | | * @param app the console application to be used. |
| | | * @param periodTime the time between printing two points. |
| | | * @param isError whether the points must be printed in error stream |
| | | * or output stream. |
| | | * @param formatter the text formatter. |
| | | * |
| | | * @param app |
| | | * The console application to be used. |
| | | * @param periodTime |
| | | * The time between printing two points. |
| | | * @param isError |
| | | * Whether the points must be printed in error stream or output |
| | | * stream. |
| | | * @param formatter |
| | | * The text formatter. |
| | | */ |
| | | public PointAdder(ConsoleApplication app, |
| | | long periodTime, boolean isError, |
| | |
| | | { |
| | | mb.append(formatter.getFormattedPoint()); |
| | | } |
| | | if (isError) |
| | | { |
| | | app.print(mb.toMessage()); |
| | | } |
| | | else |
| | | { |
| | | app.print(mb.toMessage()); |
| | | } |
| | | app.print(mb.toMessage()); |
| | | t = new Thread(this); |
| | | t.start(); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public void run() |
| | | { |
| | | while (!stopPointAdder) |
| | |
| | | try |
| | | { |
| | | Thread.sleep(periodTime); |
| | | if (isError) |
| | | { |
| | | app.print(formatter.getFormattedPoint()); |
| | | } |
| | | else |
| | | { |
| | | app.print(formatter.getFormattedPoint()); |
| | | } |
| | | app.print(formatter.getFormattedPoint()); |
| | | } |
| | | catch (Throwable t) |
| | | { |