public class Announce extends Object
Announce.doing("Testing 1");
Announce.doing("Testing 2");
Announce.message("Now testing", 3);
Announce.warning(1,2,3);
Announce.debug(1,2,3);
Announce.doing("Testing 3a");
Announce.doneDoing("Testing 3b");
Announce.done();
Announce.progressStart("Testing 3c",5); // 5 steps
D.waitMS(1000);
Announce.progressAt(1); // We're at 1 (of 5)
D.waitMS(3000);
Announce.progressAt(4); // We're at 4 (of 5)
D.waitMS(1000);
Announce.progressDone();
Announce.done();
Announce.done();
Announce.done(); // This is one too much, but it works nevertheless
-->
Testing 1...
Testing 2...
Now testing 3
Warning:1 2 3
Announce.main(243): 1 2 3
Testing 3a... done
Testing 3b... done
Testing 3c...........(4.00 s to go)................................ done (5.00 s)
done
done
The progress bar always walks to MAXDOTS dots. The data is written to
Announce.out (by default System.err). There are different levels of
announcements that can be switched on and off.| Modifier and Type | Class and Description |
|---|---|
static class |
Announce.Level
Log level
|
| Modifier and Type | Field and Description |
|---|---|
static String |
blanks
Blanks
|
protected static boolean |
cursorAtPos1
Are we at the beginning of a line?
|
protected static boolean |
debug
TRUE if debugging is on
|
protected static int |
doingLevel
Indentation level
|
protected static Set<String> |
helpCommands
Command line arguments that ask for help
|
protected static long[] |
lastEstimation
last time we printed estimated time
|
protected static Announce.Level |
level
Current log level
|
static int |
MAXDOTS
Maximal number of dots
|
protected static Writer |
out
Where to write to (default: System.err)
|
protected static boolean[] |
printedEstimatedTime
Did we print the estimated time?
|
protected static double[] |
progressCounter
Internal counter for progresses
|
protected static int[] |
progressDots
Memorizes the number of printed dots
|
protected static double[] |
progressEnd
Memorizes the maximal value for progressAt(...)
|
protected static String[] |
progressID
Memorizes a short identification string for a progress level
|
protected static int |
progressLevel
Progress level
|
protected static long[] |
progressStart
Memorizes the process start time
|
protected static long |
timer
Memorizes the timer
|
protected static Vector<Long> |
timerStarts
Memorizes a set of named timers that each can accumulate several time
intervals
|
protected static Vector<Long> |
timerTimes |
| Constructor and Description |
|---|
Announce() |
| Modifier and Type | Method and Description |
|---|---|
protected static String |
blanks()
Returns blanks
|
static String |
blanks(int n)
Returns blanks
|
static void |
close()
Closes the writer
|
static boolean |
debug(Object... o)
Prints a debug message with the class and method name preceeding
|
static void |
debugMsg(Object... o)
Prints a debug message
|
static void |
doing(Object... o)
Writes "s..." - intended for major states telling a user what the program
does
|
static void |
doingDetailed(Object... o)
Writes "s..." - intended for more detailed states, in case the user wants
to follow (nearly) every step of the program in detail
|
static void |
done()
Writes "done NEWLINE" - closes a doing statement
|
static void |
done(String text)
Writes "done NEWLINE" - closes a doing statement
|
static void |
doneDetailed()
Writes "done NEWLINE" - closes a doingDetailed statement
|
static void |
doneDoing(Object... s)
Calls done() and doing(...) - closes a doing statement opening the next
one
|
static void |
doneWithProbs()
Writes "done with problems NEWLINE" - closes a doing statement
|
static void |
error(Exception e)
Prints an exception and aborts by exiting (aborts even if log level is
mute)
|
static void |
error(Object... o)
Prints an error message and aborts by exiting (aborts even if log level
is mute)
|
static void |
errorException(Exception e)
Prints an exception and aborts by throwing a RuntimeException (aborts
even if log level is mute)
|
static void |
errorException(Object... o)
Prints an error message and aborts by throwing a RuntimeException (aborts
even if log level is mute)
|
static void |
errorException(String message,
Exception cause)
Prints an error message and aborts by throwing a RuntimeException (aborts
even if log level is mute)
|
static void |
failed()
Writes "failed NEWLINE"
|
static Announce.Level |
getActiveLevel()
Provides the current announce level
|
static long |
getTime()
Retrieves the time
|
static Long |
getTime(int number)
Retrieves the accumulated time the named timer has run for
|
static Vector<Long> |
getTimers()
Retrieves the accumulated time the named timer has run for
|
static Writer |
getWriter()
Gets the writer the data is written to
|
static void |
help(Object... o)
Writes a help text and exits
|
static int |
initTimer()
Initiates a numbered timer
|
static boolean |
isActiveLevel(Announce.Level l)
Tells whether the given level is within the currently active levels
|
static boolean |
isHelp(String arg)
Says whether a command line argument asks for help
|
static void |
main(String[] args)
Test routine
|
static void |
message(Object... o)
Prints an (indented) message intended to provide additional information
to the user at a top level
|
static void |
messageDetailed(Object... o)
Prints an (indented) message intended to provide more detailed
information to a user who is interested in the details of every program
step
|
protected static void |
newLine()
Internal printer for new line
|
protected static void |
print(Object... o)
Internal printer
|
static void |
printTime()
Retrieves the time
|
static void |
printTime(int timerNumber)
Prints the time of a particular timer given by its timer number
|
static void |
printTime(String name,
int timerNumber)
Prints the time of a particular timer given by its timer number, may be
given a name for printout
|
static void |
progressAt(double d)
Notes that the progress is at d, prints dots if necessary, calculates and
displays the estimated time after 60sec of the progress then again after
every 30min
|
static void |
progressAt(double d,
Announce.Level lvl)
Notes that the progress is at d, prints dots if necessary, calculates and
displays the estimated time after 60sec of the progress then again after
every 30min (takes only effect iff current Announce level >= the given
lvl)
|
static void |
progressDone()
Fills missing dots and writes "done NEWLINE"
|
static void |
progressDone(Announce.Level lvl)
Fills missing dots and writes "done NEWLINE" (takes only effect iff
current Announce level >= the given lvl)
|
static void |
progressFailed()
Writes "failed NEWLINE"
|
static void |
progressShowTime()
Shows remaining time
|
static void |
progressStart(String s,
double max)
Writes s, prepares to make progress up to max
|
static void |
progressStart(String s,
double max,
Announce.Level lvl)
Writes s, prepares to make progress up to max (takes only effect iff
current Announce level >= the given lvl)
|
static void |
progressStart(String s,
String id,
double max)
Writes s, prepares to make progress up to max, remembers id as name for
progress counter
|
static void |
progressStart(String s,
String id,
double max,
Announce.Level lvl)
Writes s, prepares to make progress up to max remembers id as name for
progress counter (and prints it if necessary) (takes only effect iff
current Announce level >= the given lvl)
|
static void |
progressStep()
One progress step (use alternatively to progressAt)
|
static void |
progressStep(Announce.Level lvl)
One progress step (use alternatively to progressAt) (takes only effect
iff current Announce level >= the given lvl)
|
static long |
progressTimePassed()
returns the time passed in the current tracked progress since its start
|
static void |
resetTimer(int number)
Resets the named timer to 0
|
static void |
setDebugMode(boolean set)
Switches debug prefix with method an code line on or off
|
static Announce.Level |
setLevel(Announce.Level l)
Switches announcing on or off
|
static void |
setWriter(OutputStream s)
Sets the writer the data is written to
|
static void |
setWriter(Writer w)
Sets the writer the data is written to
|
static void |
startTimer()
Starts the timer
|
static void |
startTimer(int number)
Starts a named timer
Note: The numerical identifier for the timer has to be a number generated
by calling initTimer beforehand
|
static void |
stopTimer(int number)
Stops a named timer
|
static void |
warning(Object... o)
Prints a warning
|
protected static void |
writeDoing(Object... o) |
protected static Announce.Level level
public static int MAXDOTS
protected static Writer out
protected static int doingLevel
protected static boolean cursorAtPos1
protected static int progressLevel
protected static double[] progressEnd
protected static int[] progressDots
protected static String[] progressID
protected static long[] progressStart
protected static double[] progressCounter
protected static boolean[] printedEstimatedTime
protected static long[] lastEstimation
protected static long timer
protected static Vector<Long> timerStarts
protected static boolean debug
public static final String blanks
public static void startTimer()
public static long getTime()
public static int initTimer()
public static void startTimer(int number)
public static void stopTimer(int number)
public static Long getTime(int number)
public static Vector<Long> getTimers()
public static void resetTimer(int number)
public static void printTime(int timerNumber)
public static void printTime(String name, int timerNumber)
public static void close()
throws IOException
IOExceptionpublic static Announce.Level setLevel(Announce.Level l)
public static Announce.Level getActiveLevel()
public static boolean isActiveLevel(Announce.Level l)
public static void setDebugMode(boolean set)
public static String blanks(int n)
protected static String blanks()
protected static void print(Object... o)
protected static void newLine()
public static void message(Object... o)
public static void messageDetailed(Object... o)
public static boolean debug(Object... o)
public static void debugMsg(Object... o)
public static void error(Object... o)
public static void error(Exception e)
public static void errorException(Object... o)
public static void errorException(String message, Exception cause)
public static void errorException(Exception e)
public static void warning(Object... o)
public static void setWriter(Writer w)
public static Writer getWriter()
public static void setWriter(OutputStream s)
protected static void writeDoing(Object... o)
public static void doing(Object... o)
public static void doingDetailed(Object... o)
public static void failed()
public static void doneDetailed()
public static void done()
public static void done(String text)
public static void doneWithProbs()
public static void doneDoing(Object... s)
public static void progressStart(String s, double max)
public static void progressStart(String s, double max, Announce.Level lvl)
public static void progressStart(String s, String id, double max)
public static void progressStart(String s, String id, double max, Announce.Level lvl)
public static void progressShowTime()
public static void progressAt(double d,
Announce.Level lvl)
public static void progressAt(double d)
public static void progressStep(Announce.Level lvl)
public static void progressStep()
public static void progressDone(Announce.Level lvl)
public static void progressDone()
public static long progressTimePassed()
public static void progressFailed()
public static void help(Object... o)
public static void printTime()
public static boolean isHelp(String arg)
public static void main(String[] args)
Copyright © 2018. All rights reserved.