001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software GmbH & Co. KG, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.i18n;
029
030import java.util.Locale;
031
032/**
033 * Convenience base class to access the localized messages of an OpenCms package.<p>
034 *
035 * @since 6.0.0
036 */
037public abstract class A_CmsMessageBundle implements I_CmsMessageBundle {
038
039    /**
040     * Returns an array of all messages bundles used by the OpenCms core.<p>
041     *
042     * @return an array of all messages bundles used by the OpenCms core
043     */
044    public static I_CmsMessageBundle[] getOpenCmsMessageBundles() {
045
046        return new I_CmsMessageBundle[] {
047            org.opencms.ade.detailpage.Messages.get(),
048            org.opencms.ade.containerpage.Messages.get(),
049            org.opencms.ade.galleries.Messages.get(),
050            org.opencms.ade.publish.Messages.get(),
051            org.opencms.ade.sitemap.Messages.get(),
052            org.opencms.ade.upload.Messages.get(),
053            org.opencms.cache.Messages.get(),
054            org.opencms.configuration.Messages.get(),
055            org.opencms.db.Messages.get(),
056            org.opencms.db.generic.Messages.get(),
057            org.opencms.db.log.Messages.get(),
058            org.opencms.file.Messages.get(),
059            org.opencms.file.collectors.Messages.get(),
060            org.opencms.file.types.Messages.get(),
061            org.opencms.file.wrapper.Messages.get(),
062            org.opencms.flex.Messages.get(),
063            org.opencms.gwt.Messages.get(),
064            org.opencms.i18n.Messages.get(),
065            org.opencms.importexport.Messages.get(),
066            org.opencms.jsp.Messages.get(),
067            org.opencms.jsp.decorator.Messages.get(),
068            org.opencms.jsp.util.Messages.get(),
069            org.opencms.jsp.userdata.Messages.get(),
070            org.opencms.loader.Messages.get(),
071            org.opencms.lock.Messages.get(),
072            org.opencms.mail.Messages.get(),
073            org.opencms.main.Messages.get(),
074            org.opencms.module.Messages.get(),
075            org.opencms.monitor.Messages.get(),
076            org.opencms.notification.Messages.get(),
077            org.opencms.publish.Messages.get(),
078            org.opencms.relations.Messages.get(),
079            org.opencms.repository.Messages.get(),
080            org.opencms.report.Messages.get(),
081            org.opencms.scheduler.Messages.get(),
082            org.opencms.scheduler.jobs.Messages.get(),
083            org.opencms.search.Messages.get(),
084            org.opencms.search.documents.Messages.get(),
085            org.opencms.search.extractors.Messages.get(),
086            org.opencms.search.solr.Messages.get(),
087            org.opencms.security.Messages.get(),
088            org.opencms.site.Messages.get(),
089            org.opencms.staticexport.Messages.get(),
090            org.opencms.synchronize.Messages.get(),
091            org.opencms.ui.Messages.get(),
092            org.opencms.ui.apps.Messages.get(),
093            org.opencms.ui.apps.git.Messages.get(),
094            org.opencms.ui.components.Messages.get(),
095            org.opencms.ui.contextmenu.Messages.get(),
096            org.opencms.ui.dialogs.Messages.get(),
097            org.opencms.util.Messages.get(),
098            org.opencms.widgets.Messages.get(),
099            org.opencms.workflow.Messages.get(),
100            org.opencms.workplace.Messages.get(),
101            org.opencms.workplace.commons.Messages.get(),
102            org.opencms.workplace.comparison.Messages.get(),
103            org.opencms.workplace.editors.Messages.get(),
104            org.opencms.workplace.explorer.Messages.get(),
105            org.opencms.workplace.galleries.Messages.get(),
106            org.opencms.workplace.list.Messages.get(),
107            org.opencms.workplace.threads.Messages.get(),
108            org.opencms.workplace.tools.Messages.get(),
109            org.opencms.workplace.tools.scheduler.Messages.get(),
110            org.opencms.xml.Messages.get(),
111            org.opencms.xml.containerpage.Messages.get(),
112            org.opencms.xml.content.Messages.get(),
113            org.opencms.xml.page.Messages.get(),
114            org.opencms.xml.types.Messages.get()};
115    }
116
117    /**
118     * @see org.opencms.i18n.I_CmsMessageBundle#container(java.lang.String)
119     */
120    public CmsMessageContainer container(String key) {
121
122        return container(key, null);
123    }
124
125    /**
126     * @see org.opencms.i18n.I_CmsMessageBundle#container(java.lang.String, java.lang.Object)
127     */
128    public CmsMessageContainer container(String key, Object arg0) {
129
130        return container(key, new Object[] {arg0});
131    }
132
133    /**
134     * @see org.opencms.i18n.I_CmsMessageBundle#container(java.lang.String, java.lang.Object, java.lang.Object)
135     */
136    public CmsMessageContainer container(String key, Object arg0, Object arg1) {
137
138        return container(key, new Object[] {arg0, arg1});
139    }
140
141    /**
142     * @see org.opencms.i18n.I_CmsMessageBundle#container(java.lang.String, java.lang.Object, java.lang.Object, java.lang.Object)
143     */
144    public CmsMessageContainer container(String key, Object arg0, Object arg1, Object arg2) {
145
146        return container(key, new Object[] {arg0, arg1, arg2});
147    }
148
149    /**
150     * @see org.opencms.i18n.I_CmsMessageBundle#container(java.lang.String, java.lang.Object[])
151     */
152    public CmsMessageContainer container(String message, Object[] args) {
153
154        return new CmsMessageContainer(this, message, args);
155    }
156
157    /**
158     * @see org.opencms.i18n.I_CmsMessageBundle#getBundle()
159     */
160    public CmsMessages getBundle() {
161
162        Locale locale = CmsLocaleManager.getDefaultLocale();
163        if (locale == null) {
164            locale = Locale.getDefault();
165        }
166        return getBundle(locale);
167    }
168
169    /**
170     * @see org.opencms.i18n.I_CmsMessageBundle#getBundle(java.util.Locale)
171     */
172    public CmsMessages getBundle(Locale locale) {
173
174        return new CmsMessages(getBundleName(), locale);
175    }
176
177    /**
178     * @see java.lang.Object#toString()
179     */
180    @Override
181    public String toString() {
182
183        StringBuffer result = new StringBuffer();
184
185        result.append('[');
186        result.append(this.getClass().getName());
187        result.append(", bundle: ");
188        result.append(getBundle());
189        result.append(']');
190
191        return result.toString();
192    }
193}