FileDocCategorySizeDatePackage
VectorErrorHandler.javaAPI DocApache log4j 1.2.153922Sat Aug 25 00:09:34 BST 2007org.apache.log4j

VectorErrorHandler

public final class VectorErrorHandler extends Object implements ErrorHandler
Utility class used in testing to capture errors dispatched by appenders.
author
Curt Arnold

Fields Summary
private Logger
logger
Logger.
private Appender
appender
Appender.
private Appender
backupAppender
Backup appender.
private final Vector
errors
Array of processed errors.
Constructors Summary
public VectorErrorHandler()
Default constructor.


       
    
  
Methods Summary
public voidactivateOptions()
{@inheritDoc}

  
public voiderror(java.lang.String message, java.lang.Exception e, int errorCode)
{@inheritDoc}

    error(message, e, errorCode, null);
  
public voiderror(java.lang.String message)
{@inheritDoc}

    error(message, null, -1, null);
  
public voiderror(java.lang.String message, java.lang.Exception e, int errorCode, org.apache.log4j.spi.LoggingEvent event)
{@inheritDoc}

    errors.addElement(
      new Object[] { message, e, new Integer(errorCode), event });
  
public org.apache.log4j.AppendergetAppender()
Get appender.

return
appender, may be null.

    return appender;
  
public org.apache.log4j.AppendergetBackupAppender()
Get backup appender.

return
backup appender, may be null.

    return backupAppender;
  
public intgetErrorCode(int index)
Gets error code from specified error.

param
index index.
return
error code, -1 if not specified.

    return ((Integer) ((Object[]) errors.elementAt(index))[2]).intValue();
  
public org.apache.log4j.spi.LoggingEventgetEvent(int index)
Gets logging event from specified error.

param
index index.
return
exception.

    return (LoggingEvent) ((Object[]) errors.elementAt(index))[3];
  
public java.lang.ExceptiongetException(int index)
Gets exception from specified error.

param
index index.
return
exception.

    return (Exception) ((Object[]) errors.elementAt(index))[1];
  
public org.apache.log4j.LoggergetLogger()
Gets last logger specified by setLogger.

return
logger.

    return logger;
  
public java.lang.StringgetMessage(int index)
Gets message from specified error.

param
index index.
return
message, may be null.

    return (String) ((Object[]) errors.elementAt(index))[0];
  
public voidsetAppender(org.apache.log4j.Appender appender)
{@inheritDoc}

    this.appender = appender;
  
public voidsetBackupAppender(org.apache.log4j.Appender appender)
{@inheritDoc}

    this.backupAppender = appender;
  
public voidsetLogger(org.apache.log4j.Logger logger)
{@inheritDoc}

    this.logger = logger;
  
public intsize()
Gets number of errors captured.

return
number of errors captured.

    return errors.size();