001/**
002 * Copyright 2005-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.krad.messages;
017
018import java.util.Collection;
019
020/**
021 * Message Service API
022 *
023 * <p>
024 * Messages given within an application can be externalized to a separate repository. Those messages are
025 * then retrieved with use of the message service. The API provides various retrieval methods based on how
026 * the message is identified
027 * </p>
028 *
029 * @author Kuali Rice Team (rice.collab@kuali.org)
030 */
031public interface MessageService {
032
033    public static final String DEFAULT_NAMESPACE_CODE = "KUALI";
034    public static final String DEFAULT_COMPONENT_CODE = "All";
035
036    /**
037     * Gets the {@link Message} object that has the given namespace, component, key, and the default
038     * system locale
039     *
040     * @param namespace namespace code the message belongs to, if null the default namespace should
041     * be used
042     * @param component component code the namespace is associated with, if null the default component
043     * should be used
044     * @param key key that identifies the message within the namespace and component
045     * @return Message matching message object, or null if a message was not found
046     */
047    public Message getMessage(String namespace, String component, String key);
048
049    /**
050     * Gets the {@link Message} object that has the given namespace, component, key, and locale
051     *
052     * @param namespace namespace code the message belongs to, if null the default namespace should
053     * be used
054     * @param component component code the namespace is associated with, if null the default component
055     * should be used
056     * @param key key that identifies the message within the namespace and component
057     * @param locale locale code for the message to return
058     * @return Message matching message object, or null if a message was not found
059     */
060    public Message getMessage(String namespace, String component, String key, String locale);
061
062    /**
063     * Gets the text for the message that has the given namespace, component, key, and the default
064     * system locale
065     *
066     * @param namespace namespace code the message belongs to, if null the default namespace should
067     * be used
068     * @param component component code the namespace is associated with, if null the default component
069     * should be used
070     * @param key key that identifies the message within the namespace and component
071     * @return String text for the matched message, or null if no message was found
072     */
073    public String getMessageText(String namespace, String component, String key);
074
075    /**
076     * Gets the text for the message that has the given namespace, component, key, and locale
077     *
078     * @param namespace namespace code the message belongs to, if null the default namespace should
079     * be used
080     * @param component component code the namespace is associated with, if null the default component
081     * should be used
082     * @param key key that identifies the message within the namespace and component
083     * @param locale locale code for the message to return
084     * @return String text for the matched message, or null if no message was found
085     */
086    public String getMessageText(String namespace, String component, String key, String locale);
087
088    /**
089     * Gets the text for the message that has the given key within the default namespace, component,
090     * and locale (note the defaults are determined by the service implementation)
091     *
092     * @param key key that identifies the message within the default namespace and component
093     * @return String text for the matched message, or null if no message was found
094     */
095    public String getMessageText(String key);
096
097    /**
098     * Gets the text for the message that has the given key and locale within the default namespace and
099     * component (note the defaults are determined by the service implementation)
100     *
101     * @param key key that identifies the message within the default namespace and component
102     * @param locale locale code for the message to return
103     * @return String text for the matched message, or null if no message was found
104     */
105    public String getMessageText(String key, String locale);
106
107    /**
108     * Gets all message objects for the given namespace and component using the default locale
109     *
110     * @param namespace namespace code the message belongs to
111     * @param component component code the namespace is associated with
112     * @return Collection<Message> collection of messages that match, or empty collection if no messages
113     *         are found
114     */
115    public Collection<Message> getAllMessagesForComponent(String namespace, String component);
116
117    /**
118     * Gets all message objects for the given namespace, component, and locale
119     *
120     * @param namespace namespace code the message belongs to
121     * @param component component code the namespace is associated with
122     * @param locale locale code for the message to return
123     * @return Collection<Message> collection of messages that match, or empty collection if no messages
124     *         are found
125     */
126    public Collection<Message> getAllMessagesForComponent(String namespace, String component, String locale);
127
128}