CDVMessages.java 2.33 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*-
 *  Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
 * 
 *  This file is part of CityDoctor2.
 *
 *  CityDoctor2 is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  CityDoctor2 is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with CityDoctor2.  If not, see <https://www.gnu.org/licenses/>.
 */
package de.hft.stuttgart.citydoctor2;

import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;

/**
 * Provides access to message strings in different languages.
 * 
 * @author Matthias Betz - 12bema1bif@hft-stuttgart.de
 * @version 1.0
 *
 */
public class CDVMessages {

	public static final String MISSING_SOURCE_FILE = "ArgumentParser.MissingSourceFile";
	public static final String INVALID_PARAMETER = "ArgumentParser.InvalidParameter";
	public static final String VERSION = "CityDoctorValidation.Version";

	private static final String BUNDLE_NAME = "de.hft.stuttgart.citydoctor2.cdvmessages";

	private static final ResourceBundle RESOURCE_BUNDLE;

	static {
		RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, Locale.getDefault());
	}

	/**
	 * Gives the message string for the given key based on the default locale.
	 * 
	 * @param key
	 *            the key for the message
	 * @return localized message.
	 */
	public static String getString(String key) {
		return RESOURCE_BUNDLE.getString(key);
	}

	/**
	 * Constructs a string out of the key and the given parameters with the
	 * MessageFormatter.
	 * 
	 * @param key
	 *            the key for the message
	 * @param params
	 *            the parameters for the message
	 * @return the localized message with the parameters substituted.
	 * @see MessageFormat#format(String, Object...);
	 */
	public static String getString(String key, Object... params) {
		String msg = getString(key);
		return MessageFormat.format(msg, params);
	}

	private CDVMessages() {
	}

}