KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > dictionary > M2Label


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.dictionary;
18
19 import java.util.Locale JavaDoc;
20
21 import org.alfresco.i18n.I18NUtil;
22 import org.alfresco.service.cmr.dictionary.ModelDefinition;
23 import org.alfresco.service.namespace.QName;
24 import org.springframework.util.StringUtils;
25
26
27 /**
28  * Helper for obtaining display labels for data dictionary items
29  *
30  * @author David Caruana
31  */

32 public class M2Label
33 {
34
35     /**
36      * Get label for data dictionary item given specified locale
37      *
38      * @param locale
39      * @param model
40      * @param type
41      * @param item
42      * @param label
43      * @return
44      */

45     public static String JavaDoc getLabel(Locale JavaDoc locale, ModelDefinition model, String JavaDoc type, QName item, String JavaDoc label)
46     {
47         String JavaDoc key = model.getName().toPrefixString();
48         if (type != null)
49         {
50             key += "." + type;
51         }
52         if (item != null)
53         {
54             key += "." + item.toPrefixString();
55         }
56         key += "." + label;
57         key = StringUtils.replace(key, ":", "_");
58         return I18NUtil.getMessage(key, locale);
59     }
60     
61     /**
62      * Get label for data dictionary item
63      *
64      * @param model
65      * @param type
66      * @param item
67      * @param label
68      * @return
69      */

70     public static String JavaDoc getLabel(ModelDefinition model, String JavaDoc type, QName item, String JavaDoc label)
71     {
72         return getLabel(I18NUtil.getLocale(), model, type, item, label);
73     }
74     
75 }
76
Popular Tags