001    package org.apache.archiva.converter.artifact;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one
005     * or more contributor license agreements.  See the NOTICE file
006     * distributed with this work for additional information
007     * regarding copyright ownership.  The ASF licenses this file
008     * to you under the Apache License, Version 2.0 (the
009     * "License"); you may not use this file except in compliance
010     * with the License.  You may obtain a copy of the License at
011     *
012     *  http://www.apache.org/licenses/LICENSE-2.0
013     *
014     * Unless required by applicable law or agreed to in writing,
015     * software distributed under the License is distributed on an
016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017     * KIND, either express or implied.  See the License for the
018     * specific language governing permissions and limitations
019     * under the License.
020     */
021    
022    import java.text.MessageFormat;
023    import java.util.MissingResourceException;
024    import java.util.ResourceBundle;
025    
026    /**
027     * Messages 
028     *
029     *
030     */
031    public class Messages
032    {
033        private static final String BUNDLE_NAME = "org.apache.archiva.converter.artifact.messages"; //$NON-NLS-1$
034    
035        private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
036    
037        private Messages()
038        {
039            // no op
040        }
041    
042        public static String getString( String key )
043        {
044            try
045            {
046                return RESOURCE_BUNDLE.getString( key );
047            }
048            catch ( MissingResourceException e )
049            {
050                return '!' + key + '!';
051            }
052        }
053        
054        public static String getString( String key, Object argument )
055        {
056            return getString( key, new Object[] { argument } );
057        }
058        
059        public static String getString( String key, Object arguments[] )
060        {
061            try
062            {
063                String pattern = RESOURCE_BUNDLE.getString( key );
064                return MessageFormat.format( pattern, arguments );
065            }
066            catch ( MissingResourceException e )
067            {
068                return '!' + key + '!';
069            }
070        }
071    }