|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.groovy.control.ProcessingUnit
A base class for data structures that can collect messages and errors during processing.
Field Summary | |
protected ClassLoader |
classLoader
The ClassLoader to use during processing |
protected CompilerConfiguration |
configuration
Configuration and other settings that control processing |
protected LinkedList |
errors
ErrorMessages collected during processing |
protected boolean |
fatal
Set on the first fatal error |
protected PrintWriter |
output
A place to send warning output |
protected int |
phase
The current phase |
protected boolean |
phaseComplete
Set true if phase is finished |
protected int |
tolerance
The number of non-fatal errors to allow before fail() |
protected int |
warningLevel
Warnings will be filtered on this level |
protected LinkedList |
warnings
WarningMessages collected during processing |
Constructor Summary | |
ProcessingUnit(CompilerConfiguration configuration,
ClassLoader classLoader)
Initialize the ProcessingUnit to the empty state. |
Method Summary | |
void |
addError(Message message)
Adds a non-fatal error to the message set. |
void |
addError(Message message,
boolean fatal)
Adds an optionally-fatal error to the message set. |
void |
addException(Exception cause)
|
void |
addFatalError(Message message)
Adds a fatal exception to the message set and throws the unit as a PhaseFailedException. |
void |
addWarning(WarningMessage message)
Adds a WarningMessage to the message set. |
void |
completePhase()
Marks the current phase complete and processes any errors. |
void |
configure(CompilerConfiguration configuration)
Reconfigures the ProcessingUnit. |
protected void |
fail()
Causes the current phase to fail by throwing a CompilationFailedException. |
ClassLoader |
getClassLoader()
Returns the class loader in use by this ProcessingUnit. |
CompilerConfiguration |
getConfiguration()
|
Message |
getError(int index)
Returns the specified error message, or null. |
int |
getErrorCount()
Returns the number of errors. |
List |
getErrors()
Returns the list of errors, or null if there are none. |
Exception |
getException(int index)
Convenience routine to return the specified error's underlying Exception, or null if it isn't one. |
int |
getPhase()
Returns the current phase. |
String |
getPhaseDescription()
Returns the description for the current phase. |
SyntaxException |
getSyntaxError(int index)
Convenience routine to return the specified error's underlying SyntaxException, or null if it isn't one. |
WarningMessage |
getWarning(int index)
Returns the specified warning message, or null. |
int |
getWarningCount()
Returns the number of warnings. |
List |
getWarnings()
Returns the list of warnings, or null if there are none. |
void |
gotoPhase(int phase)
Wraps up any pending operations for the current phase and switches to the next phase. |
boolean |
hasErrors()
Returns true if there are any errors pending. |
void |
nextPhase()
A synonym for gotoPhase( phase + 1 ) . |
void |
setClassLoader(ClassLoader loader)
Sets the class loader for use by this ProcessingUnit. |
void |
setConfiguration(CompilerConfiguration configuration)
|
void |
write(PrintWriter writer,
Janitor janitor)
Writes error messages to the specified PrintWriter. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected LinkedList warnings
protected LinkedList errors
protected boolean fatal
protected int phase
protected boolean phaseComplete
protected CompilerConfiguration configuration
protected int warningLevel
protected PrintWriter output
protected int tolerance
protected ClassLoader classLoader
Constructor Detail |
public ProcessingUnit(CompilerConfiguration configuration, ClassLoader classLoader)
Method Detail |
public void configure(CompilerConfiguration configuration)
public CompilerConfiguration getConfiguration()
public void setConfiguration(CompilerConfiguration configuration)
public ClassLoader getClassLoader()
public void setClassLoader(ClassLoader loader)
public int getPhase()
public String getPhaseDescription()
public List getWarnings()
public List getErrors()
public int getWarningCount()
public int getErrorCount()
public WarningMessage getWarning(int index)
public Message getError(int index)
public SyntaxException getSyntaxError(int index)
public Exception getException(int index)
public void addWarning(WarningMessage message)
public void addError(Message message) throws CompilationFailedException
CompilationFailedException
public void addError(Message message, boolean fatal) throws CompilationFailedException
CompilationFailedException
public void addFatalError(Message message) throws CompilationFailedException
CompilationFailedException
public void addException(Exception cause) throws CompilationFailedException
CompilationFailedException
public boolean hasErrors()
public void completePhase() throws CompilationFailedException
CompilationFailedException
public void nextPhase() throws CompilationFailedException
gotoPhase( phase + 1 )
.
CompilationFailedException
public void gotoPhase(int phase) throws CompilationFailedException
CompilationFailedException
protected void fail() throws CompilationFailedException
CompilationFailedException
public void write(PrintWriter writer, Janitor janitor)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |