001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (https://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: https://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: https://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.ai.Messages.get(),
054            org.opencms.cache.Messages.get(),
055            org.opencms.configuration.Messages.get(),
056            org.opencms.db.Messages.get(),
057            org.opencms.db.generic.Messages.get(),
058            org.opencms.db.log.Messages.get(),
059            org.opencms.file.Messages.get(),
060            org.opencms.file.collectors.Messages.get(),
061            org.opencms.file.types.Messages.get(),
062            org.opencms.file.wrapper.Messages.get(),
063            org.opencms.flex.Messages.get(),
064            org.opencms.gwt.Messages.get(),
065            org.opencms.i18n.Messages.get(),
066            org.opencms.importexport.Messages.get(),
067            org.opencms.jsp.Messages.get(),
068            org.opencms.jsp.decorator.Messages.get(),
069            org.opencms.jsp.util.Messages.get(),
070            org.opencms.jsp.userdata.Messages.get(),
071            org.opencms.loader.Messages.get(),
072            org.opencms.lock.Messages.get(),
073            org.opencms.mail.Messages.get(),
074            org.opencms.main.Messages.get(),
075            org.opencms.module.Messages.get(),
076            org.opencms.monitor.Messages.get(),
077            org.opencms.notification.Messages.get(),
078            org.opencms.publish.Messages.get(),
079            org.opencms.relations.Messages.get(),
080            org.opencms.repository.Messages.get(),
081            org.opencms.report.Messages.get(),
082            org.opencms.scheduler.Messages.get(),
083            org.opencms.scheduler.jobs.Messages.get(),
084            org.opencms.search.Messages.get(),
085            org.opencms.search.documents.Messages.get(),
086            org.opencms.search.extractors.Messages.get(),
087            org.opencms.search.solr.Messages.get(),
088            org.opencms.security.Messages.get(),
089            org.opencms.site.Messages.get(),
090            org.opencms.staticexport.Messages.get(),
091            org.opencms.synchronize.Messages.get(),
092            org.opencms.ui.Messages.get(),
093            org.opencms.ui.apps.Messages.get(),
094            org.opencms.ui.apps.git.Messages.get(),
095            org.opencms.ui.components.Messages.get(),
096            org.opencms.ui.contextmenu.Messages.get(),
097            org.opencms.ui.dialogs.Messages.get(),
098            org.opencms.util.Messages.get(),
099            org.opencms.widgets.Messages.get(),
100            org.opencms.workflow.Messages.get(),
101            org.opencms.workplace.Messages.get(),
102            org.opencms.workplace.commons.Messages.get(),
103            org.opencms.workplace.comparison.Messages.get(),
104            org.opencms.workplace.editors.Messages.get(),
105            org.opencms.workplace.explorer.Messages.get(),
106            org.opencms.workplace.galleries.Messages.get(),
107            org.opencms.workplace.list.Messages.get(),
108            org.opencms.workplace.threads.Messages.get(),
109            org.opencms.workplace.tools.Messages.get(),
110            org.opencms.workplace.tools.scheduler.Messages.get(),
111            org.opencms.xml.Messages.get(),
112            org.opencms.xml.containerpage.Messages.get(),
113            org.opencms.xml.content.Messages.get(),
114            org.opencms.xml.page.Messages.get(),
115            org.opencms.xml.types.Messages.get()};
116    }
117
118    /**
119     * @see org.opencms.i18n.I_CmsMessageBundle#container(java.lang.String)
120     */
121    public CmsMessageContainer container(String key) {
122
123        return container(key, null);
124    }
125
126    /**
127     * @see org.opencms.i18n.I_CmsMessageBundle#container(java.lang.String, java.lang.Object)
128     */
129    public CmsMessageContainer container(String key, Object arg0) {
130
131        return container(key, new Object[] {arg0});
132    }
133
134    /**
135     * @see org.opencms.i18n.I_CmsMessageBundle#container(java.lang.String, java.lang.Object, java.lang.Object)
136     */
137    public CmsMessageContainer container(String key, Object arg0, Object arg1) {
138
139        return container(key, new Object[] {arg0, arg1});
140    }
141
142    /**
143     * @see org.opencms.i18n.I_CmsMessageBundle#container(java.lang.String, java.lang.Object, java.lang.Object, java.lang.Object)
144     */
145    public CmsMessageContainer container(String key, Object arg0, Object arg1, Object arg2) {
146
147        return container(key, new Object[] {arg0, arg1, arg2});
148    }
149
150    /**
151     * @see org.opencms.i18n.I_CmsMessageBundle#container(java.lang.String, java.lang.Object[])
152     */
153    public CmsMessageContainer container(String message, Object[] args) {
154
155        return new CmsMessageContainer(this, message, args);
156    }
157
158    /**
159     * @see org.opencms.i18n.I_CmsMessageBundle#getBundle()
160     */
161    public CmsMessages getBundle() {
162
163        Locale locale = CmsLocaleManager.getDefaultLocale();
164        if (locale == null) {
165            locale = Locale.getDefault();
166        }
167        return getBundle(locale);
168    }
169
170    /**
171     * @see org.opencms.i18n.I_CmsMessageBundle#getBundle(java.util.Locale)
172     */
173    public CmsMessages getBundle(Locale locale) {
174
175        return new CmsMessages(getBundleName(), locale);
176    }
177
178    /**
179     * @see java.lang.Object#toString()
180     */
181    @Override
182    public String toString() {
183
184        StringBuffer result = new StringBuffer();
185
186        result.append('[');
187        result.append(this.getClass().getName());
188        result.append(", bundle: ");
189        result.append(getBundle());
190        result.append(']');
191
192        return result.toString();
193    }
194}