001    // Copyright 2004, 2005 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.hivemind;
016    
017    /**
018     * A set of localized message strings. This is somewhat like a {@link java.util.ResourceBundle},
019     * but with more flexibility about where the messages come from. In addition, it includes methods
020     * similar to {@link java.text.MessageFormat} for treating the messages as patterns.
021     * 
022     * @author Howard Lewis Ship
023     */
024    public interface Messages
025    {
026        /**
027         * Returns true if the given key is associated with a message, false otherwise.
028         * 
029         * @since 1.2
030         */
031        boolean containsMessage(String key);
032    
033        /**
034         * Searches for a localized string with the given key. If not found, a modified version of the
035         * key is returned (all upper-case and surrounded by square brackets).
036         */
037    
038        String getMessage(String key);
039    
040        /**
041         * Formats a string, using
042         * {@link java.text.MessageFormat#format(java.lang.String, java.lang.Object[])}.
043         * 
044         * @param key
045         *            the key used to obtain a localized pattern using {@link #getMessage(String)}
046         * @param arguments
047         *            passed to the formatter
048         */
049    
050        String format(String key, Object[] arguments);
051    
052        /**
053         * Convienience method for invoking {@link #format(String, Object[])}.
054         */
055        String format(String key, Object argument);
056    
057        /**
058         * Convienience method for invoking {@link #format(String, Object[])}.
059         */
060    
061        String format(String key, Object argument1, Object argument2);
062    
063        /**
064         * Convienience method for invoking {@link #format(String, Object[])}.
065         */
066        String format(String key, Object argument1, Object argument2, Object argument3);
067    }