home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / Main.bin / ResourceBundleAdapter.java < prev    next >
Text File  |  1998-10-03  |  2KB  |  101 lines

  1. package com.symantec.itools.util;
  2.  
  3.  
  4. import java.util.Enumeration;
  5. import java.util.MissingResourceException;
  6. import java.util.ResourceBundle;
  7.  
  8.  
  9. public class ResourceBundleAdapter
  10. {
  11.     protected ResourceBundle bundle;
  12.     
  13.     public ResourceBundleAdapter(ResourceBundle b)
  14.     {
  15.         bundle = b;
  16.     }
  17.     
  18.     public Enumeration getKeys()
  19.     {
  20.         return (bundle.getKeys());
  21.     }
  22.     
  23.     public Object getObject(String key)
  24.     {
  25.         return (getObject(key, null));
  26.     }
  27.     
  28.     public Object getObject(String key, Object defaultValue)
  29.     {
  30.         try
  31.         {
  32.             return (bundle.getObject(key));
  33.         }
  34.         catch(MissingResourceException ex)
  35.         {
  36.         }
  37.         
  38.         return (defaultValue);
  39.     }
  40.     
  41.     public String getString(String key)
  42.     {
  43.         return (getString(key, null));
  44.     }
  45.     
  46.     public String getString(String key, String defaultValue)
  47.     {
  48.         try
  49.         {
  50.             return (bundle.getString(key));
  51.         }
  52.         catch(MissingResourceException ex)
  53.         {
  54.         }
  55.         
  56.         return (defaultValue);
  57.     }
  58.     
  59.     public String[] getStringArray(String key)
  60.     {
  61.         return (getStringArray(key, null));
  62.     }
  63.     
  64.     public String[] getStringArray(String key, String[] defaultValue)
  65.     {
  66.         try
  67.         {
  68.             return (bundle.getStringArray(key));
  69.         }
  70.         catch(MissingResourceException ex)
  71.         {
  72.         }
  73.         
  74.         return (defaultValue);
  75.     }
  76.     
  77.     public char getChar(String key)
  78.     {
  79.         return (getChar(key, (char)0));
  80.     }
  81.     
  82.     public char getChar(String key, char defaultValue)
  83.     {
  84.         try
  85.         {
  86.             String str;
  87.             
  88.             str = bundle.getString(key);
  89.             
  90.             if(str.length() > 0)
  91.             {
  92.                 return (str.charAt(0));
  93.             }
  94.         }
  95.         catch(MissingResourceException ex)
  96.         {
  97.         }
  98.         
  99.         return (defaultValue);
  100.     }
  101. }