1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.maven.plugin.eclipse;
20
21 import java.text.MessageFormat;
22 import java.util.MissingResourceException;
23 import java.util.ResourceBundle;
24
25 /**
26 * @author <a href="mailto:fgiust@users.sourceforge.net">Fabrizio Giustina</a>
27 * @version $Id: Messages.java 728546 2008-12-21 22:56:51Z bentmann $
28 */
29 public class Messages
30 {
31
32 private static final String BUNDLE_NAME = "org.apache.maven.plugin.eclipse.messages"; //$NON-NLS-1$
33
34 private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
35
36 private Messages()
37 {
38 }
39
40 public static String getString( String key )
41 {
42 try
43 {
44 return RESOURCE_BUNDLE.getString( key );
45 }
46 catch ( MissingResourceException e )
47 {
48 return '!' + key + '!';
49 }
50 }
51
52 public static String getString( String key, Object[] params )
53 {
54 try
55 {
56 return MessageFormat.format( RESOURCE_BUNDLE.getString( key ), params );
57 }
58 catch ( MissingResourceException e )
59 {
60 return '!' + key + '!';
61 }
62 }
63
64 public static String getString( String key, Object param )
65 {
66 return getString( key, new Object[] { param } );
67 }
68 }