diff options
author | wisberg <wisberg> | 2004-03-31 00:39:21 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2004-03-31 00:39:21 +0000 |
commit | 60b3a70a85f5b0c1dd504fbe4410d52664f63eed (patch) | |
tree | ee1a41915ded2168e5914a9fcfc766375fcfcb36 /testing | |
parent | c2bcc9d1c7f47299055bf68c4f1ae32f5aa9553a (diff) | |
download | aspectj-60b3a70a85f5b0c1dd504fbe4410d52664f63eed.tar.gz aspectj-60b3a70a85f5b0c1dd504fbe4410d52664f63eed.zip |
recursive message checks of run status with children
Diffstat (limited to 'testing')
-rw-r--r-- | testing/src/org/aspectj/testing/run/IRunStatus.java | 20 | ||||
-rw-r--r-- | testing/src/org/aspectj/testing/run/RunStatus.java | 38 |
2 files changed, 58 insertions, 0 deletions
diff --git a/testing/src/org/aspectj/testing/run/IRunStatus.java b/testing/src/org/aspectj/testing/run/IRunStatus.java index 6651c42f1..1757fedbc 100644 --- a/testing/src/org/aspectj/testing/run/IRunStatus.java +++ b/testing/src/org/aspectj/testing/run/IRunStatus.java @@ -105,6 +105,26 @@ public interface IRunStatus extends IMessageHolder { */ void completeAbruptly(); //------------------- process messages + /** + * Detect whether a message of a given kind has been handled. + * @param kind the IMessage.Kind of the message to detect + * @param orGreater if true, then also accept any message of a greater kind + * @param includeChildren if true, then also search in any child IRunStatus + * @return true if any such message is detected + */ + boolean hasAnyMessage(IMessage.Kind kind, boolean orGreater, boolean includeChildren); + + /** + * Get all messages or those of a specific kind, optionally in children as well + * Pass null to get all kinds. + * @param kind the IMessage.Kind expected, or null for all messages + * @param orGreater if true, also get any greater than the target kind + * as determined by IMessage.Kind.COMPARATOR + * @param includeChildren if true, then also search in any child IRunStatus + * @return IMessage[] of messages of the right kind, or IMessage.NONE + */ + IMessage[] getMessages(IMessage.Kind kind, boolean orGreater, boolean includeChildren); + /** * Call this any time to signal any messages. * (In particular, the IRun caller may use this to register messages diff --git a/testing/src/org/aspectj/testing/run/RunStatus.java b/testing/src/org/aspectj/testing/run/RunStatus.java index be971f6b9..1f2af56ab 100644 --- a/testing/src/org/aspectj/testing/run/RunStatus.java +++ b/testing/src/org/aspectj/testing/run/RunStatus.java @@ -15,13 +15,16 @@ package org.aspectj.testing.run; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.List; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.IMessageHolder; import org.aspectj.bridge.MessageHandler; +import org.aspectj.bridge.IMessage.Kind; import org.aspectj.testing.util.BridgeUtil; +import org.aspectj.util.LangUtil; /** * Default implementation of {@link IRunStatus}. @@ -227,6 +230,41 @@ public class RunStatus implements IRunStatus { public boolean runResult() { return validator.runPassed(this); } + + public boolean hasAnyMessage(IMessage.Kind kind, boolean orGreater, boolean includeChildren) { + if (messageHolder.hasAnyMessage(kind, orGreater)) { + return true; + } + if (includeChildren) { + IRunStatus[] kids = getChildren(); + for (int i = 0; i < kids.length; i++) { + if (kids[i].hasAnyMessage(kind, orGreater, true)) { + return true; + } + } + } + return false; + } + + public IMessage[] getMessages(IMessage.Kind kind, boolean orGreater, boolean includeChildren) { + IMessage[] result = getMessages(kind, orGreater); + if (!includeChildren) { + return result; + } + ArrayList sink = new ArrayList(); + if (!LangUtil.isEmpty(result)) { + sink.addAll(Arrays.asList(result)); + } + + IRunStatus[] kids = getChildren(); + for (int i = 0; i < kids.length; i++) { + result = kids[i].getMessages(kind, orGreater, includeChildren); + if (!LangUtil.isEmpty(result)) { + sink.addAll(Arrays.asList(result)); + } + } + return (IMessage[]) sink.toArray(new IMessage[0]); + } //------------------- process messages /** |