FileDocCategorySizeDatePackage
LocalStringsManager.javaAPI DocGlassfish v2 API6022Fri May 04 22:25:20 BST 2007com.sun.enterprise.cli.framework

LocalStringsManager

public class LocalStringsManager extends Object
author
pa100654

Fields Summary
private final String
packageName
private final String
propertyFile
private final Vector
resourceBundles
public static final String
DEFAULT_STRING_VALUE
Constructors Summary
public LocalStringsManager(String packageNameIn, String propertyFileIn)
Creates a new instance of LocalStringsManager


           
         
    
        this.packageName = packageNameIn;
        this.propertyFile = propertyFileIn;
        ResourceBundle resourceBundle = 
                ResourceBundle.getBundle(packageNameIn + "." + propertyFile);
        resourceBundles.add(resourceBundle);
    
public LocalStringsManager(Vector localizePropertiesList)
Creates a new instance of LocalStringsManager from the properties Vector

        this.packageName    = null;
        this.propertyFile   = null;
        
        for (int i = 0; i < localizePropertiesList.size(); i++)
        {
            Properties properties = localizePropertiesList.get(i);
            String packageNameStr = (String) properties.get("base-package");
            String propertyFileStr = (String) properties.get("property-file-name");
            ResourceBundle resourceBundle = 
                ResourceBundle.getBundle(packageNameStr + "." + propertyFileStr);
            resourceBundles.add(resourceBundle);
        }
    
public LocalStringsManager(Vector localizeStringList, Locale locale)
Creates a new instance of LocalStringsManager from the properties Vector of Strings and locale

        this.packageName    = null;
        this.propertyFile   = null;
        
        for (int i = 0; i < localizeStringList.size(); i++)
        {
            ResourceBundle resourceBundle = 
                ResourceBundle.getBundle(localizeStringList.get(i),
                                         locale);
            resourceBundles.add(resourceBundle);
        }
    
Methods Summary
public java.lang.StringgetPackageName()

        return packageName;
    
public java.lang.StringgetPropertiesFile()

        return propertyFile;
    
public java.util.VectorgetResourceBundles()

        return resourceBundles;
    
public java.lang.StringgetString(java.lang.String key)

        Iterator resourcesIter = resourceBundles.iterator();
        String value = DEFAULT_STRING_VALUE + " (" + key + ")";
        while (resourcesIter.hasNext())
        {
            ResourceBundle resourceBundle = (ResourceBundle)resourcesIter.next();
            try
            {
                value = resourceBundle.getString(key);
                break;
            }
            catch (MissingResourceException mre)
            {
                // if not found, try next resource bundle in the iterator
            }
        }
        return value;
    
public java.lang.StringgetString(java.lang.String key, java.lang.Object[] toInsert)

        String fmtStr = null;
        try
        {
            MessageFormat msgFormat = 
                            new MessageFormat(getString(key));
            fmtStr = msgFormat.format(toInsert);
        }
        catch(Exception e)
        {
            throw new CommandValidationException(e);
        }
        return fmtStr;