Top Description Inners Fields Constructors Methods
org.aspectj.bridge

public Class MessageUtil

extends Object
Class Inheritance
Imports
java.io.File, .IOException, .OutputStream, .PrintStream, .PrintWriter, .StringWriter, java.util.ArrayList, .Arrays, .Collection, .Collections, .Iterator, .List, org.aspectj.bridge.IMessage.Kind, org.aspectj.util.LangUtil

Convenience API's for constructing, printing, and sending messages.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
MessageUtil.IMessageRenderer

parameterize rendering behavior for messages

private static class
MessageUtil.KindSelector

implementation for PICK_...

Field Summary

Modifier and TypeField and Description
public static final IMessage
public static final IMessage
public static final IMessage
public static final IMessage
public static final IMessage
public static final MessageUtil.IMessageRenderer
MESSAGE_ALL

render message without restriction, up to 10K, including throwable

public static final MessageUtil.IMessageRenderer
MESSAGE_LABEL

render message as label, i.e., less than 33 char

public static final MessageUtil.IMessageRenderer
MESSAGE_LABEL_NOLOC

render message as label, i.e., less than 33 char, with no source location

public static final MessageUtil.IMessageRenderer
MESSAGE_LINE

render message as line, i.e., less than 75 char, no internal line sep

public static final MessageUtil.IMessageRenderer
MESSAGE_LINE_FORCE_LOC

render message as line, i.e., less than 75 char, no internal line sep, trying to trim text as needed to end with a full source location

public static final MessageUtil.IMessageRenderer
MESSAGE_MOST

render message without restriction, except any Throwable thrown

public static final MessageUtil.IMessageRenderer
MESSAGE_SCALED

render message more verbosely if it is worse

public static final MessageUtil.IMessageRenderer
MESSAGE_SHORT

render message using toShortString(IMessage)"

public static final MessageUtil.IMessageRenderer
MESSAGE_TOSTRING

render message using its toString() or "((IMessage) null)"

public static final MessageUtil.IMessageRenderer
MESSAGE_WIDELINE

render message as wide line, i.e., less than 256 char, no internal line sep, except any Throwable thrown

public static final IMessageHandler
public static final IMessageHandler
public static final IMessageHandler
public static final IMessageHandler
public static final IMessageHandler
public static final IMessageHandler
public static final IMessageHandler
public static final IMessageHandler
public static final IMessageHandler
public static final IMessageHandler
public static final IMessageHandler
public static final IMessageHandler
public static final IMessageHandler
public static final IMessage

Constructor Summary

AccessConstructor and Description
private
MessageUtil()

utility class

Method Summary

Modifier and TypeMethod and Description
public static boolean
abort(IMessageHandler handler, String message)

handle abort message (ignored if handler is null)

public static boolean
abort(IMessageHandler handler, String message, Throwable t)

create and handle exception message (ignored if handler is null)

public static IMessage

Returns:

ABORT_NOMESSAGE if message is empty or IMessage otherwise
abort
(String message)

public static IMessage

Returns:

abort IMessage with thrown and message o ABORT_NOMESSAGE if both are empty/null
abort
(String message, Throwable thrown)

public static String
addExtraSourceLocations(IMessage message, String baseMessage)

public static boolean
debug(IMessageHandler handler, String message)

create and handle debug message (ignored if handler is null)

public static IMessage

Returns:

IMessage.DEBUG message with message content
debug
(String message)

public static boolean
error(IMessageHandler handler, String message)

create and handle error message (ignored if handler is null)

public static IMessage

Returns:

ERROR_NOMESSAGE if message is empty or IMessage otherwise
error
(String message, ISourceLocation location)

public static IMessage

Returns:

ERROR_NOMESSAGE if message is empty or IMessage otherwise
error
(String message)

public static boolean
fail(IMessageHandler handler, String message)

create and handle fail message (ignored if handler is null)

public static boolean
fail(IMessageHandler handler, String message, Throwable thrown)

create and handle fail message (ignored if handler is null)

public static IMessage

Returns:

FAIL_NOMESSAGE if message is empty or IMessage otherwise
fail
(String message)

public static IMessage

Returns:

FAIL_NOMESSAGE if thrown is null and message is empty or IMessage FAIL with message and thrown otherwise
fail
(String message, Throwable thrown)

Create fail message.

public static IMessage.Kind

Returns:

Kind the associated IMessage.Kind, or null if not found
getKind
(String
the String representing the kind of message (IMessage.Kind.toString())
kind
)

Map to the kind of messages associated with this string key.

public static List<IMessage>

Returns:

unmodifiable list of IMessage complying with parameters
getMessages
(IMessageHolder holder, IMessage.Kind kind, boolean orGreater, String infix)

public static List<IMessage>
getMessages(List<IMessage>
if null, return EMPTY_LIST
messages
,
IMessage.Kind
if null, return messages
kind
)

Extract messages of type kind from the input list.

public static IMessage[]

Returns:

unmodifiable list of specified IMessage
getMessagesExcept
(IMessageHolder holder, final IMessage.Kind kind, final boolean orGreater)

Select all messages in holder except those of the same kind (optionally or greater).

public static boolean

Returns:

false if any sink.handleMessage(..) failed
handleAll
(IMessageHandler
the IMessageHandler sink for all messages in source
sink
,
IMessageHolder
the IMessageHolder source for all messages to handle
source
,
boolean
if true, stop on first failure
fastFail
)

