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