|
ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavafe.util.ErrorSet
The ErrorSet
class is responsible for displaying
cautions, warnings, ordinary errors, and fatal errors to the user.
It maintains counts of how many cautions, warnings, and errors have
been reported so far.
Currently, reporting is done via printing all messages to
System.out
. Messages are accompanied by an indication
of whether they are a caution, a warning, an ordinary error, or a
fatal error.
Messages are printed as soon as they are reported. A future
version of ErrorSet
may group together messages
concerning the same file to be printed in location sorted order
once the file has been processed fully. (This will require adding
some kind of end_of_file(F)
call.)
Rough rules for determining what class to report something as:
Location
,
FatalError
Nested Class Summary | |
static interface |
ErrorSet.Reporter
|
static class |
ErrorSet.StandardReporter
|
Field Summary | |
private static java.lang.String |
CAUTION
* Common code for reporting: * * |
static int |
cautions
The number of cautions reported so far. |
private static java.lang.String |
ERROR
|
static int |
errors
The number of errors reported so far, including fatal errors. |
private static java.lang.String |
FATALERROR
|
static int |
fatals
The number of fatal errors so far (some may have been caught and handled) |
static boolean |
gag
If gag is true, then no output is produced by
ErrorSet methods (useful for test harnesses).
|
private static ErrorSet.Reporter |
reporter
|
private static int |
savedCautions
|
private static int |
savedErrorsWarnings
|
private static int |
TABSTOP
|
private static java.lang.String |
WARNING
|
static int |
warnings
The number of warnings reported so far. |
Constructor Summary | |
private |
ErrorSet()
|
Method Summary | |
static void |
assocLoc(int loc)
|
static void |
caution(int loc,
java.lang.String msg)
Report a caution associated with a location. |
static void |
caution(int loc,
java.lang.String msg,
int addLoc)
|
static void |
caution(java.lang.String msg)
Report a caution. |
static boolean |
cautionsSinceMark()
|
static void |
clear()
Resets all error and warning counts. |
static void |
displayColumn(int loc)
See documentation for two-argument version of displayColumn .
|
static void |
displayColumn(int loc,
ClipPolicy policy)
Display (part of) the line that loc occurs on, then indicate via a caret (^) which column loc points to. |
static void |
dump(java.lang.String s)
Prints to System.out the given String (if not null) and a current stack trace, to be used for debugging with print statements. |
static void |
error(int loc,
java.lang.String msg)
Report an ordinary error associated with a location. |
static void |
error(int loc,
java.lang.String msg,
int addLoc)
|
static void |
error(java.lang.String msg)
Report an ordinary error. |
static boolean |
errorsSinceMark()
|
static void |
fatal(int loc,
java.lang.String msg)
Report a fatal error associated with a location. |
static void |
fatal(java.lang.String msg)
Report a fatal error. |
private static java.io.InputStream |
getFile(int loc)
Return a new InputStream for the file that loc refers to or null if an I/O error occurs while attempting to open the stream. |
private static java.lang.String |
getLine(int loc)
Return the line loc refers to or null if an I/O error occurs while attempting to read the line in. |
static ErrorSet.Reporter |
getReporter()
Returns the current output reporter. |
static void |
mark()
|
static void |
notImplemented(boolean print,
int loc,
java.lang.String msg)
Special call to report unimplemented features, so they can be caught and handled more easily. |
private static void |
report(int loc,
java.lang.String type,
java.lang.String msg)
Report information associated with a location. |
static void |
report(java.lang.String msg)
Reports a general message, implemented here in order to have a single location through which error reporting happens. |
private static void |
report(java.lang.String type,
java.lang.String msg)
Report general information. |
static ErrorSet.Reporter |
setReporter(ErrorSet.Reporter r)
Sets the reporter to be used to convey information to the user; returns the previous value of the reporter. |
static void |
warning(int loc,
java.lang.String msg)
Report a warning associated with a location. |
static void |
warning(java.lang.String msg)
Report a warning. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static int cautions
public static int warnings
public static int errors
public static int fatals
public static boolean gag
gag
is true, then no output is produced by
ErrorSet
methods (useful for test harnesses).
Defaults to false.
private static int savedErrorsWarnings
private static int savedCautions
private static final java.lang.String CAUTION
private static final java.lang.String WARNING
private static final java.lang.String ERROR
private static final java.lang.String FATALERROR
private static final int TABSTOP
private static ErrorSet.Reporter reporter
Constructor Detail |
private ErrorSet()
Method Detail |
public static void clear()
public static void mark()
public static boolean errorsSinceMark()
public static boolean cautionsSinceMark()
public static void caution(java.lang.String msg)
The message will be marked as a caution when it is displayed to
the user. Increments cautions
by one.
public static void caution(int loc, java.lang.String msg)
Precondition: loc
must be a regular location or a
whole file location.
The message will be marked as a caution when it is displayed to
the user. Increments cautions
by one.
public static void caution(int loc, java.lang.String msg, int addLoc)
public static void warning(java.lang.String msg)
The message will be marked as a warning when it is displayed to
the user. Increments warnings
by one.
public static void warning(int loc, java.lang.String msg)
Precondition: loc
must be a regular location or a
whole file location.
The message will be marked as a warning when it is displayed to
the user. Increments warnings
by one.
public static void error(java.lang.String msg)
The message will be marked as an error when it is displayed to
the user. Increments errors
by one.
public static void error(int loc, java.lang.String msg)
Precondition: loc
must be a regular location or a
whole file location.
The message will be marked as an error when it is displayed to
the user. Increments errors
by one.
public static void error(int loc, java.lang.String msg, int addLoc)
public static void assocLoc(int loc)
public static void fatal(java.lang.String msg)
The variable errors
is incremented by one, the
error reported as a fatal error, and then an unchecked
FatalError
exception is thrown. The top level of a
Tool
is responsible for catching the
FatalError
, so that it can do whatever cleanup is
required before exiting.
public static void fatal(int loc, java.lang.String msg)
Precondition: loc
must be a regular location or a
whole file location.
The variable errors
is incremented by one, the
error reported as a fatal error, and then an unchecked
FatalError
exception is thrown. The top level of a
Tool
is responsible for catching the
FatalError
, so that it can do whatever cleanup is
required before exiting.
public static void notImplemented(boolean print, int loc, java.lang.String msg)
private static void report(java.lang.String type, java.lang.String msg)
Type contains a non-null String describing the type of the information (usually one of the above constants). The information itself is contained in the non-null String msg.
This function is not responsible for incrementing counts or other ErrorSet functionality.
public static void report(java.lang.String msg)
private static void report(int loc, java.lang.String type, java.lang.String msg)
Type contains a non-null String describing the type of the information (usually one of the above constants). The information itself is contained in the non-null String msg.
Precondition: loc
must be a regular location or a
whole file location.
This function is not responsible for incrementing counts or other ErrorSet functionality.
private static java.io.InputStream getFile(int loc)
Precondition: loc
must be a regular location or a
whole file location.
No error is reported if an I/O error occurs.
private static java.lang.String getLine(int loc)
Precondition: loc
is a regular location (e.g., not
a whole-file location).
No error is reported if an I/O error occurs.
public static void displayColumn(int loc)
displayColumn
.
This version differs in that the default clip policy is applied.
public static void displayColumn(int loc, ClipPolicy policy)
Tabs are expanded before the line is displayed using 8-character tab stops. 8 spaces is perhaps not what the user intended, but there will not be any other lines portrayed against which it must match, and the caret positioning will be consistent with the 8 character spacing; at worst, the line will be spread out more than it would be with shorter tabs.
Precondition: loc
is a regular location (e.g., not
a whole-file location).
If an I/O error does occur, then the user is informed of the
column number and that the line in question is not available; no
error is reported.
By using a non-null policy
argument, a caller can fine-
tune the policy used for introducing ellipses in the printed line.
public static void dump(java.lang.String s)
public static ErrorSet.Reporter getReporter()
public static ErrorSet.Reporter setReporter(ErrorSet.Reporter r)
r
- The new value of the single reporter object.
|
ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |