KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jpublish > util > MessageUtilities


1 /*--
2  Copyright (C) 2001-2003 Aetrion LLC.
3  All rights reserved.
4  Redistribution and use in source and binary forms, with or without
5  modification, are permitted provided that the following conditions
6  are met:
7  1. Redistributions of source code must retain the above copyright
8     notice, this list of conditions, and the following disclaimer.
9  2. Redistributions in binary form must reproduce the above copyright
10     notice, this list of conditions, and the disclaimer that follows
11     these conditions in the documentation and/or other materials
12     provided with the distribution.
13  3. The name "JPublish" must not be used to endorse or promote products
14     derived from this software without prior written permission. For
15     written permission, please contact info@aetrion.com.
16  4. Products derived from this software may not be called "JPublish", nor
17     may "JPublish" appear in their name, without prior written permission
18     from Aetrion LLC (info@aetrion.com).
19  In addition, the authors of this software request (but do not require)
20  that you include in the end-user documentation provided with the
21  redistribution and/or in the software itself an acknowledgement equivalent
22  to the following:
23      "This product includes software developed by
24       Aetrion LLC (http://www.aetrion.com/)."
25  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
26  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28  DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
29  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
34  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  POSSIBILITY OF SUCH DAMAGE.
36  For more information on JPublish, please see <http://www.jpublish.org/>.
37  */

38 package org.jpublish.util;
39
40 import java.text.MessageFormat JavaDoc;
41 import java.util.List JavaDoc;
42
43 /**
44  * Description of the Class
45  *
46  * @author Anthony Eden
47  */

48 public class MessageUtilities {
49
50     private final static MessageUtilities messageUtilities =
51             new MessageUtilities();
52
53     /**
54      * Get an instance of MessageUtilities class
55      *
56      * @return The instance
57      */

58     public static MessageUtilities getInstance() {
59         return messageUtilities;
60     }
61
62     /**
63      * Format the given message with the specified argument.
64      *
65      * @param message The message to format
66      * @param arg The single argument
67      * @return The formatted String
68      */

69     public String JavaDoc format(String JavaDoc message, String JavaDoc arg) {
70         Object JavaDoc[] args = {arg};
71         return MessageFormat.format(message, args);
72     }
73
74     /**
75      * Format the given message with the specified arguments.
76      *
77      * @param message The message to format
78      * @param arguments The single argument
79      * @return The formatted String
80      */

81     public String JavaDoc format(String JavaDoc message, List JavaDoc arguments) {
82         Object JavaDoc[] args = arguments.toArray();
83         return MessageFormat.format(message, args);
84     }
85
86 }
87
88
Popular Tags