From 98976598593e8a1f89e9628e8fc11c7822b8e3d4 Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 4 Jan 2005 13:15:57 +0000 Subject: Fix for Bug 82062: WeaveMessage should provide more information (Bug and fix from Martin Lippert) --- bridge/src/org/aspectj/bridge/WeaveMessage.java | 44 +++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'bridge/src') diff --git a/bridge/src/org/aspectj/bridge/WeaveMessage.java b/bridge/src/org/aspectj/bridge/WeaveMessage.java index 3f2e72297..3dfd82fca 100644 --- a/bridge/src/org/aspectj/bridge/WeaveMessage.java +++ b/bridge/src/org/aspectj/bridge/WeaveMessage.java @@ -33,11 +33,35 @@ public class WeaveMessage extends Message { new WeaveMessageKind(5,"Softening exceptions in type '%1' (%2) as defined by aspect '%3' (%4)"); + private String affectedtypename; + private String aspectname; + + // private ctor - use the static factory method - private WeaveMessage(String message) { + private WeaveMessage(String message, String affectedtypename, String aspectname) { super(message, IMessage.WEAVEINFO, null, null); + this.affectedtypename = affectedtypename; + this.aspectname = aspectname; } + /** + * Static helper method for constructing weaving messages. + * @param kind what kind of message (e.g. declare parents) + * @param inserts inserts for the message (inserts are marked %n in the message) + * @return new weaving message + */ + public static WeaveMessage constructWeavingMessage( + WeaveMessageKind kind, + String[] inserts) { + StringBuffer str = new StringBuffer(kind.getMessage()); + int pos = -1; + while ((pos=new String(str).indexOf("%"))!=-1) { + int n = Character.getNumericValue(str.charAt(pos+1)); + str.replace(pos,pos+2,inserts[n-1]); + } + return new WeaveMessage(str.toString(), null, null); + } + /** * Static helper method for constructing weaving messages. * @param kind what kind of message (e.g. declare parents) @@ -48,17 +72,31 @@ public class WeaveMessage extends Message { */ public static WeaveMessage constructWeavingMessage( WeaveMessageKind kind, - String[] inserts) { + String[] inserts, + String affectedtypename, + String aspectname) { StringBuffer str = new StringBuffer(kind.getMessage()); int pos = -1; while ((pos=new String(str).indexOf("%"))!=-1) { int n = Character.getNumericValue(str.charAt(pos+1)); str.replace(pos,pos+2,inserts[n-1]); } - return new WeaveMessage(str.toString()); + return new WeaveMessage(str.toString(), affectedtypename, aspectname); } + /** + * @return Returns the aspectname. + */ + public String getAspectname() { + return aspectname; + } + /** + * @return Returns the affectedtypename. + */ + public String getAffectedtypename() { + return affectedtypename; + } public static class WeaveMessageKind { -- cgit v1.2.3