001    // Copyright 2006, 2007 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package org.apache.tapestry5.ioc;
016    
017    /**
018     * Provides access to a messages catalog, a set of properties files that provide localized messages for a particular
019     * locale. The message catalog consists of keys and values and follows the semantics of a Java {@link
020     * java.util.ResourceBundle} with some changes.
021     */
022    public interface Messages
023    {
024        /**
025         * Returns true if the bundle contains the named key.
026         */
027        boolean contains(String key);
028    
029        /**
030         * Returns the localized message for the given key. If catalog does not contain such a key, then a modified version
031         * of the key is returned (converted to upper case and enclosed in brackets).
032         *
033         * @param key
034         * @return localized message for key, or placeholder
035         */
036        String get(String key);
037    
038        /**
039         * Returns a formatter for the message, which can be used to substitute arguments (as per {@link
040         * java.util.Formatter}).
041         *
042         * @param key
043         * @return formattable object
044         */
045        MessageFormatter getFormatter(String key);
046    
047        /**
048         * Convienience for accessing a formatter and formatting a localized message with arguments.
049         */
050    
051        String format(String key, Object... args);
052    }