~ubuntu-branches/ubuntu/wily/aspectj/wily-proposed

« back to all changes in this revision

Viewing changes to org.aspectj/modules/bridge/src/org/aspectj/bridge/Message.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2011-03-15 23:54:31 UTC
  • mfrom: (1.2.5 upstream)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20110315235431-iq2gxbsx08kpwuiw
* New upstream release.
* Updated Standards-Version to 3.9.1 (no changes needed).
* Fix local Javadoc links:
  - d/patches/07_javadoc_links.diff: Use locally installed
   javadoc packages and hyperlink with them.
  - d/control: Add B-D on default-java-doc and libasm3-java-doc.
* d/control: Drop B-D on itself (our new bootstrap infrastructure doesn't need
  that anymore).
* Split packages into :
  - aspectj: only contains CLI tools.
  - libaspectj-java: JAR librairies for /usr/share/java.
  - libaspectj-java-doc: 4 API's Javadoc.
  - aspectj-doc: Programming Guides and SDK Documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 *     Xerox/PARC     initial implementation 
12
12
 * ******************************************************************/
13
13
 
14
 
 
15
14
package org.aspectj.bridge;
16
15
 
17
16
import java.util.Arrays;
18
17
import java.util.Collections;
19
18
import java.util.List;
20
19
 
21
 
 
22
20
/**
23
 
 * Implement messages.
24
 
 * This implementation is immutable if ISourceLocation is immutable.
 
21
 * Implement messages. This implementation is immutable if ISourceLocation is immutable.
25
22
 */
26
23
public class Message implements IMessage {
27
 
    private final String message;
28
 
    private final IMessage.Kind kind;
29
 
    private final Throwable thrown;
30
 
    private final ISourceLocation sourceLocation;
31
 
    private final String details;
32
 
    private final List/*SourceLocation*/ extraSourceLocations;
33
 
    private final boolean declared; // Is it a DEOW ?
34
 
    private final int id; 
35
 
    private final int sourceStart,sourceEnd;
36
 
        
37
 
    /**
38
 
     * Create a (compiler) error or warning message
39
 
     * @param message the String used as the underlying message
40
 
     * @param location the ISourceLocation, if any, associated with this message
41
 
     * @param isError if true, use IMessage.ERROR; else use IMessage.WARNING
42
 
     */
43
 
    public Message(String message, ISourceLocation location, boolean isError) {
44
 
        this(message, (isError ? IMessage.ERROR : IMessage.WARNING), null,
45
 
            location);
46
 
    }
47
 
 
48
 
    public Message(String message, ISourceLocation location, boolean isError, ISourceLocation[] extraSourceLocations) {
49
 
        this(message, "",(isError ? IMessage.ERROR : IMessage.WARNING), location, null, 
50
 
                        (extraSourceLocations.length > 0 ? extraSourceLocations : null));
51
 
    }
52
 
        
53
 
        /**
54
 
         * Create a message, handling null values for message and kind
55
 
         * if thrown is not null.
 
24
        private final String message;
 
25
        private final IMessage.Kind kind;
 
26
        private final Throwable thrown;
 
27
        private final ISourceLocation sourceLocation;
 
28
        private final String details;
 
29
        private final List<ISourceLocation> extraSourceLocations;
 
30
        private final boolean declared; // Is it a DEOW ?
 
31
        private final int id;
 
32
        private final int sourceStart, sourceEnd;
 
33
 
 
34
        /**
 
35
         * Create a (compiler) error or warning message
 
36
         * 
 
37
         * @param message the String used as the underlying message
 
38
         * @param location the ISourceLocation, if any, associated with this message
 
39
         * @param isError if true, use IMessage.ERROR; else use IMessage.WARNING
 
40
         */
 
41
        public Message(String message, ISourceLocation location, boolean isError) {
 
42
                this(message, (isError ? IMessage.ERROR : IMessage.WARNING), null, location);
 
43
        }
 
44
 
 
45
        public Message(String message, ISourceLocation location, boolean isError, ISourceLocation[] extraSourceLocations) {
 
46
                this(message, "", (isError ? IMessage.ERROR : IMessage.WARNING), location, null,
 
47
                                (extraSourceLocations.length > 0 ? extraSourceLocations : null));
 
48
        }
 
49
 
 
50
        /**
 
51
         * Create a message, handling null values for message and kind if thrown is not null.
 
52
         * 
56
53
         * @param message the String used as the underlying message
57
54
         * @param kind the IMessage.Kind of message - not null
58
55
         * @param thrown the Throwable, if any, associated with this message
59
56
         * @param sourceLocation the ISourceLocation, if any, associated with this message
60
57
         * @param details descriptive information about the message
61
 
         * @throws IllegalArgumentException if message is null and
62
 
         * thrown is null or has a null message, or if kind is null
63
 
         * and thrown is null.
 
58
         * @throws IllegalArgumentException if message is null and thrown is null or has a null message, or if kind is null and thrown
 
59
         *         is null.
64
60
         */
65
 
        public Message(String message, String details, IMessage.Kind kind, 
66
 
                ISourceLocation sourceLocation, Throwable thrown, ISourceLocation[] extraSourceLocations) {
67
 
                this(message,details,kind,sourceLocation,thrown,extraSourceLocations,false,0,-1,-1);
 
61
        public Message(String message, String details, IMessage.Kind kind, ISourceLocation sourceLocation, Throwable thrown,
 
62
                        ISourceLocation[] extraSourceLocations) {
 
63
                this(message, details, kind, sourceLocation, thrown, extraSourceLocations, false, 0, -1, -1);
68
64
        }
69
 
        
70
 
        public Message(String message, String details, IMessage.Kind kind,
71
 
                       ISourceLocation sLoc, Throwable thrown, ISourceLocation[] otherLocs,
72
 
                       boolean declared,int id,int sourcestart,int sourceend) {
 
65
 
 
66
        public Message(String message, String details, IMessage.Kind kind, ISourceLocation sLoc, Throwable thrown,
 
67
                        ISourceLocation[] otherLocs, boolean declared, int id, int sourcestart, int sourceend) {
73
68
                this.details = details;
74
69
                this.id = id;
75
70
                this.sourceStart = sourcestart;
76
71
                this.sourceEnd = sourceend;
77
 
                this.message = ((message!=null) ? message : ((thrown==null) ? null : thrown.getMessage()));
 
72
                this.message = ((message != null) ? message : ((thrown == null) ? null : thrown.getMessage()));
78
73
                this.kind = kind;
79
74
                this.sourceLocation = sLoc;
80
75
                this.thrown = thrown;
81
 
        if (otherLocs != null) {
82
 
                        this.extraSourceLocations 
83
 
                        = Collections.unmodifiableList(Arrays.asList(otherLocs));
84
 
                }
85
 
                else {
86
 
                        this.extraSourceLocations = Collections.EMPTY_LIST;
 
76
                if (otherLocs != null) {
 
77
                        this.extraSourceLocations = Collections.unmodifiableList(Arrays.asList(otherLocs));
 
78
                } else {
 
79
                        this.extraSourceLocations = Collections.emptyList();
87
80
                }
88
81
                if (null == this.kind) {
89
 
                         throw new IllegalArgumentException("null kind");
 
82
                        throw new IllegalArgumentException("null kind");
90
83
                }
91
84
                if (null == this.message) {
92
85
                        throw new IllegalArgumentException("null message");
93
 
                }               
 
86
                }
94
87
                this.declared = declared;
95
88
        }
96
 
    
97
 
    /**
98
 
     * Create a message, handling null values for message and kind
99
 
     * if thrown is not null.
100
 
     * @param message the String used as the underlying message
101
 
     * @param kind the IMessage.Kind of message - not null
102
 
     * @param thrown the Throwable, if any, associated with this message
103
 
     * @param sourceLocation the ISourceLocation, if any, associated with this message
104
 
     * @throws IllegalArgumentException if message is null and
105
 
     * thrown is null or has a null message, or if kind is null
106
 
     * and thrown is null.
107
 
     */
108
 
    public Message(String message, IMessage.Kind kind, Throwable thrown,
109
 
                    ISourceLocation sourceLocation) {
110
 
          this(message, "", kind, sourceLocation, thrown, null );              
111
 
    }
112
 
    
113
 
    /** @return the kind of this message */
114
 
    public IMessage.Kind getKind() {
115
 
        return kind;
116
 
    }
117
 
 
118
 
    /** @return true if kind == IMessage.ERROR */
119
 
    public boolean isError() {
120
 
        return kind == IMessage.ERROR;
121
 
    }
122
 
    
123
 
    /** @return true if kind == IMessage.WARNING */
124
 
    public boolean isWarning() {
125
 
        return kind == IMessage.WARNING;
126
 
    }
127
 
 
128
 
    /** @return true if kind == IMessage.DEBUG */
129
 
    public boolean isDebug() {
130
 
        return kind == IMessage.DEBUG;
131
 
    }
132
 
        
 
89
 
 
90
        /**
 
91
         * Create a message, handling null values for message and kind if thrown is not null.
 
92
         * 
 
93
         * @param message the String used as the underlying message
 
94
         * @param kind the IMessage.Kind of message - not null
 
95
         * @param thrown the Throwable, if any, associated with this message
 
96
         * @param sourceLocation the ISourceLocation, if any, associated with this message
 
97
         * @throws IllegalArgumentException if message is null and thrown is null or has a null message, or if kind is null and thrown
 
98
         *         is null.
 
99
         */
 
100
        public Message(String message, IMessage.Kind kind, Throwable thrown, ISourceLocation sourceLocation) {
 
101
                this(message, "", kind, sourceLocation, thrown, null);
 
102
        }
 
103
 
 
104
        /** @return the kind of this message */
 
105
        public IMessage.Kind getKind() {
 
106
                return kind;
 
107
        }
 
108
 
 
109
        /** @return true if kind == IMessage.ERROR */
 
110
        public boolean isError() {
 
111
                return kind == IMessage.ERROR;
 
112
        }
 
113
 
 
114
        /** @return true if kind == IMessage.WARNING */
 
115
        public boolean isWarning() {
 
116
                return kind == IMessage.WARNING;
 
117
        }
 
118
 
 
119
        /** @return true if kind == IMessage.DEBUG */
 
120
        public boolean isDebug() {
 
121
                return kind == IMessage.DEBUG;
 
122
        }
 
123
 
133
124
        public boolean isTaskTag() {
134
125
                return kind == IMessage.TASKTAG;
135
126
        }
136
127
 
137
 
    /** 
138
 
     * @return true if kind == IMessage.INFO  
139
 
     */
140
 
    public boolean isInfo() {
141
 
        return kind == IMessage.INFO;
142
 
    }
143
 
    
144
 
    /** @return true if  kind == IMessage.ABORT  */
145
 
    public boolean isAbort() {
146
 
        return kind == IMessage.ABORT;
147
 
    }    
148
 
    
149
 
    /** Caller can verify if this message came about because of a DEOW */
150
 
    public boolean getDeclared() {
151
 
        return declared;
152
 
    }
153
 
    
154
 
    /** 
155
 
     * @return true if kind == IMessage.FAIL
156
 
     */
157
 
    public boolean isFailed() {
158
 
        return kind == IMessage.FAIL;
159
 
    }
160
 
    
161
 
    /** @return non-null String with simple message */
162
 
    final public String getMessage() {
163
 
        return message;
164
 
    }
165
 
    
166
 
    /** @return Throwable associated with this message, or null if none */
167
 
    final public Throwable getThrown() {
168
 
        return thrown;
169
 
    }
170
 
 
171
 
    /** @return ISourceLocation associated with this message, or null if none */
172
 
    final public ISourceLocation getSourceLocation() {
173
 
        return sourceLocation;
174
 
    }
175
 
    
176
 
    public String toString() {
177
 
        return MessageUtil.renderMessage(this,false);
178
 
    }
 
128
        /**
 
129
         * @return true if kind == IMessage.INFO
 
130
         */
 
131
        public boolean isInfo() {
 
132
                return kind == IMessage.INFO;
 
133
        }
 
134
 
 
135
        /** @return true if kind == IMessage.ABORT */
 
136
        public boolean isAbort() {
 
137
                return kind == IMessage.ABORT;
 
138
        }
 
139
 
 
140
        /** Caller can verify if this message came about because of a DEOW */
 
141
        public boolean getDeclared() {
 
142
                return declared;
 
143
        }
 
144
 
 
145
        /**
 
146
         * @return true if kind == IMessage.FAIL
 
147
         */
 
148
        public boolean isFailed() {
 
149
                return kind == IMessage.FAIL;
 
150
        }
 
151
 
 
152
        /** @return non-null String with simple message */
 
153
        final public String getMessage() {
 
154
                return message;
 
155
        }
 
156
 
 
157
        /** @return Throwable associated with this message, or null if none */
 
158
        final public Throwable getThrown() {
 
159
                return thrown;
 
160
        }
 
161
 
 
162
        /** @return ISourceLocation associated with this message, or null if none */
 
163
        final public ISourceLocation getSourceLocation() {
 
164
                return sourceLocation;
 
165
        }
 
166
 
 
167
        public String toString() {
 
168
                return MessageUtil.renderMessage(this, false);
 
169
        }
179
170
 
180
171
        public String getDetails() {
181
172
                return details;
182
173
        }
183
 
    
184
 
        public List getExtraSourceLocations() {
 
174
 
 
175
        public List<ISourceLocation> getExtraSourceLocations() {
185
176
                return extraSourceLocations;
186
177
        }
187
178
 
192
183
        public int getSourceStart() {
193
184
                return sourceStart;
194
185
        }
195
 
        
 
186
 
196
187
        public int getSourceEnd() {
197
188
                return sourceEnd;
198
189
        }