poker.util
Class Reporter

java.lang.Object
  extended by poker.util.Reporter

public class Reporter
extends java.lang.Object

Handles reporting messages to stdout or stderr, and logging messages to files. Defaults to printing output to stderr.

Version:
1.3.6
Author:
Aaron Davidson

Field Summary
 int level
          Non-negative value indicating priority threshold for reporting messages.
 
Constructor Summary
Reporter()
           
Reporter(java.lang.String logfile)
           
 
Method Summary
 void addReportListener(ReportListener rl)
           
 void appendLog(java.lang.String s)
          Logs a message to a file.
static java.lang.String center(java.lang.String s, int size)
          Pads s with space on both sides so as to center it, returning a string of length size.
 void consoleOff()
          disable the output to console
 void consoleOn()
          Set the output to console
 void debug(java.lang.String s)
           
 void debugb(java.lang.String s)
           
static boolean fileExists(java.lang.String s)
           
 void finalize()
           
 java.lang.String format(java.lang.String s)
           
static Reporter getReporter()
           
static java.lang.String loadExec(java.lang.String cmnd)
          Attempts to execute the command.
static java.lang.String loadFile(java.lang.String fname)
          Load the contents of a text file into a String
static void log(java.lang.String s, java.lang.String file)
          Logs a message to a file.
static java.lang.String pad(java.lang.String s, int size)
           
static java.lang.String padLeft(java.lang.String s, int size)
           
static void pause()
          wait for the user to type enter.
 void print(java.lang.String s)
          Print a message to the current output stream.
 void println(java.lang.String s)
          Print a message to the current output stream.
 java.lang.String prompt(java.lang.String s)
          Prompt the user for a string.
static java.lang.String readLine()
          Read a line of text from stdin.
static java.lang.String readString()
          Return the next line typed by the user.
 void removeReportListener(ReportListener rl)
           
 void report(java.lang.String s)
          Print a message to the current output stream.
 void report(java.lang.String s, int priority)
          Print a message to the current output stream if the priority is high enough.
 void reportb(java.lang.String s)
          Print a message to the current output stream.
static double round(double f, int precision)
           
 void setActive(boolean t)
           
 void setDebug(boolean on)
           
 void setLogFile(java.lang.String logfile)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

level

public int level
Non-negative value indicating priority threshold for reporting messages.

Constructor Detail

Reporter

public Reporter()

Reporter

public Reporter(java.lang.String logfile)
Method Detail

getReporter

public static Reporter getReporter()

setLogFile

public void setLogFile(java.lang.String logfile)

setDebug

public void setDebug(boolean on)

setActive

public void setActive(boolean t)

debug

public void debug(java.lang.String s)

debugb

public void debugb(java.lang.String s)

addReportListener

public void addReportListener(ReportListener rl)

removeReportListener

public void removeReportListener(ReportListener rl)

consoleOff

public void consoleOff()
disable the output to console


consoleOn

public void consoleOn()
Set the output to console


println

public void println(java.lang.String s)
Print a message to the current output stream.

Parameters:
s - the string to print.

print

public void print(java.lang.String s)
Print a message to the current output stream. Does not print a line feed at the end of the string.

Parameters:
s - the string to print.

report

public void report(java.lang.String s)
Print a message to the current output stream.

Parameters:
s - the string to print.

reportb

public void reportb(java.lang.String s)
Print a message to the current output stream. Does not print a line feed at the end of the string.

Parameters:
s - the string to print.

report

public void report(java.lang.String s,
                   int priority)
Print a message to the current output stream if the priority is high enough. Note: 0 is the highest priority. Larger numbers are of lower priority.

Parameters:
s - the string to print.
priority - the priority of this message

log

public static void log(java.lang.String s,
                       java.lang.String file)
Logs a message to a file.

Parameters:
s - the message to log.
file - the name of the file to log to.

appendLog

public void appendLog(java.lang.String s)
Logs a message to a file.

Parameters:
s - the message to log.

readLine

public static java.lang.String readLine()
Read a line of text from stdin.

Returns:
a line of text from stdin

round

public static double round(double f,
                           int precision)

pad

public static java.lang.String pad(java.lang.String s,
                                   int size)

padLeft

public static java.lang.String padLeft(java.lang.String s,
                                       int size)

center

public static java.lang.String center(java.lang.String s,
                                      int size)
Pads s with space on both sides so as to center it, returning a string of length size.


finalize

public void finalize()
Overrides:
finalize in class java.lang.Object

loadFile

public static java.lang.String loadFile(java.lang.String fname)
Load the contents of a text file into a String

Parameters:
fname - the file name
Returns:
the contents of the file

loadExec

public static java.lang.String loadExec(java.lang.String cmnd)
Attempts to execute the command.

Parameters:
cmnd - the command to execute
Returns:
null if unsuccessful, or the output of the command

prompt

public java.lang.String prompt(java.lang.String s)
Prompt the user for a string.

Parameters:
s - the text prompt
Returns:
what the user typed.

readString

public static java.lang.String readString()
Return the next line typed by the user.

Returns:
what the user typed.

pause

public static void pause()
wait for the user to type enter.


format

public java.lang.String format(java.lang.String s)

fileExists

public static boolean fileExists(java.lang.String s)