Package org.aspectj.bridge
Klasse MessageUtil
java.lang.Object
org.aspectj.bridge.MessageUtil
Convenience API's for constructing, printing, and sending messages.
-
Verschachtelte Klassen - Übersicht
Modifizierer und TypKlasseBeschreibungstatic interface
parameterize rendering behavior for messages -
Feldübersicht
Modifizierer und TypFeldBeschreibungstatic final IMessage
static final IMessage
static final IMessage
static final IMessage
static final IMessage
static final MessageUtil.IMessageRenderer
render message without restriction, up to 10K, including throwablestatic final MessageUtil.IMessageRenderer
render message as label, i.e., less than 33 charstatic final MessageUtil.IMessageRenderer
render message as label, i.e., less than 33 char, with no source locationstatic final MessageUtil.IMessageRenderer
render message as line, i.e., less than 75 char, no internal line sepstatic final MessageUtil.IMessageRenderer
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 locationstatic final MessageUtil.IMessageRenderer
render message without restriction, except any Throwable thrownstatic final MessageUtil.IMessageRenderer
render message more verbosely if it is worsestatic final MessageUtil.IMessageRenderer
render message using toShortString(IMessage)"static final MessageUtil.IMessageRenderer
render message using its toString() or "((IMessage) null)"static final MessageUtil.IMessageRenderer
render message as wide line, i.e., less than 256 char, no internal line sep, except any Throwable thrownstatic final IMessageHandler
static final IMessageHandler
static final IMessageHandler
static final IMessageHandler
static final IMessageHandler
static final IMessageHandler
static final IMessageHandler
static final IMessageHandler
static final IMessageHandler
static final IMessageHandler
static final IMessageHandler
static final IMessageHandler
static final IMessageHandler
static final IMessage
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic IMessage
static IMessage
static boolean
abort
(IMessageHandler handler, String message) handle abort message (ignored if handler is null)static boolean
abort
(IMessageHandler handler, String message, Throwable t) create and handle exception message (ignored if handler is null)static String
addExtraSourceLocations
(IMessage message, String baseMessage) static IMessage
static boolean
debug
(IMessageHandler handler, String message) create and handle debug message (ignored if handler is null)static IMessage
static IMessage
error
(String message, ISourceLocation location) static boolean
error
(IMessageHandler handler, String message) create and handle error message (ignored if handler is null)static IMessage
static IMessage
Create fail message.static boolean
fail
(IMessageHandler handler, String message) create and handle fail message (ignored if handler is null)static boolean
fail
(IMessageHandler handler, String message, Throwable thrown) create and handle fail message (ignored if handler is null)static IMessage.Kind
Map to the kind of messages associated with this string key.getMessages
(List<IMessage> messages, IMessage.Kind kind) Extract messages of type kind from the input list.getMessages
(IMessageHolder holder, IMessage.Kind kind, boolean orGreater, String infix) static IMessage[]
getMessagesExcept
(IMessageHolder holder, IMessage.Kind kind, boolean orGreater) Select all messages in holder except those of the same kind (optionally or greater).static boolean
handleAll
(IMessageHandler sink, IMessage[] sources, boolean fastFail) Handle messages in the sink.static boolean
handleAll
(IMessageHandler sink, IMessageHolder source, boolean fastFail) Handle all messages in the second handler using the firststatic boolean
handleAll
(IMessageHandler sink, IMessageHolder source, IMessage.Kind kind, boolean orGreater, boolean fastFail) Handle messages in the second handler using the firststatic boolean
handleAllExcept
(IMessageHandler sink, IMessageHolder source, IMessage.Kind kind, boolean orGreater, boolean fastFail) Handle messages in the second handler using the first if they are NOT of this kind (optionally, or greater).static PrintStream
handlerPrintStream
(IMessageHandler handler, IMessage.Kind kind, OutputStream overage, String prefix) Factory for handler adapted to PrintStream XXX weak - only handles println(String)static IMessage
static boolean
info
(IMessageHandler handler, String message) create and handle info message (ignored if handler is null)static IMessageHandler
makeSelector
(IMessage.Kind kind, boolean orGreater, String infix) Make an IMessageHandler that handles IMessage if they have the right kind (or greater) and contain some infix String.static int
numMessages
(List<IMessage> messages, IMessage.Kind kind, boolean orGreater) static void
print
(PrintStream out, IMessageHolder messageHolder) Print all message to the print stream, starting each on a new linestatic void
print
(PrintStream out, IMessageHolder holder, String prefix) Print all message to the print stream, starting each on a new line, with a prefix.static void
print
(PrintStream out, IMessageHolder holder, String prefix, MessageUtil.IMessageRenderer renderer) Print all message to the print stream, starting each on a new line, with a prefix and using a renderer.static void
print
(PrintStream out, IMessageHolder holder, String prefix, MessageUtil.IMessageRenderer renderer, IMessageHandler selector) Print all message to the print stream, starting each on a new line, with a prefix and using a renderer.static void
print
(PrintStream out, IMessageHolder holder, String prefix, MessageUtil.IMessageRenderer renderer, IMessageHandler selector, boolean printSummary) static void
printMessageCounts
(PrintStream out, IMessageHolder messageHolder) Print total counts message to the print stream, starting each on a new linestatic void
printMessageCounts
(PrintStream out, IMessageHolder holder, String prefix) static String
renderCounts
(IMessageHolder holder) static String
renderMessage
(IMessage message) This renders IMessage as String, ignoring empty elements and eliding any thrown stack traces.static String
renderMessage
(IMessage message, boolean elide) This renders IMessage as String, ignoring empty elements and eliding any thrown.static String
renderMessageLine
(IMessage message, int textScale, int locScale, int max) Render message in a line.static String
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)).static String
toShortString
(IMessage message) static IMessage[]
visitMessages
(Collection<IMessage> messages, IMessageHandler visitor, boolean accumulate, boolean abortOnFail) Run visitor over a collection of messages, optionally accumulating those accepted by the visitorstatic 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 visitorstatic 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 visitorstatic IMessage
static IMessage
warn
(String message, ISourceLocation location) static boolean
warn
(IMessageHandler handler, String message) create and handle warn message (ignored if handler is null)
-
Felddetails
-
ABORT_NOTHING_TO_RUN
-
FAIL_INCOMPLETE
-
ABORT_NOMESSAGE
-
FAIL_NOMESSAGE
-
ERROR_NOMESSAGE
-
WARNING_NOMESSAGE
-
PICK_ALL
-
PICK_ABORT
-
PICK_DEBUG
-
PICK_ERROR
-
PICK_FAIL
-
PICK_INFO
-
PICK_WARNING
-
PICK_ABORT_PLUS
-
PICK_DEBUG_PLUS
-
PICK_ERROR_PLUS
-
PICK_FAIL_PLUS
-
PICK_INFO_PLUS
-
PICK_WARNING_PLUS
-
MESSAGE_SCALED
render message more verbosely if it is worse -
MESSAGE_LABEL
render message as label, i.e., less than 33 char -
MESSAGE_LABEL_NOLOC
render message as label, i.e., less than 33 char, with no source location -
MESSAGE_LINE
render message as line, i.e., less than 75 char, no internal line sep -
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 -
MESSAGE_ALL
render message without restriction, up to 10K, including throwable -
MESSAGE_MOST
render message without restriction, except any Throwable thrown -
MESSAGE_WIDELINE
render message as wide line, i.e., less than 256 char, no internal line sep, except any Throwable thrown -
MESSAGE_TOSTRING
render message using its toString() or "((IMessage) null)" -
MESSAGE_SHORT
render message using toShortString(IMessage)"
-
-
Methodendetails
-
abort
handle abort message (ignored if handler is null) -
abort
create and handle exception message (ignored if handler is null) -
fail
create and handle fail message (ignored if handler is null) -
fail
create and handle fail message (ignored if handler is null) -
error
create and handle error message (ignored if handler is null) -
warn
create and handle warn message (ignored if handler is null) -
debug
create and handle debug message (ignored if handler is null) -
info
create and handle info message (ignored if handler is null) -
abort
- Gibt zurück:
- ABORT_NOMESSAGE if message is empty or IMessage otherwise
-
abort
- Gibt zurück:
- abort IMessage with thrown and message o ABORT_NOMESSAGE if both are empty/null
-
fail
- Gibt zurück:
- FAIL_NOMESSAGE if message is empty or IMessage otherwise
-
fail
Create fail message. If message is empty but thrown is not, use thrown.getMessage() as the message. If message is empty and thrown is null, return FAIL_NOMESSAGE.- Gibt zurück:
- FAIL_NOMESSAGE if thrown is null and message is empty or IMessage FAIL with message and thrown otherwise
-
error
- Gibt zurück:
- ERROR_NOMESSAGE if message is empty or IMessage otherwise
-
warn
- Gibt zurück:
- WARNING_NOMESSAGE if message is empty or IMessage otherwise
-
error
- Gibt zurück:
- ERROR_NOMESSAGE if message is empty or IMessage otherwise
-
warn
- Gibt zurück:
- WARNING_NOMESSAGE if message is empty or IMessage otherwise
-
debug
- Gibt zurück:
- IMessage.DEBUG message with message content
-
info
- Gibt zurück:
- IMessage.INFO message with message content
-
printMessageCounts
Print total counts message to the print stream, starting each on a new line- Parameter:
out
-messageHolder
-
-
printMessageCounts
-
print
Print all message to the print stream, starting each on a new line- Parameter:
out
-messageHolder
-- Siehe auch:
-
print
Print all message to the print stream, starting each on a new line, with a prefix.- Parameter:
out
-holder
-- Siehe auch:
-
print
public static void print(PrintStream out, IMessageHolder holder, String prefix, MessageUtil.IMessageRenderer renderer) Print all message to the print stream, starting each on a new line, with a prefix and using a renderer.- Parameter:
out
-holder
-renderer
- IMessageRender to render result - use MESSAGE_LINE if null- Siehe auch:
-
print
public static void print(PrintStream out, IMessageHolder holder, String prefix, MessageUtil.IMessageRenderer renderer, IMessageHandler selector) Print all message to the print stream, starting each on a new line, with a prefix and using a renderer. The first line renders a summary: {prefix}MessageHolder: {summary} Each message line has the following form:{prefix}[{kind} {index}]: {rendering}
(where "{index}" (length 3) is the position within the set of like-kinded messages, ignoring selector omissions. Renderers are free to render multi-line output.- Parameter:
out
- the PrintStream sink - return silently if nullholder
- the IMessageHolder with the messages to printprefix
- the prefix for each linerenderer
- IMessageRender to render result - use MESSAGE_ALL if nullselector
- IMessageHandler to select messages to render - if null, do all non-null
-
print
public static void print(PrintStream out, IMessageHolder holder, String prefix, MessageUtil.IMessageRenderer renderer, IMessageHandler selector, boolean printSummary) -
toShortString
-
numMessages
- Gibt zurück:
- int number of message of this kind (optionally or greater) in list
-
getMessagesExcept
public static IMessage[] getMessagesExcept(IMessageHolder holder, IMessage.Kind kind, boolean orGreater) Select all messages in holder except those of the same kind (optionally or greater). If kind is null, then all messages are rejected, so an empty list is returned.- Gibt zurück:
- unmodifiable list of specified IMessage
-
getMessages
public static List<IMessage> getMessages(IMessageHolder holder, IMessage.Kind kind, boolean orGreater, String infix) - Gibt zurück:
- unmodifiable list of IMessage complying with parameters
-
getMessages
Extract messages of type kind from the input list.- Parameter:
messages
- if null, return EMPTY_LISTkind
- if null, return messages- Siehe auch:
-
getKind
Map to the kind of messages associated with this string key.- Parameter:
kind
- the String representing the kind of message (IMessage.Kind.toString())- Gibt zurück:
- Kind the associated IMessage.Kind, or null if not found
-
visitMessages
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 -
visitMessages
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 -
visitMessages
public static IMessage[] visitMessages(Collection<IMessage> messages, IMessageHandler visitor, boolean accumulate, boolean abortOnFail) Run visitor over a collection of messages, optionally accumulating those accepted by the visitor- Parameter:
messages
- if null or empty, return IMessage.RA_IMessagevisitor
- run visitor.handleMessage(message) on each message - if null and messages not empty, IllegalArgumentExceptionaccumulate
- if true, then return accepted IMessage[]abortOnFail
- if true and visitor returns false, stop visiting- Gibt zurück:
- IMessage.RA_IMessage if collection is empty, if not accumulate, or if visitor accepted no IMessage, or IMessage[] of accepted messages otherwise
- Löst aus:
IllegalArgumentException
- if any in collection are not instanceof IMessage
-
makeSelector
Make an IMessageHandler that handles IMessage if they have the right kind (or greater) and contain some infix String.- Parameter:
kind
- the IMessage.Kind required of the messageorGreater
- if true, also accept messages with greater kinds, as defined by IMessage.Kind.COMPARATORinfix
- the String text to require in the message - may be null or empty to accept any message with the specified kind.- Gibt zurück:
- IMessageHandler selector that works to param specs
-
renderMessage
This renders IMessage as String, ignoring empty elements and eliding any thrown stack traces.- Gibt zurück:
- "((IMessage) null)" if null or String rendering otherwise, including everything (esp. throwable stack trace)
- Siehe auch:
-
renderMessage
This renders IMessage as String, ignoring empty elements and eliding any thrown.- Gibt zurück:
- "((IMessage) null)" if null or String rendering otherwise, including everything (esp. throwable stack trace)
- Siehe auch:
-
addExtraSourceLocations
-
renderSourceLocation
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)).- Gibt zurück:
- "((ISourceLocation) null)" if null or String rendering
{file:}line{:column}
-
renderMessageLine
Render message in a line. IMessage.Kind is always printed, then any unqualified exception class, then the remainder of text and location according to their relative scale, all to fit in max characters or less. This does not render thrown except for the unqualified class name- Parameter:
textScale
- relative proportion to spend on message and/or exception message, relative to source location - if 0, message is suppressedlocScale
- relative proportion to spend on source location suppressed if 0max
- the number of characters - forced to 32..10000- Gibt zurück:
- "((IMessage) null)" or message per spec
-
renderCounts
- Gibt zurück:
- String of the form "{(# {type}) }.." for message kinds, skipping 0
-
handlerPrintStream
public static PrintStream handlerPrintStream(IMessageHandler handler, IMessage.Kind kind, OutputStream overage, String prefix) Factory for handler adapted to PrintStream XXX weak - only handles println(String)- Parameter:
handler
- the IMessageHandler sink for the messages generatedkind
- the IMessage.Kind of message to createoverage
- the OuputStream for text not captured by the handler (if null, System.out used)- Löst aus:
IllegalArgumentException
- if kind or handler is null
-
handleAll
Handle all messages in the second handler using the first- Parameter:
sink
- the IMessageHandler sink for all messages in sourcesource
- the IMessageHolder source for all messages to handlefastFail
- if true, stop on first failure- Gibt zurück:
- false if any sink.handleMessage(..) failed
-
handleAll
public static boolean handleAll(IMessageHandler sink, IMessageHolder source, IMessage.Kind kind, boolean orGreater, boolean fastFail) Handle messages in the second handler using the first- Parameter:
sink
- the IMessageHandler sink for all messages in sourcesource
- the IMessageHolder source for all messages to handlekind
- the IMessage.Kind to select, if not nullorGreater
- if true, also accept greater kindsfastFail
- if true, stop on first failure- Gibt zurück:
- false if any sink.handleMessage(..) failed
-
handleAllExcept
public static boolean handleAllExcept(IMessageHandler sink, IMessageHolder source, IMessage.Kind kind, boolean orGreater, boolean fastFail) Handle messages in the second handler using the first if they are NOT of this kind (optionally, or greater). If you pass null as the kind, then all messages are ignored and this returns true.- Parameter:
sink
- the IMessageHandler sink for all messages in sourcesource
- the IMessageHolder source for all messages to handlekind
- the IMessage.Kind to reject, if not nullorGreater
- if true, also reject greater kindsfastFail
- if true, stop on first failure- Gibt zurück:
- false if any sink.handleMessage(..) failed
-
handleAll
Handle messages in the sink.- Parameter:
sink
- the IMessageHandler sink for all messages in sourcesources
- the IMessage[] messages to handlefastFail
- if true, stop on first failure- Gibt zurück:
- false if any sink.handleMessage(..) failed
- Löst aus:
IllegalArgumentException
- if sink is null
-