KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workflow > Messages


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/workflow/Messages.java,v $
3  * Date : $Date: 2006/03/28 12:14:36 $
4  * Version: $Revision: 1.10 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.workflow;
33
34 import org.opencms.file.CmsRequestContext;
35 import org.opencms.i18n.A_CmsMessageBundle;
36 import org.opencms.i18n.CmsLocaleManager;
37 import org.opencms.i18n.I_CmsMessageBundle;
38
39 import java.util.Locale JavaDoc;
40
41 /**
42  * Convenience class to access the localized messages of this OpenCms package.<p>
43  *
44  * @author Achim Westermann
45  *
46  * @version $Revision: 1.10 $
47  *
48  * @since 6.0.0
49  */

50 public final class Messages extends A_CmsMessageBundle {
51
52     /** Message constant for key in the resource bundle. */
53     public static final String JavaDoc ERR_BAD_TASKNAME_4 = "ERR_BAD_TASKNAME_4";
54
55     /** Message constant for key in the resource bundle. */
56     public static final String JavaDoc ERR_BAD_TASKNAME_EMPTY_0 = "ERR_BAD_TASKNAME_EMPTY_0";
57
58     /** Message constant for key in the resource bundle. */
59     public static final String JavaDoc GUI_TASK_STATE_ENDED_0 = "GUI_TASK_STATE_ENDED_0";
60
61     /** Message constant for key in the resource bundle. */
62     public static final String JavaDoc GUI_TASK_STATE_HALTED_0 = "GUI_TASK_STATE_HALTED_0";
63
64     /** Message constant for key in the resource bundle. */
65     public static final String JavaDoc GUI_TASK_STATE_PREPARED_0 = "GUI_TASK_STATE_PREPARED_0";
66
67     /** Message constant for key in the resource bundle. */
68     public static final String JavaDoc GUI_TASK_STATE_RUNNING_0 = "GUI_TASK_STATE_RUNNING_0";
69
70     /** Message constant for key in the resource bundle. */
71     public static final String JavaDoc GUI_TASK_STATE_START_0 = "GUI_TASK_STATE_START_0";
72
73     /** Message constant for key in the resource bundle. */
74     public static final String JavaDoc GUI_TASK_STATE_STARTED_0 = "GUI_TASK_STATE_STARTED_0";
75
76     /** Message constant for key in the resource bundle. */
77     public static final String JavaDoc GUI_TASK_STATE_UNKNOWN_0 = "GUI_TASK_STATE_UNKNOWN_0";
78
79     /** Message constant for key in the resource bundle. */
80     public static final String JavaDoc GUI_TASK_TYPE_ACTIVE_0 = "GUI_TASK_TYPE_ACTIVE_0";
81
82     /** Message constant for key in the resource bundle. */
83     public static final String JavaDoc GUI_TASK_TYPE_ALL_0 = "GUI_TASK_TYPE_ALL_0";
84
85     /** Message constant for key in the resource bundle. */
86     public static final String JavaDoc GUI_TASK_TYPE_DONE_0 = "GUI_TASK_TYPE_DONE_0";
87
88     /** Message constant for key in the resource bundle. */
89     public static final String JavaDoc GUI_TASK_TYPE_ILLEGAL_0 = "GUI_TASK_TYPE_ILLEGAL_0";
90
91     /** Message constant for key in the resource bundle. */
92     public static final String JavaDoc GUI_TASK_TYPE_NEW_0 = "GUI_TASK_TYPE_NEW_0";
93
94     /** Message constant for key in the resource bundle. */
95     public static final String JavaDoc GUI_TASK_TYPE_OPEN_0 = "GUI_TASK_TYPE_OPEN_0";
96
97     /** Name of the used resource bundle. */
98     private static final String JavaDoc BUNDLE_NAME = "org.opencms.workflow.messages";
99
100     /** Static instance member. */
101     private static final I_CmsMessageBundle INSTANCE = new Messages();
102
103     /**
104      * Hides the public constructor for this utility class.<p>
105      */

106     private Messages() {
107
108         // hide the constructor
109
}
110
111     /**
112      * Returns an instance of this localized message accessor.<p>
113      *
114      * @return an instance of this localized message accessor
115      */

116     public static I_CmsMessageBundle get() {
117
118         return INSTANCE;
119     }
120
121     /**
122      * Small utility-method that allows output of task states in the OpenCms default locale. <p>
123      *
124      * @param taskType One of
125      * <ul>
126      * <li>
127      * {@link CmsTaskService#TASKS_ACTIVE}
128      * <li>
129      * {@link CmsTaskService#TASKS_ALL}
130      * <li>
131      * {@link CmsTaskService#TASKS_DONE}
132      * <li>
133      * {@link CmsTaskService#TASKS_NEW}
134      * <li>
135      * {@link CmsTaskService#TASKS_OPEN}
136      * </ul>
137      * @return A string describing the state of the task in the default locale.
138      * @see CmsTaskService
139      * @see #toTaskTypeString(int, CmsRequestContext)
140      */

141     public static String JavaDoc toTaskTypeString(int taskType) {
142
143         return toTaskTypeString(taskType, CmsLocaleManager.getDefaultLocale());
144     }
145
146     /**
147      * Small utility-method that allows output of task states in the locale of the current user request. <p>
148      *
149      * @param taskType One of
150      * <ul>
151      * <li>
152      * {@link CmsTaskService#TASKS_ACTIVE}
153      * <li>
154      * {@link CmsTaskService#TASKS_ALL}
155      * <li>
156      * {@link CmsTaskService#TASKS_DONE}
157      * <li>
158      * {@link CmsTaskService#TASKS_NEW}
159      * <li>
160      * {@link CmsTaskService#TASKS_OPEN}
161      * </ul>
162      *
163      * @param context the current user's request context.
164      * @return A string describing the state of the task in the default locale.
165      * @see CmsTaskService
166      * @see #toTaskTypeString(int)
167      */

168
169     public static String JavaDoc toTaskTypeString(int taskType, CmsRequestContext context) {
170
171         return toTaskTypeString(taskType, context.getLocale());
172     }
173
174     /**
175      * Small utility-method that allows output of task states in the given <code>Locale</code>. <p>
176      *
177      * @param taskType One of
178      * <ul>
179      * <li>
180      * {@link CmsTaskService#TASKS_ACTIVE}
181      * <li>
182      * {@link CmsTaskService#TASKS_ALL}
183      * <li>
184      * {@link CmsTaskService#TASKS_DONE}
185      * <li>
186      * {@link CmsTaskService#TASKS_NEW}
187      * <li>
188      * {@link CmsTaskService#TASKS_OPEN}
189      * </ul>
190      * @param locale the locale in which the task state should be given back.
191      * @return A string describing the state of the task in the default locale.
192      * @see CmsTaskService
193      * @see #toTaskTypeString(int)
194      */

195     public static String JavaDoc toTaskTypeString(int taskType, Locale JavaDoc locale) {
196
197         switch (taskType) {
198             case CmsTaskService.TASKS_ACTIVE:
199                 return Messages.get().getBundle(locale).key(Messages.GUI_TASK_TYPE_ACTIVE_0);
200             case CmsTaskService.TASKS_ALL:
201                 return Messages.get().getBundle(locale).key(Messages.GUI_TASK_TYPE_ACTIVE_0);
202             case CmsTaskService.TASKS_DONE:
203                 return Messages.get().getBundle(locale).key(Messages.GUI_TASK_TYPE_ACTIVE_0);
204             case CmsTaskService.TASKS_NEW:
205                 return Messages.get().getBundle(locale).key(Messages.GUI_TASK_TYPE_ACTIVE_0);
206             case CmsTaskService.TASKS_OPEN:
207             default:
208                 return Messages.get().getBundle(locale).key(Messages.GUI_TASK_TYPE_ILLEGAL_0);
209         }
210     }
211
212     /**
213      * Returns the bundle name for this OpenCms package.<p>
214      *
215      * @return the bundle name for this OpenCms package
216      */

217     public String JavaDoc getBundleName() {
218
219         return BUNDLE_NAME;
220     }
221
222 }
Popular Tags