001/*
002 *                  BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 * Created on Aug 4, 2006
021 *
022 */
023package org.biojava.nbio.structure.align.util;
024
025import java.util.MissingResourceException;
026import java.util.ResourceBundle;
027
028
029
030/** A class that manages the Strings that are defined in the spice.properties file.
031 * This will be usefull for internationalisation.
032 *
033 * TODO: provide .properties files for other locales.
034 * e.g. jfatcat_de_DE.properties, etc.
035 *
036 * @author Andreas Prlic
037 * @since 1:43:04 PM
038 * @version %I% %G%
039 */
040public class ResourceManager {
041
042        private String BUNDLE_NAME ;
043
044        private ResourceBundle RESOURCE_BUNDLE ;
045
046
047        public ResourceManager() {
048                BUNDLE_NAME =  "jfatcat"; //$NON-NLS-1$;
049                RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
050        }
051
052        private ResourceManager(String bundleName){
053                try {
054                        RESOURCE_BUNDLE = ResourceBundle.getBundle(bundleName);
055                } catch(Exception e){
056                        e.printStackTrace();
057                }
058
059        }
060        public static ResourceManager getResourceManager(String bundleName){
061                return new ResourceManager(bundleName);
062        }
063
064        public String getString(String key) {
065
066                try {
067                        return RESOURCE_BUNDLE.getString(key);
068                } catch (MissingResourceException e) {
069                        System.err.println(e.getMessage());
070                        return '!' + key + '!';
071                }
072        }
073}