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.definition;
016    
017    import org.apache.hivemind.impl.MessageFormatter;
018    
019    /**
020     * Used to format messages used in errors and log output for classes within the definition package.
021     * 
022     * @author Achim Huegen
023     */
024    public class DefinitionMessages
025    {
026        private static final MessageFormatter _formatter = new MessageFormatter(DefinitionMessages.class,
027                "DefinitionStrings");
028        
029        public static String duplicateModuleId(String moduleId)
030        {
031            return _formatter.format(
032                    "duplicate-module-id",
033                    moduleId);
034        }
035    
036        public static String wrongNumberOfContributions(ModuleDefinition definingModule, ConfigurationPointDefinition point, int actualCount,
037                Occurances expectation)
038        {
039            return _formatter.format(
040                    "wrong-number-of-contributions",
041                    point.getQualifiedId(),
042                    contributionCount(actualCount),
043                    occurances(expectation));
044        }
045    
046        public static String duplicateServicePointId(String pointId, ModuleDefinition module)
047        {
048            return _formatter.format("duplicate-service-point", pointId, module.getId());
049        }
050    
051        public static String duplicateConfigurationPointId(String pointId, ModuleDefinition module)
052        {
053            return _formatter.format("duplicate-configuration-point", pointId, module.getId());
054        }
055    
056        public static String contributionCount(int count)
057        {
058            return _formatter.format("contribution-count", new Integer(count));
059        }
060    
061        public static String occurances(Occurances occurances)
062        {
063            return _formatter.getMessage("occurances." + occurances.getName());
064        }
065    
066        public static String dependencyOnUnknownModule(String toModuleId)
067        {
068            return _formatter.format("dependency-on-unknown-module", toModuleId);
069        }
070        
071        public static String unknownConfigurationPoint(String moduleId,
072                String configurationId)
073        {
074            return _formatter.format("unknown-configuration-extension-point", moduleId, configurationId);
075        }
076    
077        public static String unknownServicePoint(String moduleId, String pointId)
078        {
079            return _formatter.format(
080                    "unknown-service-extension-point",
081                    moduleId,
082                    pointId);
083        }
084    
085        public static String configurationPointNotVisible(ConfigurationPointDefinition point,
086                ModuleDefinition contributingModule)
087        {
088            return _formatter.format(
089                    "configuration-point-not-visible",
090                    point.getQualifiedId(),
091                    contributingModule.getId());
092        }
093    
094        public static String duplicateParserInputFormat(String inputFormat, ConfigurationPointDefinition cp)
095        {
096            return _formatter.format("duplicate-parser-inputformat", inputFormat, cp.getQualifiedId());
097        }
098    
099    
100        public static String servicePointNotVisible(ServicePointDefinition point, ModuleDefinition contributingModule)
101        {
102            return _formatter.format(
103                    "service-point-not-visible",
104                    point.getQualifiedId(),
105                    contributingModule.getId());
106        }
107        
108    }