Top Description Fields Constructors Methods
org.aspectj.bridge

public Class MessageHandler

extends Object
implements IMessageHolder
Class Inheritance
All Implemented Interfaces
org.aspectj.bridge.IMessageHolder, org.aspectj.bridge.IMessageHandler
Known Direct Subclasses
org.aspectj.weaver.tools.WeavingAdaptor.WeavingAdaptorMessageHolder
Imports
java.util.ArrayList, .Collections, .List

This handler accumulates messages. To control messages accumulated, clients can ignore messages of a given kind, or install a listener/interceptor. The interceptor handles all messages (even null) first, and can halt further processing/accumlation by returning true. Clients can obtain messages accumulated using the get... methods. XXX this does not permit messages to be removed.
Authors
PARC, Andy Clement

Field Summary

Modifier and TypeField and Description
protected boolean
handleMessageResult

result of handleMessage(..) for messages not accumulated (ignored)

protected final List<IMessage.Kind>
ignoring

kinds of messages to be ignored

protected IMessageHandler
interceptor

listener which can halt processing by returning true

protected final ArrayList<IMessage>
messages

messages accumulated

Constructor Summary

AccessConstructor and Description
public
MessageHandler()

same as MessageHandler(false)

public
MessageHandler(boolean
the result of handleMessage (i.e., if true, then only accumulate messages - stop processing
accumulateOnly
)

Method Summary

Modifier and TypeMethod and Description
public void
clearMessages()

Implements org.aspectj.bridge.IMessageHolder.clearMessages.

Clear the messages without changing other behavior.
public void
dontIgnore(IMessage.Kind kind)

Implements org.aspectj.bridge.IMessageHandler.dontIgnore.

Remove a message kind from the list of those ignored from now on.
public IMessage[]

Returns:

array of error messages, or IMessage.NONE
getErrors
()

public IMessage[]

Returns:

IMessage[] of messages of the right kind
getMessages
(IMessage.Kind
the IMessage.Kind expected, or null for all messages
kind
,
final boolean
if true, also get any greater than the target kind as determined by IMessage.Kind.COMPARATOR
orGreater
)

Implements org.aspectj.bridge.IMessageHolder.getMessages.

Get all messages or those of a specific kind.
public List<IMessage>
public IMessage[]

Returns:

array of warning messages, or IMessage.NONE
getWarnings
()

public boolean

Returns:

true on interception or the constructor value otherwise
handleMessage
(IMessage
the IMessage to handle - never null
message
)

Implements org.aspectj.bridge.IMessageHandler.handleMessage.

This implementation accumulates message.
public boolean
hasAnyMessage(final IMessage.Kind
the IMessage.Kind to check for - accept any if null
kind
,
final boolean
if true, also any greater than the target kind as determined by IMessage.Kind.COMPARATOR
orGreater
)

Implements org.aspectj.bridge.IMessageHolder.hasAnyMessage.

Tell whether this holder has any message of this kind (optionally or greater).
public void
ignore(IMessage.Kind kind)

Implements org.aspectj.bridge.IMessageHandler.ignore.

Set a message kind to be ignored from now on
public void
init()

Initialize this, removing any messages accumulated, kinds being ignored, or interceptor.

public void
init(boolean
boolean value returned from handleMessage after accumulating in list
accumulateOnly
)

Initialize this, removing any messages accumulated, kinds being ignored, or interceptor.

public boolean

Returns:

true if this kind has been flagged to be ignored.
isIgnoring
(IMessage.Kind kind)

Implements org.aspectj.bridge.IMessageHandler.isIgnoring.

Signal clients whether this will ignore messages of a given type.
public int

Returns:

number of messages accumulated of a given kind
numMessages
(IMessage.Kind
the IMessage.Kind expected, or null for all messages
kind
,
final boolean
if true, also any greater than the target kind as determined by IMessage.Kind.COMPARATOR
orGreater
)

Implements org.aspectj.bridge.IMessageHolder.numMessages.

Count the messages currently held by this holder.
public void
setInterceptor(IMessageHandler
the IMessageHandler passed the message. Pass null to remove the old interceptor.
interceptor
)

Set the interceptor which gets any message before we process it.

public String

Returns:

String containing list of messages
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

handleMessageResultback to summary
protected boolean handleMessageResult

result of handleMessage(..) for messages not accumulated (ignored)

ignoringback to summary
protected final List<IMessage.Kind> ignoring

kinds of messages to be ignored

interceptorback to summary
protected IMessageHandler interceptor

listener which can halt processing by returning true

messagesback to summary
protected final ArrayList<IMessage> messages

messages accumulated

Constructor Detail

MessageHandlerback to summary
public MessageHandler()

same as MessageHandler(false)

MessageHandlerback to summary
public MessageHandler(boolean accumulateOnly)
Parameters
accumulateOnly:boolean

the result of handleMessage (i.e., if true, then only accumulate messages - stop processing

Method Detail

clearMessagesback to summary
public void clearMessages()

Implements org.aspectj.bridge.IMessageHolder.clearMessages.

Clear the messages without changing other behavior.

dontIgnoreback to summary
public void dontIgnore(IMessage.Kind kind)

Implements org.aspectj.bridge.IMessageHandler.dontIgnore.

Remove a message kind from the list of those ignored from now on.

getErrorsback to summary
public IMessage[] getErrors()
Returns:IMessage[]

array of error messages, or IMessage.NONE

getMessagesback to summary
public IMessage[] getMessages(IMessage.Kind kind, final boolean orGreater)

Implements org.aspectj.bridge.IMessageHolder.getMessages.

Get all messages or those of a specific kind. Pass null to get all kinds.

Parameters
kind:IMessage.Kind

the IMessage.Kind expected, or null for all messages

orGreater:boolean

Doc from org.aspectj.bridge.IMessageHolder.getMessages.

if true, also get any greater than the target kind as determined by IMessage.Kind.COMPARATOR

Returns:IMessage[]

IMessage[] of messages of the right kind

getUnmodifiableListViewback to summary
public List<IMessage> getUnmodifiableListView()

Implements org.aspectj.bridge.IMessageHolder.getUnmodifiableListView.

Returns:List<IMessage>

Doc from org.aspectj.bridge.IMessageHolder.getUnmodifiableListView.

unmodifiable List view of underlying collection of IMessage

See Also
org.aspectj.bridge.IMessageHolder#getUnmodifiableListView()
getWarningsback to summary
public IMessage[] getWarnings()
Returns:IMessage[]

array of warning messages, or IMessage.NONE

handleMessageback to summary
public boolean handleMessage(IMessage message)

Implements org.aspectj.bridge.IMessageHandler.handleMessage.

This implementation accumulates message. If an interceptor is installed and returns true (message handled), then processing halts and the message is not accumulated.

Parameters
message:IMessage

Doc from org.aspectj.bridge.IMessageHandler.handleMessage.

the IMessage to handle - never null

Returns:boolean

true on interception or the constructor value otherwise

See Also
org.aspectj.bridge.IMessageHandler#handleMessage(IMessage)
hasAnyMessageback to summary
public boolean hasAnyMessage(final IMessage.Kind kind, final boolean orGreater)

Implements org.aspectj.bridge.IMessageHolder.hasAnyMessage.

Doc from org.aspectj.bridge.IMessageHolder.hasAnyMessage.

Tell whether this holder has any message of this kind (optionally or greater).

Parameters
kind:IMessage.Kind

the IMessage.Kind to check for - accept any if null

orGreater:boolean

if true, also any greater than the target kind as determined by IMessage.Kind.COMPARATOR

Returns:boolean

true if this holder has any message of this kind, or if orGreater and any message has a greater kind, as determined by IMessage.Kind.COMPARATOR

See Also
org.aspectj.bridge.IMessageHolder#hasAnyMessage(Kind, boolean)
ignoreback to summary
public void ignore(IMessage.Kind kind)

Implements org.aspectj.bridge.IMessageHandler.ignore.

Set a message kind to be ignored from now on

initback to summary
public void init()

Initialize this, removing any messages accumulated, kinds being ignored, or interceptor. Assume that this should return false from handleMessage(..).

initback to summary
public void init(boolean accumulateOnly)

Initialize this, removing any messages accumulated, kinds being ignored, or interceptor.

Parameters
accumulateOnly:boolean

boolean value returned from handleMessage after accumulating in list

isIgnoringback to summary
public boolean isIgnoring(IMessage.Kind kind)

Implements org.aspectj.bridge.IMessageHandler.isIgnoring.

Doc from org.aspectj.bridge.IMessageHandler.isIgnoring.

Signal clients whether this will ignore messages of a given type. Clients may use this to avoid constructing or sending certain messages.

Returns:boolean

true if this kind has been flagged to be ignored.

See Also
ignore(IMessage.Kind), org.aspectj.bridge.IMessageHandler#isIgnoring(Kind)
numMessagesback to summary
public int numMessages(IMessage.Kind kind, final boolean orGreater)

Implements org.aspectj.bridge.IMessageHolder.numMessages.

Doc from org.aspectj.bridge.IMessageHolder.numMessages.

Count the messages currently held by this holder. Pass null to get all kinds.

Parameters
kind:IMessage.Kind

the IMessage.Kind expected, or null for all messages

orGreater:boolean

if true, also any greater than the target kind as determined by IMessage.Kind.COMPARATOR

Returns:int

number of messages accumulated of a given kind

setInterceptorback to summary
public void setInterceptor(IMessageHandler interceptor)

Set the interceptor which gets any message before we process it.

Parameters
interceptor:IMessageHandler

the IMessageHandler passed the message. Pass null to remove the old interceptor.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

String containing list of messages