FileDocCategorySizeDatePackage
ErrorCounter.javaAPI DocHibernate 3.2.51898Thu Feb 09 05:37:36 GMT 2006org.hibernate.hql.ast

ErrorCounter

public class ErrorCounter extends Object implements ParseErrorHandler
An error handler that counts parsing errors and warnings.

Fields Summary
private Log
log
private Log
hqlLog
private List
errorList
private List
warningList
private List
recognitionExceptions
Constructors Summary
Methods Summary
public intgetErrorCount()

		return errorList.size();
	
private java.lang.StringgetErrorString()

		StringBuffer buf = new StringBuffer();
		for ( Iterator iterator = errorList.iterator(); iterator.hasNext(); ) {
			buf.append( ( String ) iterator.next() );
			if ( iterator.hasNext() ) buf.append( "\n" );

		}
		return buf.toString();
	
public voidreportError(antlr.RecognitionException e)


	    
		reportError( e.toString() );
		recognitionExceptions.add( e );
		if ( log.isDebugEnabled() ) {
			log.debug( e, e );
		}
	
public voidreportError(java.lang.String message)

		hqlLog.error( message );
		errorList.add( message );
	
public voidreportWarning(java.lang.String message)

		hqlLog.debug( message );
		warningList.add( message );
	
public voidthrowQueryException()

		if ( getErrorCount() > 0 ) {
			if ( recognitionExceptions.size() > 0 ) {
				throw QuerySyntaxException.convert( ( RecognitionException ) recognitionExceptions.get( 0 ) );
			}
			else {
				throw new QueryException( getErrorString() );
			}
		}
		else {
			// all clear
			if ( log.isDebugEnabled() ) {
				log.debug( "throwQueryException() : no errors" );
			}
		}