/** Dumps messages to the given output stream, returning the highest message level seen. */ static MessageLevel dumpMessages(MessageQueue mq, MessageContext mc, Appendable out) { MessageLevel maxLevel = MessageLevel.values()[0]; for (Message m : mq.getMessages()) { MessageLevel level = m.getMessageLevel(); if (maxLevel.compareTo(level) < 0) { maxLevel = level; } } MessageLevel ignoreLevel = null; if (maxLevel.compareTo(MessageLevel.LINT) < 0) { // If there's only checkpoints, be quiet. ignoreLevel = MessageLevel.LOG; } try { for (Message m : mq.getMessages()) { MessageLevel level = m.getMessageLevel(); if (ignoreLevel != null && level.compareTo(ignoreLevel) <= 0) { continue; } out.append(level.name() + ": "); m.format(mc, out); out.append("\n"); if (maxLevel.compareTo(level) < 0) { maxLevel = level; } } } catch (IOException ex) { ex.printStackTrace(); } return maxLevel; }
public boolean hasNoMessagesOfLevel(MessageLevel level) { for (Message m : getMessageQueue().getMessages()) { if (level.compareTo(m.getMessageLevel()) <= 0) { return false; } } return true; }