org.aspectj.bridge
Class CountingMessageHandler

java.lang.Object
  extended by org.aspectj.bridge.CountingMessageHandler
All Implemented Interfaces:
IMessageHandler

public class CountingMessageHandler
extends java.lang.Object
implements IMessageHandler

Wrap an IMessageHandler to count messages handled. Messages being ignored by the delegate IMessageHandler are not counted.


Field Summary
 IMessageHandler delegate
           
 CountingMessageHandler proxy
           
 
Fields inherited from interface org.aspectj.bridge.IMessageHandler
SYSTEM_ERR, SYSTEM_OUT, THROW
 
Constructor Summary
CountingMessageHandler(IMessageHandler delegate)
           
 
Method Summary
 void dontIgnore(IMessage.Kind kind)
          Delegate
 boolean handleMessage(IMessage message)
          Handle message, by reporting and/or throwing an AbortException.
 boolean hasErrors()
           
 void ignore(IMessage.Kind kind)
          Delegate
 boolean isIgnoring(IMessage.Kind kind)
          Signal clients whether this will ignore messages of a given type.
static CountingMessageHandler makeCountingMessageHandler(IMessageHandler handler)
           
 int numMessages(IMessage.Kind kind, boolean orGreater)
          Return count of messages seen through this interface.
 void reset()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

delegate

public final IMessageHandler delegate

proxy

public final CountingMessageHandler proxy
Constructor Detail

CountingMessageHandler

public CountingMessageHandler(IMessageHandler delegate)
Method Detail

makeCountingMessageHandler

public static CountingMessageHandler makeCountingMessageHandler(IMessageHandler handler)

handleMessage

public boolean handleMessage(IMessage message)
                      throws AbortException
Description copied from interface: IMessageHandler
Handle message, by reporting and/or throwing an AbortException.

Specified by:
handleMessage in interface IMessageHandler
Parameters:
message - the IMessage to handle - never null
Returns:
delegate.handleMessage(IMessage)
Throws:
AbortException - depending on handler logic.

isIgnoring

public boolean isIgnoring(IMessage.Kind kind)
Description copied from interface: IMessageHandler
Signal clients whether this will ignore messages of a given type. Clients may use this to avoid constructing or sending certain messages.

Specified by:
isIgnoring in interface IMessageHandler
Returns:
delegate.isIgnoring(IMessage.Kind)

dontIgnore

public void dontIgnore(IMessage.Kind kind)
Delegate

Specified by:
dontIgnore in interface IMessageHandler
Parameters:
kind -
See Also:
IMessageHandler.isIgnoring(org.aspectj.bridge.IMessage.Kind)

ignore

public void ignore(IMessage.Kind kind)
Delegate

Specified by:
ignore in interface IMessageHandler
Parameters:
kind -
See Also:
IMessageHandler.ignore(org.aspectj.bridge.IMessage.Kind)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
delegate.toString()

numMessages

public int numMessages(IMessage.Kind kind,
                       boolean orGreater)
Return count of messages seen through this interface.

Parameters:
kind - the IMessage.Kind of the messages to count (if null, count all)
orGreater - if true, then count this kind and any considered greater by the ordering of IMessage.Kind.COMPARATOR
Returns:
number of messages of this kind (optionally or greater)
See Also:
IMessage.Kind.COMPARATOR

hasErrors

public boolean hasErrors()
Returns:
true if 0 is less than numMessages(IMessage.ERROR, true)

reset

public void reset()