Handle all messages in the second handler using the first

public static boolean

Returns:

false if any sink.handleMessage(..) failed
handleAll
(IMessageHandler
the IMessageHandler sink for all messages in source
sink
,
IMessageHolder
the IMessageHolder source for all messages to handle
source
,
IMessage.Kind
the IMessage.Kind to select, if not null
kind
,
boolean
if true, also accept greater kinds
orGreater
,
boolean
if true, stop on first failure
fastFail
)

Handle messages in the second handler using the first

public static boolean

Returns:

false if any sink.handleMessage(..) failed
handleAll
(IMessageHandler
the IMessageHandler sink for all messages in source
sink
,
IMessage[]
the IMessage[] messages to handle
sources
,
boolean
if true, stop on first failure
fastFail
)

Handle messages in the sink.

public static boolean

Returns:

false if any sink.handleMessage(..) failed
handleAllExcept
(IMessageHandler
the IMessageHandler sink for all messages in source
sink
,
IMessageHolder
the IMessageHolder source for all messages to handle
source
,
IMessage.Kind
the IMessage.Kind to reject, if not null
kind
,
boolean
if true, also reject greater kinds
orGreater
,
boolean
if true, stop on first failure
fastFail
)

Handle messages in the second handler using the first if they are NOT of this kind (optionally, or greater).

public static PrintStream
handlerPrintStream(final IMessageHandler
the IMessageHandler sink for the messages generated
handler
,
final IMessage.Kind
the IMessage.Kind of message to create
kind
,
final OutputStream
the OuputStream for text not captured by the handler (if null, System.out used)
overage
,
final String prefix)

Factory for handler adapted to PrintStream XXX weak - only handles println(String)

public static boolean
info(IMessageHandler handler, String message)

create and handle info message (ignored if handler is null)

public static IMessage

Returns:

IMessage.INFO message with message content
info
(String message)

public static IMessageHandler

Returns:

IMessageHandler selector that works to param specs
makeSelector
(IMessage.Kind
the IMessage.Kind required of the message
kind
,
boolean
if true, also accept messages with greater kinds, as defined by IMessage.Kind.COMPARATOR
orGreater
,
String
the String text to require in the message - may be null or empty to accept any message with the specified kind.
infix
)

Make an IMessageHandler that handles IMessage if they have the right kind (or greater) and contain some infix String.

public static int

Returns:

int number of message of this kind (optionally or greater) in list
numMessages
(List<IMessage> messages, IMessage.Kind kind, boolean orGreater)

public static void
printMessageCounts(PrintStream out, IMessageHolder messageHolder)

Print total counts message to the print stream, starting each on a new line

public static void
public static String

Returns:

String of the form "{(# {type}) }.." for message kinds, skipping 0
renderCounts
(IMessageHolder holder)

public static String

Returns:

"((IMessage) null)" if null or String rendering otherwise, including everything (esp. throwable stack trace)
renderMessage
(IMessage message)

This renders IMessage as String, ignoring empty elements and eliding any thrown stack traces.

public static String

Returns:

"((IMessage) null)" if null or String rendering otherwise, including everything (esp. throwable stack trace)
renderMessage
(IMessage message, boolean elide)

This renders IMessage as String, ignoring empty elements and eliding any thrown.

public static String

Returns:

"((IMessage) null)" or message per spec
renderMessageLine
(IMessage message, int
relative proportion to spend on message and/or exception message, relative to source location - if 0, message is suppressed
textScale
,
int
relative proportion to spend on source location suppressed if 0
locScale
,
int
the number of characters - forced to 32..10000
max
)

Render message in a line.

public static String

Returns:

"((ISourceLocation) null)" if null or String rendering
{file:}line{:column}
renderSourceLocation
(ISourceLocation loc)

Render ISourceLocation to String, ignoring empty elements (null or ISourceLocation.NO_FILE or ISourceLocation.NO_COLUMN (though implementations may return 0 from getColumn() when passed NO_COLUMN as input)).

public static String
public static IMessage[]
visitMessages(IMessageHolder holder, IMessageHandler visitor, boolean accumulate, boolean abortOnFail)

Run visitor over the set of messages in holder, optionally accumulating those accepted by the visitor

public static IMessage[]
visitMessages(IMessage[] messages, IMessageHandler visitor, boolean accumulate, boolean abortOnFail)

Run visitor over the set of messages in holder, optionally accumulating those accepted by the visitor

public static IMessage[]

Returns:

IMessage.RA_IMessage if collection is empty, if not accumulate, or if visitor accepted no IMessage, or IMessage[] of accepted messages otherwise
visitMessages
(Collection<IMessage>
if null or empty, return IMessage.RA_IMessage
messages
,
IMessageHandler
run visitor.handleMessage(message) on each message - if null and messages not empty, IllegalArgumentException
visitor
,
final boolean
if true, then return accepted IMessage[]
accumulate
,
final boolean
if true and visitor returns false, stop visiting
abortOnFail
)

Run visitor over a collection of messages, optionally accumulating those accepted by the visitor

public static boolean
warn(IMessageHandler handler, String message)

create and handle warn message (ignored if handler is null)

public static IMessage

Returns:

WARNING_NOMESSAGE if message is empty or IMessage otherwise
warn
(String message, ISourceLocation location)

public static IMessage

Returns:

WARNING_NOMESSAGE if message is empty or IMessage otherwise
warn
(String message)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait