Klasse MessageUtil

java.lang.Object
org.aspectj.bridge.MessageUtil

public class MessageUtil extends Object
Convenience API's for constructing, printing, and sending messages.
  • Felddetails

    • ABORT_NOTHING_TO_RUN

      public static final IMessage ABORT_NOTHING_TO_RUN
    • FAIL_INCOMPLETE

      public static final IMessage FAIL_INCOMPLETE
    • ABORT_NOMESSAGE

      public static final IMessage ABORT_NOMESSAGE
    • FAIL_NOMESSAGE

      public static final IMessage FAIL_NOMESSAGE
    • ERROR_NOMESSAGE

      public static final IMessage ERROR_NOMESSAGE
    • WARNING_NOMESSAGE

      public static final IMessage WARNING_NOMESSAGE
    • PICK_ALL

      public static final IMessageHandler PICK_ALL
    • PICK_ABORT

      public static final IMessageHandler PICK_ABORT
    • PICK_DEBUG

      public static final IMessageHandler PICK_DEBUG
    • PICK_ERROR

      public static final IMessageHandler PICK_ERROR
    • PICK_FAIL

      public static final IMessageHandler PICK_FAIL
    • PICK_INFO

      public static final IMessageHandler PICK_INFO
    • PICK_WARNING

      public static final IMessageHandler PICK_WARNING
    • PICK_ABORT_PLUS

      public static final IMessageHandler PICK_ABORT_PLUS
    • PICK_DEBUG_PLUS

      public static final IMessageHandler PICK_DEBUG_PLUS
    • PICK_ERROR_PLUS

      public static final IMessageHandler PICK_ERROR_PLUS
    • PICK_FAIL_PLUS

      public static final IMessageHandler PICK_FAIL_PLUS
    • PICK_INFO_PLUS

      public static final IMessageHandler PICK_INFO_PLUS
    • PICK_WARNING_PLUS

      public static final IMessageHandler PICK_WARNING_PLUS
    • MESSAGE_SCALED

      public static final MessageUtil.IMessageRenderer MESSAGE_SCALED
      render message more verbosely if it is worse
    • MESSAGE_LABEL

      public static final MessageUtil.IMessageRenderer MESSAGE_LABEL
      render message as label, i.e., less than 33 char
    • MESSAGE_LABEL_NOLOC

      public static final MessageUtil.IMessageRenderer MESSAGE_LABEL_NOLOC
      render message as label, i.e., less than 33 char, with no source location
    • MESSAGE_LINE

      public static final MessageUtil.IMessageRenderer MESSAGE_LINE
      render message as line, i.e., less than 75 char, no internal line sep
    • MESSAGE_LINE_FORCE_LOC

      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
    • MESSAGE_ALL

      public static final MessageUtil.IMessageRenderer MESSAGE_ALL
      render message without restriction, up to 10K, including throwable
    • MESSAGE_MOST

      public static final MessageUtil.IMessageRenderer MESSAGE_MOST
      render message without restriction, except any Throwable thrown
    • MESSAGE_WIDELINE

      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
    • MESSAGE_TOSTRING

      public static final MessageUtil.IMessageRenderer MESSAGE_TOSTRING
      render message using its toString() or "((IMessage) null)"
    • MESSAGE_SHORT

      public static final MessageUtil.IMessageRenderer MESSAGE_SHORT
      render message using toShortString(IMessage)"
  • Methodendetails

    • abort

      public static boolean abort(IMessageHandler handler, String message)
      handle abort message (ignored if handler is null)
    • abort

      public static boolean abort(IMessageHandler handler, String message, Throwable t)
      create and handle exception message (ignored if handler is null)
    • fail

      public static boolean fail(IMessageHandler handler, String message)
      create and handle fail message (ignored if handler is null)
    • fail

      public static boolean fail(IMessageHandler handler, String message, Throwable thrown)
      create and handle fail message (ignored if handler is null)
    • error

      public static boolean error(IMessageHandler handler, String message)
      create and handle error message (ignored if handler is null)
    • warn

      public static boolean warn(IMessageHandler handler, String message)
      create and handle warn message (ignored if handler is null)
    • debug

      public static boolean debug(IMessageHandler handler, String message)
      create and handle debug message (ignored if handler is null)
    • info

      public static boolean info(IMessageHandler handler, String message)
      create and handle info message (ignored if handler is null)
    • abort

      public static IMessage abort(String message)
      Gibt zurück:
      ABORT_NOMESSAGE if message is empty or IMessage otherwise
    • abort

      public static IMessage abort(String message, Throwable thrown)
      Gibt zurück:
      abort IMessage with thrown and message o ABORT_NOMESSAGE if both are empty/null
    • fail

      public static IMessage fail(String message)
      Gibt zurück:
      FAIL_NOMESSAGE if message is empty or IMessage otherwise
    • fail

      public static IMessage fail(String message, Throwable thrown)
      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

      public static IMessage error(String message, ISourceLocation location)
      Gibt zurück:
      ERROR_NOMESSAGE if message is empty or IMessage otherwise
    • warn

      public static IMessage warn(String message, ISourceLocation location)
      Gibt zurück:
      WARNING_NOMESSAGE if message is empty or IMessage otherwise
    • error

      public static IMessage error(String message)
      Gibt zurück:
      ERROR_NOMESSAGE if message is empty or IMessage otherwise
    • warn

      public static IMessage warn(String message)
      Gibt zurück:
      WARNING_NOMESSAGE if message is empty or IMessage otherwise
    • debug

      public static IMessage debug(String message)
      Gibt zurück:
      IMessage.DEBUG message with message content
    • info

      public static IMessage info(String message)
      Gibt zurück:
      IMessage.INFO message with message content
    • printMessageCounts

      public static void printMessageCounts(PrintStream out, IMessageHolder messageHolder)
      Print total counts message to the print stream, starting each on a new line
      Parameter:
      out -
      messageHolder -
    • printMessageCounts

      public static void printMessageCounts(PrintStream out, IMessageHolder holder, String prefix)
    • print

      public static void print(PrintStream out, IMessageHolder messageHolder)
      Print all message to the print stream, starting each on a new line
      Parameter:
      out -
      messageHolder -
      Siehe auch:
    • print

      public static void print(PrintStream out, IMessageHolder holder, String prefix)
      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 null
      holder - the IMessageHolder with the messages to print
      prefix - the prefix for each line
      renderer - IMessageRender to render result - use MESSAGE_ALL if null
      selector - 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

      public static String toShortString(IMessage message)
    • numMessages

      public static int numMessages(List<IMessage> messages, IMessage.Kind kind, boolean orGreater)
      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

      public static List<IMessage> getMessages(List<IMessage> messages, IMessage.Kind kind)
      Extract messages of type kind from the input list.
      Parameter:
      messages - if null, return EMPTY_LIST
      kind - if null, return messages
      Siehe auch:
    • getKind

      public static IMessage.Kind getKind(String kind)
      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_IMessage
      visitor - run visitor.handleMessage(message) on each message - if null and messages not empty, IllegalArgumentException
      accumulate - 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

      public 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.
      Parameter:
      kind - the IMessage.Kind required of the message
      orGreater - if true, also accept messages with greater kinds, as defined by IMessage.Kind.COMPARATOR
      infix - 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

      public static String renderMessage(IMessage message)
      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

      public static String renderMessage(IMessage message, boolean elide)
      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

      public static String addExtraSourceLocations(IMessage message, String baseMessage)
    • renderSourceLocation

      public static String 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)).
      Gibt zurück:
      "((ISourceLocation) null)" if null or String rendering
       {file:}line{:column}
       
    • renderMessageLine

      public static String renderMessageLine(IMessage message, int textScale, int locScale, int max)
      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 suppressed
      locScale - relative proportion to spend on source location suppressed if 0
      max - the number of characters - forced to 32..10000
      Gibt zurück:
      "((IMessage) null)" or message per spec
    • renderCounts

      public static String renderCounts(IMessageHolder holder)
      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 generated
      kind - the IMessage.Kind of message to create
      overage - 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

      public static boolean handleAll(IMessageHandler sink, IMessageHolder source, boolean fastFail)
      Handle all messages in the second handler using the first
      Parameter:
      sink - the IMessageHandler sink for all messages in source
      source - the IMessageHolder source for all messages to handle
      fastFail - 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 source
      source - the IMessageHolder source for all messages to handle
      kind - the IMessage.Kind to select, if not null
      orGreater - if true, also accept greater kinds
      fastFail - 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 source
      source - the IMessageHolder source for all messages to handle
      kind - the IMessage.Kind to reject, if not null
      orGreater - if true, also reject greater kinds
      fastFail - if true, stop on first failure
      Gibt zurück:
      false if any sink.handleMessage(..) failed
    • handleAll

      public static boolean handleAll(IMessageHandler sink, IMessage[] sources, boolean fastFail)
      Handle messages in the sink.
      Parameter:
      sink - the IMessageHandler sink for all messages in source
      sources - the IMessage[] messages to handle
      fastFail - if true, stop on first failure
      Gibt zurück:
      false if any sink.handleMessage(..) failed
      Löst aus:
      IllegalArgumentException - if sink is null