|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavatools.administrative.Announce
public class Announce
This class is part of the Java Tools (see http://mpii.de/yago-naga/javatools).
It is licensed under the Creative Commons Attribution License
(see http://creativecommons.org/licenses/by/3.0) by
the YAGO-NAGA team (see http://mpii.de/yago-naga).
This class can make progress announcements. The announcements are handled by an object,
but static methods exist to simplify the calls.
Example:
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 doneThe 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.
Nested Class Summary | |
---|---|
static class |
Announce.Level
Log level |
Field Summary | |
---|---|
static java.lang.String |
blanks
Blanks |
static int |
MAXDOTS
Maximal number of dots |
Constructor Summary | |
---|---|
Announce()
|
Method Summary | |
---|---|
static java.lang.String |
blanks(int n)
Returns blanks |
static void |
close()
Closes the writer |
static boolean |
debug(java.lang.Object... o)
Prints a debug message with the class and method name preceeding |
static void |
debugMsg(java.lang.Object... o)
Prints a debug message |
static void |
doing(java.lang.Object... o)
Writes "s..." - intended for major states telling a user what the program does |
static void |
doingDetailed(java.lang.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(java.lang.String text)
Writes "done NEWLINE" - closes a doing statement |
static void |
doneDetailed()
Writes "done NEWLINE" - closes a doingDetailed statement |
static void |
doneDoing(java.lang.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(java.lang.Exception e)
Prints an exception and aborts by exiting (aborts even if log level is mute) |
static void |
error(java.lang.Object... o)
Prints an error message and aborts by exiting (aborts even if log level is mute) |
static void |
errorException(java.lang.Exception e)
Prints an exception and aborts by throwing a RuntimeException (aborts even if log level is mute) |
static void |
errorException(java.lang.Object... o)
Prints an error message and aborts by throwing a RuntimeException (aborts even if log level is mute) |
static void |
errorException(java.lang.String message,
java.lang.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 java.lang.Long |
getTime(int number)
Retrieves the accumulated time the named timer has run for |
static java.util.Vector<java.lang.Long> |
getTimers()
Retrieves the accumulated time the named timer has run for |
static java.io.Writer |
getWriter()
Gets the writer the data is written to |
static void |
help(java.lang.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(java.lang.String arg)
Says whether a command line argument asks for help |
static void |
main(java.lang.String[] args)
Test routine |
static void |
message(java.lang.Object... o)
Prints an (indented) message intended to provide additional information to the user at a top level |
static void |
messageDetailed(java.lang.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 |
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(java.lang.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(java.lang.String s,
double max)
Writes s, prepares to make progress up to max |
static void |
progressStart(java.lang.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(java.lang.String s,
java.lang.String id,
double max)
Writes s, prepares to make progress up to max, remembers id as name for progress counter |
static void |
progressStart(java.lang.String s,
java.lang.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(java.io.OutputStream s)
Sets the writer the data is written to |
static void |
setWriter(java.io.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 |
static void |
stopTimer(int number)
Stops a named timer |
static void |
warning(java.lang.Object... o)
Prints a warning |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static int MAXDOTS
public static final java.lang.String blanks
Constructor Detail |
---|
public Announce()
Method Detail |
---|
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 java.lang.Long getTime(int number)
public static java.util.Vector<java.lang.Long> getTimers()
public static void resetTimer(int number)
public static void printTime(int timerNumber)
public static void printTime(java.lang.String name, int timerNumber)
public static void close() throws java.io.IOException
java.io.IOException
public 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 java.lang.String blanks(int n)
public static void message(java.lang.Object... o)
public static void messageDetailed(java.lang.Object... o)
public static boolean debug(java.lang.Object... o)
public static void debugMsg(java.lang.Object... o)
public static void error(java.lang.Object... o)
public static void error(java.lang.Exception e)
public static void errorException(java.lang.Object... o)
public static void errorException(java.lang.String message, java.lang.Exception cause)
public static void errorException(java.lang.Exception e)
public static void warning(java.lang.Object... o)
public static void setWriter(java.io.Writer w)
public static java.io.Writer getWriter()
public static void setWriter(java.io.OutputStream s)
public static void doing(java.lang.Object... o)
public static void doingDetailed(java.lang.Object... o)
public static void failed()
public static void doneDetailed()
public static void done()
public static void done(java.lang.String text)
public static void doneWithProbs()
public static void doneDoing(java.lang.Object... s)
public static void progressStart(java.lang.String s, double max)
public static void progressStart(java.lang.String s, double max, Announce.Level lvl)
public static void progressStart(java.lang.String s, java.lang.String id, double max)
public static void progressStart(java.lang.String s, java.lang.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(java.lang.Object... o)
public static void printTime()
public static boolean isHelp(java.lang.String arg)
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |