%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
nl.toolforge.karma.core.cmd.event.AbstractMessage |
|
|
1 | /* |
|
2 | Karma core - Core of the Karma application |
|
3 | Copyright (C) 2004 Toolforge <www.toolforge.nl> |
|
4 | ||
5 | This library is free software; you can redistribute it and/or |
|
6 | modify it under the terms of the GNU Lesser General Public |
|
7 | License as published by the Free Software Foundation; either |
|
8 | version 2.1 of the License, or (at your option) any later version. |
|
9 | ||
10 | This library is distributed in the hope that it will be useful, |
|
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 | Lesser General Public License for more details. |
|
14 | ||
15 | You should have received a copy of the GNU Lesser General Public |
|
16 | License along with this library; if not, write to the Free Software |
|
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | */ |
|
19 | package nl.toolforge.karma.core.cmd.event; |
|
20 | ||
21 | import java.text.MessageFormat; |
|
22 | ||
23 | /** |
|
24 | * Base implementation of a {@link Message}. Provides standard implementations for methods handling messages. |
|
25 | * |
|
26 | * @author D.A. Smedes |
|
27 | * @version $Id: AbstractMessage.java,v 1.2 2004/11/02 23:57:06 asmedes Exp $ |
|
28 | */ |
|
29 | public class AbstractMessage implements Message { |
|
30 | ||
31 | 0 | private String message = null; |
32 | ||
33 | 0 | public AbstractMessage(String message) { |
34 | 0 | this.message = message; |
35 | 0 | } |
36 | ||
37 | /** |
|
38 | * Constructs a message. {@link java.text.MessageFormat} is used to convert parameters in the <code>message</code> |
|
39 | * text. |
|
40 | * |
|
41 | * @param message The message string (with optional parameters). |
|
42 | * @param messageParameters An object array with parameter values. |
|
43 | */ |
|
44 | 0 | public AbstractMessage(String message, Object[] messageParameters) { |
45 | ||
46 | 0 | if (messageParameters != null && messageParameters.length != 0) { |
47 | 0 | MessageFormat messageFormat = new MessageFormat(message); |
48 | 0 | this.message = messageFormat.format(messageParameters); |
49 | } else { |
|
50 | 0 | this.message = message; |
51 | } |
|
52 | 0 | } |
53 | ||
54 | /** |
|
55 | * Returns the message as a String, having replaced all parameters with the actual content. |
|
56 | * |
|
57 | * @return The message text. |
|
58 | */ |
|
59 | public String getMessageText() { |
|
60 | 0 | return message; |
61 | } |
|
62 | ||
63 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |