org.codehaus.groovy.tools
Class ExceptionCollector

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byorg.codehaus.groovy.GroovyException
              extended byorg.codehaus.groovy.tools.ExceptionCollector
All Implemented Interfaces:
java.io.Serializable

public class ExceptionCollector
extends GroovyException

Provides a collector for Groovy compilation exceptions that throws itself when the volume of compilation errors pass a specified threshold. The threshold is met when either a single fatal exception or some configured maximum of non-fatal exceptions make it into the set.

Created by org.codehaus.groovy.tools.Compiler, and filled by the lexer, parser, and code generation subsystems.

Version:
$Revision: 1.1 $
Author:
Chris Poirier
See Also:
Serialized Form

Constructor Summary
ExceptionCollector()
          Initializes the exception set so that all exceptions are considered fatal.
ExceptionCollector(int limit)
          Initializes the exception set so that some number of non-fatal exceptions triggers fatality.
ExceptionCollector(java.lang.String message, int limit)
          Initializes the exception set so that some number of non-fatal exceptions triggers fatality.
 
Method Summary
 void add(GroovyException exception)
          Adds a GroovyException to the collector.
 void add(GroovyException exception, boolean withThrow)
          Adds a GroovyException to the collector.
 GroovyException get(int child)
          Returns the Exception at the specified offset.
 java.lang.String getMessage()
          Returns a string summary of the exception set.
 boolean hasCause()
          Returns true if throwIfCause() should throw.
 boolean isEmpty()
          Returns true if the collector is empty.
 boolean isFull()
          Returns true if the set has reached its limit.
 java.util.Iterator iterator()
          Returns an Iterator to the exceptions in the set.
 void merge(ExceptionCollector other)
          Merges in data from another collector.
 void merge(ExceptionCollector other, boolean withThrow)
          Merges in data from another collector.
 int size()
          Returns the number of exceptions in the set.
 void throwFirstChild()
          Throws the first exception.
 void throwIfCause()
          Throws this collector if there is sufficient cause.
 void throwUnlessEmpty()
          Throws this collector if it isn't empty.
 java.lang.String toString()
          Returns a string representation of the exception set.
 
Methods inherited from class org.codehaus.groovy.GroovyException
isFatal, setFatal
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExceptionCollector

public ExceptionCollector()
Initializes the exception set so that all exceptions are considered fatal.


ExceptionCollector

public ExceptionCollector(int limit)
Initializes the exception set so that some number of non-fatal exceptions triggers fatality.


ExceptionCollector

public ExceptionCollector(java.lang.String message,
                          int limit)
Initializes the exception set so that some number of non-fatal exceptions triggers fatality.

Method Detail

add

public void add(GroovyException exception)
         throws ExceptionCollector
Adds a GroovyException to the collector. Throws the collector if hasCause().

Throws:
ExceptionCollector

add

public void add(GroovyException exception,
                boolean withThrow)
         throws ExceptionCollector
Adds a GroovyException to the collector. Throws the collector if hasCause() and withThrow.

Throws:
ExceptionCollector

merge

public void merge(ExceptionCollector other)
           throws ExceptionCollector
Merges in data from another collector. Throws this collector if hasCause().

Throws:
ExceptionCollector

merge

public void merge(ExceptionCollector other,
                  boolean withThrow)
           throws ExceptionCollector
Merges in data from another collector. Throws this collector if hasCause() and withThrow.

Throws:
ExceptionCollector

throwIfCause

public void throwIfCause()
                  throws ExceptionCollector
Throws this collector if there is sufficient cause.

Throws:
ExceptionCollector

throwUnlessEmpty

public void throwUnlessEmpty()
                      throws ExceptionCollector
Throws this collector if it isn't empty.

Throws:
ExceptionCollector

isEmpty

public boolean isEmpty()
Returns true if the collector is empty.


isFull

public boolean isFull()
Returns true if the set has reached its limit.


hasCause

public boolean hasCause()
Returns true if throwIfCause() should throw.


size

public int size()
Returns the number of exceptions in the set.


get

public GroovyException get(int child)
Returns the Exception at the specified offset.


throwFirstChild

public void throwFirstChild()
                     throws GroovyException
Throws the first exception. For convenience in testing.

Throws:
GroovyException

iterator

public java.util.Iterator iterator()
Returns an Iterator to the exceptions in the set.


getMessage

public java.lang.String getMessage()
Returns a string summary of the exception set.


toString

public java.lang.String toString()
Returns a string representation of the exception set.



Copyright © 2003-2004 The Codehaus. All Rights Reserved.