KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > databinding > BindingMessages


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.core.internal.databinding;
12
13 import java.util.MissingResourceException JavaDoc;
14 import java.util.ResourceBundle JavaDoc;
15
16 import com.ibm.icu.text.MessageFormat;
17
18 /**
19  * @since 1.0
20  *
21  */

22 public class BindingMessages {
23
24     /**
25      * The Binding resource bundle; eagerly initialized.
26      */

27     private static final ResourceBundle JavaDoc bundle = ResourceBundle
28             .getBundle("org.eclipse.core.internal.databinding.messages"); //$NON-NLS-1$
29

30     /**
31      * Key to be used for an index out of range message.
32      */

33     public static final String JavaDoc INDEX_OUT_OF_RANGE = "IndexOutOfRange"; //$NON-NLS-1$
34

35     /**
36      * Key to be used for a "Multiple Problems." message.
37      */

38     public static final String JavaDoc MULTIPLE_PROBLEMS = "MultipleProblems"; //$NON-NLS-1$
39

40     /**
41      * Returns the resource object with the given key in the resource bundle for
42      * JFace Data Binding. If there isn't any value under the given key, the key
43      * is returned.
44      *
45      * @param key
46      * the resource name
47      * @return the string
48      */

49     public static String JavaDoc getString(String JavaDoc key) {
50         try {
51             return bundle.getString(key);
52         } catch (MissingResourceException JavaDoc e) {
53             return key;
54         }
55     }
56
57     /**
58      * Returns a formatted string with the given key in the resource bundle for
59      * JFace Data Binding.
60      *
61      * @param key
62      * @param arguments
63      * @return formatted string, the key if the key is invalid
64      */

65     public static String JavaDoc formatString(String JavaDoc key, Object JavaDoc[] arguments) {
66         try {
67             return MessageFormat.format(bundle.getString(key), arguments);
68         } catch (MissingResourceException JavaDoc e) {
69             return key;
70         }
71     }
72 }
73
Popular Tags