1 /** 2 * Copyright 2005-2014 The Kuali Foundation 3 * 4 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php 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 package org.kuali.rice.krad.messages; 17 18 import java.util.Collection; 19 20 /** 21 * Message Service API 22 * 23 * <p> 24 * Messages given within an application can be externalized to a separate repository. Those messages are 25 * then retrieved with use of the message service. The API provides various retrieval methods based on how 26 * the message is identified 27 * </p> 28 * 29 * @author Kuali Rice Team (rice.collab@kuali.org) 30 */ 31 public interface MessageService { 32 33 public static final String DEFAULT_NAMESPACE_CODE = "KUALI"; 34 public static final String DEFAULT_COMPONENT_CODE = "All"; 35 36 /** 37 * Gets the {@link Message} object that has the given namespace, component, key, and the default 38 * system locale 39 * 40 * @param namespace namespace code the message belongs to, if null the default namespace should 41 * be used 42 * @param component component code the namespace is associated with, if null the default component 43 * should be used 44 * @param key key that identifies the message within the namespace and component 45 * @return Message matching message object, or null if a message was not found 46 */ 47 public Message getMessage(String namespace, String component, String key); 48 49 /** 50 * Gets the {@link Message} object that has the given namespace, component, key, and locale 51 * 52 * @param namespace namespace code the message belongs to, if null the default namespace should 53 * be used 54 * @param component component code the namespace is associated with, if null the default component 55 * should be used 56 * @param key key that identifies the message within the namespace and component 57 * @param locale locale code for the message to return 58 * @return Message matching message object, or null if a message was not found 59 */ 60 public Message getMessage(String namespace, String component, String key, String locale); 61 62 /** 63 * Gets the text for the message that has the given namespace, component, key, and the default 64 * system locale 65 * 66 * @param namespace namespace code the message belongs to, if null the default namespace should 67 * be used 68 * @param component component code the namespace is associated with, if null the default component 69 * should be used 70 * @param key key that identifies the message within the namespace and component 71 * @return String text for the matched message, or null if no message was found 72 */ 73 public String getMessageText(String namespace, String component, String key); 74 75 /** 76 * Gets the text for the message that has the given namespace, component, key, and locale 77 * 78 * @param namespace namespace code the message belongs to, if null the default namespace should 79 * be used 80 * @param component component code the namespace is associated with, if null the default component 81 * should be used 82 * @param key key that identifies the message within the namespace and component 83 * @param locale locale code for the message to return 84 * @return String text for the matched message, or null if no message was found 85 */ 86 public String getMessageText(String namespace, String component, String key, String locale); 87 88 /** 89 * Gets the text for the message that has the given key within the default namespace, component, 90 * and locale (note the defaults are determined by the service implementation) 91 * 92 * @param key key that identifies the message within the default namespace and component 93 * @return String text for the matched message, or null if no message was found 94 */ 95 public String getMessageText(String key); 96 97 /** 98 * Gets the text for the message that has the given key and locale within the default namespace and 99 * 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 }