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    import org.apache.hivemind.impl.MessageFormatter;
018    import org.apache.hivemind.service.ClassFabUtils;
019    
020    /**
021     * Used to format general-purpose messages used in code within HiveMind.
022     * 
023     * @author Howard Lewis Ship
024     */
025    public class HiveMindMessages
026    {
027        protected static MessageFormatter _formatter = new MessageFormatter(HiveMindMessages.class);
028    
029        public static String unimplementedMethod(Object instance, String methodName)
030        {
031            return _formatter.format("unimplemented-method", instance.getClass().getName(), methodName);
032        }
033    
034        public static String registryShutdown()
035        {
036            return _formatter.getMessage("registry-shutdown");
037        }
038    
039        public static String unknownLocation()
040        {
041            return _formatter.getMessage("unknown-location");
042        }
043    
044        /** @since 1.1 */
045        public static String paramNotNull(String parameterName)
046        {
047            return _formatter.format("param-not-null", parameterName);
048        }
049        
050        public static String fieldNotNull(String fieldName)
051        {
052            return _formatter.format("field-not-null", fieldName);
053        }
054    
055        /** @since 1.1 */
056        public static String paramWrongType(String parameterName, Object parameter, Class expectedType)
057        {
058            return _formatter.format("param-wrong-type", parameterName, ClassFabUtils
059                    .getJavaClassName(parameter.getClass()), ClassFabUtils
060                    .getJavaClassName(expectedType));
061        }
062    }