Package gnu.text
Class SourceMessages
java.lang.Object
gnu.text.SourceLocator.Simple
gnu.text.SourceMessages
- All Implemented Interfaces:
SourceLocator
,SourceLocator
,Locator
A collection of (zero or more) SourceErrors.
Has a "current line number" which clients can use as the default line
number, or clients can explicitly provide a line number.
Does not handle localization of messages.
Similar functionality as JAVA6's javax.tools.DiagnosticCollector.
-
Nested Class Summary
Nested classes/interfaces inherited from interface gnu.text.SourceLocator
SourceLocator.Simple
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic boolean
If true, print out stack trace with any error.static boolean
If true, print out stack trace with any warning.boolean
True if we should sort messages by line number.boolean
static boolean
Fields inherited from class gnu.text.SourceLocator.Simple
filename, position
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkErrors
(Appendable out, int max) Checks if an error was seen; if so, prints and clears the messages.void
clear()
Clear the contained errors and warnings.void
Clear the error count (only).void
error
(char severity, SourceLocator location, String message) void
error
(char severity, SourceLocator location, String message, String code) void
Record a new error at the current default source file location.void
Record a new error.void
void
void
void
error
(SourceError error) Link in an error.final int
The default column number to use for a new error.int
Get number of diagnostics whose severity is one of the characters in the argument.int
Column (one-origin) of end of range; unknown/unspecified is -1.int
Line number (one-origin) of end of range; unknown/unspecified is -1.int
Get the number of errors (not counting warnings).final String
The default filename to use for a new error.final int
The default line number to use for a new error.int
Column (one-origin) of start of range; unknown/unspecified is -1.int
Line number (one-origin) of start of range; unknown/unspecified is -1.boolean
True if position is unlikely to change.void
printAll
(Appendable out, int max) Print all the error messages to an Appendable.boolean
Return true iff errors (not warnings) have been seen.boolean
void
setColumn
(int column) Set the default column number to use for a new error.final void
setLocation
(SourceLocator locator) Copies the current position of locator.final void
setSourceLocator
(SourceLocator locator) Links our location to the one give.final SourceLocator
swapSourceLocator
(SourceLocator locator) toString
(int max) Convert this to a String containing the recorded errors.
-
Field Details
-
stripDirectoriesDefault
public static boolean stripDirectoriesDefault -
stripDirectories
public boolean stripDirectories -
debugStackTraceOnWarning
public static boolean debugStackTraceOnWarningIf true, print out stack trace with any warning. -
debugStackTraceOnError
public static boolean debugStackTraceOnErrorIf true, print out stack trace with any error. -
sortMessages
public boolean sortMessagesTrue if we should sort messages by line number.
-
-
Constructor Details
-
SourceMessages
public SourceMessages()
-
-
Method Details
-
getErrors
-
seenErrors
public boolean seenErrors()Return true iff errors (not warnings) have been seen. -
seenErrorsOrWarnings
public boolean seenErrorsOrWarnings() -
getErrorCount
public int getErrorCount()Get the number of errors (not counting warnings). -
getCount
Get number of diagnostics whose severity is one of the characters in the argument. -
clearErrors
public void clearErrors()Clear the error count (only). -
clear
public void clear()Clear the contained errors and warnings. -
error
Link in an error. -
error
Record a new error.- Parameters:
severity
- is the seriousness of the error - one of 'w' (for warning), 'e' (for error), or 'f' (for fatal error)filename
- the name or URL of the file containing the errorline
- the (1-origin) line number or 0 if unknowncolumn
- the (1-origin) column number or 0 if unknownmessage
- the error message
-
error
-
error
-
error
-
error
Record a new error at the current default source file location.- Parameters:
severity
- is the seriousness of the error - one of 'w' (for warning), 'e' (for error), or 'f' (for fatal error)message
- the error message
-
error
-
error
-
printAll
Print all the error messages to an Appendable. -
toString
Convert this to a String containing the recorded errors.- Parameters:
max
- the maximum number of error error to list- Returns:
- a String with one '\n'-terminated line per recorded error
-
checkErrors
Checks if an error was seen; if so, prints and clears the messages.- Parameters:
out
- where to write the error message tomax
- maximum number of messages to print (can be 0)
-
setSourceLocator
Links our location to the one give. -
swapSourceLocator
-
setLocation
Copies the current position of locator.- Overrides:
setLocation
in classSourceLocator.Simple
-
getPublicId
- Specified by:
getPublicId
in interfaceLocator
- Specified by:
getPublicId
in interfaceSourceLocator
- Specified by:
getPublicId
in interfaceSourceLocator
- Overrides:
getPublicId
in classSourceLocator.Simple
-
getSystemId
- Specified by:
getSystemId
in interfaceLocator
- Specified by:
getSystemId
in interfaceSourceLocator
- Specified by:
getSystemId
in interfaceSourceLocator
- Overrides:
getSystemId
in classSourceLocator.Simple
-
isStableSourceLocation
public boolean isStableSourceLocation()Description copied from interface:SourceLocator
True if position is unlikely to change. True for an expression but not an input file.- Specified by:
isStableSourceLocation
in interfaceSourceLocator
- Overrides:
isStableSourceLocation
in classSourceLocator.Simple
-
getFileName
The default filename to use for a new error.- Specified by:
getFileName
in interfaceSourceLocator
- Overrides:
getFileName
in classSourceLocator.Simple
-
getLineNumber
public final int getLineNumber()The default line number to use for a new error.- Specified by:
getLineNumber
in interfaceLocator
- Specified by:
getLineNumber
in interfaceSourceLocator
- Specified by:
getLineNumber
in interfaceSourceLocator
- Overrides:
getLineNumber
in classSourceLocator.Simple
-
getColumnNumber
public final int getColumnNumber()The default column number to use for a new error.- Specified by:
getColumnNumber
in interfaceLocator
- Specified by:
getColumnNumber
in interfaceSourceLocator
- Specified by:
getColumnNumber
in interfaceSourceLocator
- Overrides:
getColumnNumber
in classSourceLocator.Simple
-
getStartLine
public int getStartLine()Description copied from interface:SourceLocator
Line number (one-origin) of start of range; unknown/unspecified is -1.- Specified by:
getStartLine
in interfaceSourceLocator
- Overrides:
getStartLine
in classSourceLocator.Simple
-
getStartColumn
public int getStartColumn()Description copied from interface:SourceLocator
Column (one-origin) of start of range; unknown/unspecified is -1.- Specified by:
getStartColumn
in interfaceSourceLocator
- Overrides:
getStartColumn
in classSourceLocator.Simple
-
getEndLine
public int getEndLine()Description copied from interface:SourceLocator
Line number (one-origin) of end of range; unknown/unspecified is -1.- Specified by:
getEndLine
in interfaceSourceLocator
- Overrides:
getEndLine
in classSourceLocator.Simple
-
getEndColumn
public int getEndColumn()Description copied from interface:SourceLocator
Column (one-origin) of end of range; unknown/unspecified is -1.- Specified by:
getEndColumn
in interfaceSourceLocator
- Overrides:
getEndColumn
in classSourceLocator.Simple
-
setColumn
public void setColumn(int column) Set the default column number to use for a new error.
-