Skip to main content
summaryrefslogtreecommitdiffstats
blob: 159cdba0cf950c9894a5bc6beccf4d62f5f54fc2 (plain) (blame)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/**
 * Copyright (c) 2011 Ericsson and others.
 * 
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *    Ericsson Research Canada - Provides resources from resource bundle.
 * 
 */
package org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal;

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

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.reviews.r4e.mail.smtp.Activator;

/**
 * 
 * 
 * @author Jacques Bouthillier
 * @version $Id: R4EString.java
 */
public class SMTPHostString {
	/**
	 * Field FBUNDLE_NAME.
	 * (value is ""org.eclipse.mylyn.reviews.r4e.mail.smtp.R4EString"")
	 */
	private static final String FBUNDLE_NAME = "org.eclipse.mylyn.reviews.r4e.mail.smtp.SMTPHostString"; //$NON-NLS-1$

	/**
	 * Field RESOURCE_BUNDLE.
	 */
	private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
			.getBundle(FBUNDLE_NAME);

	/**
	 * Private Constructor
	 */
	private SMTPHostString() {
		//Prevents clients from instantiating this class.
	}

	/**
	 * Gets the key from the value, or 'value' if not found.
	 * 
	 * @param key the value to search value.
	
	 * @return the key from the value, or 'value' if not found. */
	public static String getString(String key) {
		// Debug.print("In getString for: " + key);
		try {
			return RESOURCE_BUNDLE.getString(key);
		} catch (MissingResourceException e) {
			StatusHandler.log(new Status(IStatus.ERROR, Activator.FPLUGIN_ID, IStatus.OK, e.toString(), e));
			// Debug.print("EXCEPTION In getString for:" + key);
			return '!' + key + '!';
		}
	}

	/**
	 * Format the String according to the object pass
	 * 
	 * @param key
	 *            String
	 * @param arg
	 *            Object
	
	 * @return the key from the value, or 'value' if not found. */
	public static String getFormattedString(String key, Object arg) {
		String format = null;
		try {
			format = RESOURCE_BUNDLE.getString(key);
		} catch (MissingResourceException e) {
			StatusHandler.log(new Status(IStatus.ERROR, Activator.FPLUGIN_ID, IStatus.OK, e.toString(), e));
			return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ 
		}
		if (null == arg) {
			arg = ""; //$NON-NLS-1$ 
		}
		return MessageFormat.format(format, new Object[] { arg });
	}

	/**
	 * Format the String according to the object pass
	 * 
	 * @param key
	 *            String
	
	
	 * @param args String[]
	 * @return the key from the value, or 'value' if not found. */
	public static String getFormattedString(String key, String[] args) {
		return MessageFormat.format(RESOURCE_BUNDLE.getString(key),
				args);
	}

}

Back to the top