001: /*
002: * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/LocaleMessageUtil.java,v 1.3 2007/12/10 03:21:14 minhnn Exp $
003: * $Author: minhnn $
004: * $Revision: 1.3 $
005: * $Date: 2007/12/10 03:21:14 $
006: *
007: * ====================================================================
008: *
009: * Copyright (C) 2002-2007 by MyVietnam.net
010: *
011: * All copyright notices regarding mvnForum MUST remain
012: * intact in the scripts and in the outputted HTML.
013: * The "powered by" text/logo with a link back to
014: * http://www.mvnForum.com and http://www.MyVietnam.net in
015: * the footer of the pages MUST remain visible when the pages
016: * are viewed on the internet or intranet.
017: *
018: * This program is free software; you can redistribute it and/or modify
019: * it under the terms of the GNU General Public License as published by
020: * the Free Software Foundation; either version 2 of the License, or
021: * any later version.
022: *
023: * This program is distributed in the hope that it will be useful,
024: * but WITHOUT ANY WARRANTY; without even the implied warranty of
025: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
026: * GNU General Public License for more details.
027: *
028: * You should have received a copy of the GNU General Public License
029: * along with this program; if not, write to the Free Software
030: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
031: *
032: * Support can be obtained from support forums at:
033: * http://www.mvnForum.com/mvnforum/index
034: *
035: * Correspondence and Marketing Questions can be sent to:
036: * info at MyVietnam net
037: *
038: * @author: Minh Nguyen
039: */
040: package com.mvnforum;
041:
042: import java.util.Locale;
043:
044: import com.mvnforum.db.*;
045:
046: public class LocaleMessageUtil {
047:
048: /**************************************************************************
049: * Thread bean
050: **************************************************************************/
051: public static String getThreadStatusDescFromInt(Locale locale,
052: int threadStatus) {
053:
054: String result = null;
055: switch (threadStatus) {
056: case ThreadBean.THREAD_STATUS_DEFAULT:
057: result = MVNForumResourceBundle.getString(locale,
058: "mvnforum.common.thread.status.active");
059: break;
060:
061: case ThreadBean.THREAD_STATUS_DISABLED:
062: result = MVNForumResourceBundle.getString(locale,
063: "mvnforum.common.thread.status.disabled");
064: break;
065:
066: case ThreadBean.THREAD_STATUS_LOCKED:
067: result = MVNForumResourceBundle.getString(locale,
068: "mvnforum.common.thread.status.locked");
069: break;
070:
071: case ThreadBean.THREAD_STATUS_CLOSED:
072: result = MVNForumResourceBundle.getString(locale,
073: "mvnforum.common.thread.status.closed");
074: break;
075:
076: default:
077: throw new AssertionError(
078: "Cannot get thread status description with threadStatus = "
079: + threadStatus);
080: }
081: return result;
082: }
083:
084: public static String getThreadTypeDescFromInt(Locale locale,
085: int threadType) {
086:
087: String result;
088: switch (threadType) {
089: case ThreadBean.THREAD_TYPE_DEFAULT:
090: result = MVNForumResourceBundle.getString(locale,
091: "mvnforum.common.thread.type.normal_thread");
092: break;
093:
094: case ThreadBean.THREAD_TYPE_STICKY:
095: result = MVNForumResourceBundle.getString(locale,
096: "mvnforum.common.thread.type.sticky_thread");
097: break;
098:
099: case ThreadBean.THREAD_TYPE_FORUM_ANNOUNCEMENT:
100: result = MVNForumResourceBundle.getString(locale,
101: "mvnforum.common.thread.type.announcement_thread");
102: break;
103:
104: case ThreadBean.THREAD_TYPE_GLOBAL_ANNOUNCEMENT:
105: result = MVNForumResourceBundle
106: .getString(locale,
107: "mvnforum.common.thread.type.global_announcement_thread");
108: break;
109:
110: default:
111: throw new AssertionError(
112: "Cannot get thread type description with threadType = "
113: + threadType);
114: }
115: return result;
116: }
117:
118: public static String getThreadPriorityDescFromInt(Locale locale,
119: int threadPriority) {
120:
121: String result;
122: switch (threadPriority) {
123: case ThreadBean.THREAD_PRIORITY_NORMAL:
124: result = MVNForumResourceBundle.getString(locale,
125: "mvnforum.common.thread.priority.normal");
126: break;
127:
128: case ThreadBean.THREAD_PRIORITY_LOW:
129: result = MVNForumResourceBundle.getString(locale,
130: "mvnforum.common.thread.priority.low");
131: break;
132:
133: case ThreadBean.THREAD_PRIORITY_HIGH:
134: result = MVNForumResourceBundle.getString(locale,
135: "mvnforum.common.thread.priority.high");
136: break;
137:
138: default:
139: throw new AssertionError(
140: "Cannot get thread priority description with threadPriority = "
141: + threadPriority);
142: }
143: return result;
144: }
145:
146: /**************************************************************************
147: * Forum bean
148: **************************************************************************/
149: public static String getForumStatusDescFromInt(Locale locale,
150: int forumStatus) {
151:
152: String result = null;
153: switch (forumStatus) {
154: case ForumBean.FORUM_STATUS_DEFAULT:
155: result = MVNForumResourceBundle.getString(locale,
156: "mvnforum.common.forum.status.active");
157: break;
158:
159: case ForumBean.FORUM_STATUS_DISABLED:
160: result = MVNForumResourceBundle.getString(locale,
161: "mvnforum.common.forum.status.disabled");
162: break;
163:
164: case ForumBean.FORUM_STATUS_LOCKED:
165: result = MVNForumResourceBundle.getString(locale,
166: "mvnforum.common.forum.status.locked");
167: break;
168:
169: case ForumBean.FORUM_STATUS_CLOSED:
170: result = MVNForumResourceBundle.getString(locale,
171: "mvnforum.common.forum.status.closed");
172: break;
173:
174: default:
175: throw new AssertionError(
176: "Cannot get forum status description with forumStatus = "
177: + forumStatus);
178: }
179: return result;
180: }
181:
182: public static String getForumTypeDescFromInt(Locale locale,
183: int forumType) {
184:
185: String result;
186: switch (forumType) {
187: case ForumBean.FORUM_TYPE_DEFAULT:
188: result = MVNForumResourceBundle.getString(locale,
189: "mvnforum.common.forum.type.default");
190: break;
191:
192: case ForumBean.FORUM_TYPE_PRIVATE:
193: result = MVNForumResourceBundle.getString(locale,
194: "mvnforum.common.forum.type.private");
195: break;
196:
197: default:
198: throw new AssertionError(
199: "Cannot get forum type description with forumType = "
200: + forumType);
201: }
202:
203: return result;
204: }
205:
206: public static String getForumModeDescFromInt(Locale locale,
207: int forumMode) {
208:
209: String result;
210: switch (forumMode) {
211: case ForumBean.FORUM_MODERATION_MODE_SYSTEM_DEFAULT:
212: result = MVNForumResourceBundle.getString(locale,
213: "mvnforum.common.forum.moderation_mode.default");
214: break;
215:
216: case ForumBean.FORUM_MODERATION_MODE_NO_MODERATION:
217: result = MVNForumResourceBundle.getString(locale,
218: "mvnforum.common.forum.moderation_mode.no");
219: break;
220:
221: case ForumBean.FORUM_MODERATION_MODE_THREAD_AND_POST:
222: result = MVNForumResourceBundle
223: .getString(locale,
224: "mvnforum.common.forum.moderation_mode.thread_post");
225: break;
226:
227: case ForumBean.FORUM_MODERATION_MODE_THREAD_ONLY:
228: result = MVNForumResourceBundle.getString(locale,
229: "mvnforum.common.forum.moderation_mode.thread");
230: break;
231:
232: case ForumBean.FORUM_MODERATION_MODE_POST_ONLY:
233: result = MVNForumResourceBundle.getString(locale,
234: "mvnforum.common.forum.moderation_mode.post");
235: break;
236:
237: default:
238: throw new AssertionError(
239: "Cannot get forum mode description with forumMode = "
240: + forumMode);
241: }
242:
243: return result;
244: }
245:
246: /**************************************************************************
247: * Watch bean
248: **************************************************************************/
249: public static String getWatchTypeDescFromInt(Locale locale,
250: int watchType) {
251:
252: String result;
253: switch (watchType) {
254: case WatchBean.WATCH_TYPE_DEFAULT:
255: result = MVNForumResourceBundle.getString(locale,
256: "mvnforum.common.watch.type.default");
257: break;
258:
259: case WatchBean.WATCH_TYPE_DIGEST:
260: result = MVNForumResourceBundle.getString(locale,
261: "mvnforum.common.watch.type.digest");
262: break;
263:
264: case WatchBean.WATCH_TYPE_NONDIGEST:
265: result = MVNForumResourceBundle.getString(locale,
266: "mvnforum.common.watch.type.nondigest");
267: break;
268:
269: default:
270: throw new AssertionError(
271: "Cannot get watch type description with watchType = "
272: + watchType);
273: }
274:
275: return result;
276: }
277:
278: /**************************************************************************
279: * Member bean
280: **************************************************************************/
281: public static String getMemberStatusDescFromInt(Locale locale,
282: int memberStatus) {
283:
284: String result;
285: switch (memberStatus) {
286: case MemberBean.MEMBER_STATUS_ENABLE:
287: result = MVNForumResourceBundle.getString(locale,
288: "mvnforum.common.member.status.enabled");
289: break;
290:
291: case MemberBean.MEMBER_STATUS_DISABLE:
292: result = MVNForumResourceBundle.getString(locale,
293: "mvnforum.common.member.status.disabled");
294: break;
295:
296: case MemberBean.MEMBER_STATUS_PENDING:
297: result = MVNForumResourceBundle.getString(locale,
298: "mvnforum.common.member.status.pending");
299: break;
300:
301: case MemberBean.MEMBER_STATUS_DELETED:
302: result = MVNForumResourceBundle.getString(locale,
303: "mvnforum.common.member.status.deleted");
304: break;
305:
306: default:
307: throw new AssertionError(
308: "Cannot get member status description with memberStatus = "
309: + memberStatus);
310: }
311:
312: return result;
313: }
314:
315: /**************************************************************************
316: * PollAnswer bean
317: **************************************************************************/
318: public static String getPollAnswerTypeDescFromInt(Locale locale,
319: int pollAnswerType) {
320:
321: String result;
322: switch (pollAnswerType) {
323: case PollAnswerBean.POLL_ANSWER_TYPE_NORMAL:
324: result = MVNForumResourceBundle.getString(locale,
325: "mvnforum.common.pollanswer.type.normal");
326: break;
327:
328: case PollAnswerBean.POLL_ANSWER_TYPE_NEED_YOUR_OPINION:
329: result = MVNForumResourceBundle
330: .getString(locale,
331: "mvnforum.common.pollanswer.type.need_your_opinion");
332: break;
333:
334: default:
335: throw new AssertionError(
336: "Cannot get poll answer type description with pollAnswerType = "
337: + pollAnswerType);
338: }
339:
340: return result;
341: }
342:
343: /**************************************************************************
344: * Poll bean
345: **************************************************************************/
346: public static String getPollStatusDescFromInt(Locale locale,
347: int pollStatus) {
348:
349: String result;
350: switch (pollStatus) {
351: case PollBean.POLL_STATUS_ENABLE:
352: result = MVNForumResourceBundle.getString(locale,
353: "mvnforum.common.poll.status.enable");
354: break;
355:
356: case PollBean.POLL_STATUS_EDITING:
357: result = MVNForumResourceBundle.getString(locale,
358: "mvnforum.common.poll.status.editing");
359: break;
360:
361: case PollBean.POLL_STATUS_DISABLED:
362: result = MVNForumResourceBundle.getString(locale,
363: "mvnforum.common.poll.status.disabled");
364: break;
365:
366: default:
367: throw new AssertionError(
368: "Cannot get poll status description with pollStatus = "
369: + pollStatus);
370: }
371:
372: return result;
373: }
374:
375: public static String getPollMultipleDescFromInt(Locale locale,
376: int pollMultiple) {
377:
378: String result;
379: switch (pollMultiple) {
380: case PollBean.POLL_MULTIPLE_NO:
381: result = MVNForumResourceBundle.getString(locale,
382: "mvnforum.common.poll.multiple.single_choice");
383: break;
384:
385: case PollBean.POLL_MULTIPLE_YES:
386: result = MVNForumResourceBundle.getString(locale,
387: "mvnforum.common.poll.multiple.multiple_choice");
388: break;
389:
390: default:
391: throw new AssertionError(
392: "Cannot get poll multiple description with pollMultiple = "
393: + pollMultiple);
394: }
395:
396: return result;
397: }
398:
399: }
|