1 | /* |
2 | * Copyright 2005-2006 The RbUtils Project |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | * |
16 | */ |
17 | |
18 | // $Id: RbUtilsHelper.java,v 1.3 2006/09/16 14:29:10 redfish Exp $ |
19 | |
20 | package org.ktc.rbutils; |
21 | |
22 | |
23 | import org.ktc.rbutils.api.i18n.Message; |
24 | |
25 | /** |
26 | * Provides general informations about the RbUtils project. |
27 | * @since RbUtils 0.4.1 |
28 | * @version $Revision: 1.3 $ |
29 | * @author ktcguru |
30 | */ |
31 | public class RbUtilsHelper { |
32 | |
33 | /** Name of the RessourceBundle for this class. */ |
34 | private static final String RESOURCE = rbutilsInfos.class.getName(); |
35 | |
36 | /** |
37 | * Dummy constructor. This <b>MUST NOT</b> be instanciated. |
38 | * @throws UnsupportedOperationException if this class is instanciated. |
39 | */ |
40 | protected RbUtilsHelper() { |
41 | // prevents calls from subclass |
42 | throw new UnsupportedOperationException(); |
43 | } |
44 | |
45 | /** |
46 | * Returns the version of the project. |
47 | * @return the version of project. |
48 | */ |
49 | public static String getVersion() { |
50 | return getMessage(rbutilsInfos.RBUTILS_VERSION); |
51 | } |
52 | |
53 | /** |
54 | * Returns the compiled timestamp of the project. |
55 | * @return the compiled timestamp of the project. |
56 | * @since RbUtils 0.9.3.3 |
57 | */ |
58 | public static String getTimestamp() { |
59 | return getMessage(rbutilsInfos.RBUTILS_TIMESTAMP); |
60 | } |
61 | |
62 | /** |
63 | * Returns the project's homepage url. |
64 | * @return the project's homepage url. |
65 | */ |
66 | public static String getHomePage() { |
67 | return getMessage(rbutilsInfos.RBUTILS_HOMEPAGE); |
68 | } |
69 | |
70 | /** |
71 | * {@inheritDoc} |
72 | */ |
73 | public static Message getLocalizedMessage(final String key, final Object[] args) { |
74 | // TODO code - duplication with the localized message feature |
75 | return new Message(RESOURCE, key, args); |
76 | } |
77 | |
78 | /** |
79 | * {@inheritDoc} |
80 | */ |
81 | public static String getMessage(final String key, final Object[] args) { |
82 | return getLocalizedMessage(key, args).getMessage(); |
83 | } |
84 | |
85 | /** |
86 | * {@inheritDoc} |
87 | */ |
88 | public static String getMessage(final String key) { |
89 | return getLocalizedMessage(key, null).getMessage(); |
90 | } |
91 | |
92 | /** |
93 | * Returns the full version of RbUtils. It means the version number and the compiled timestamp. |
94 | * @return the full version of RbUtils. |
95 | * @since RbUtils 0.9.3.3 |
96 | */ |
97 | public static String getFullVersion() { |
98 | return getVersion() + " (" + getTimestamp() + ")"; |
99 | } |
100 | |
101 | } |