Class MetadataResource

java.lang.Object
com.sas.metadata.remote.MetadataResource

public class MetadataResource extends Object
Each package has a standard set of resources named PropertyBundle. These resources can be string values, integers, boolean, or even images. A compiled java file is used to store these resources. ResourceBundle is the standard Java mechanism used for this purpose. We wrap some nice helper methods to ease the conversion of data into usable values. Example usage: ( normally you just need to pass the current class to the constructor so the correct package can be used. )
                static MetadataResource bundle = new MetadataResource(  "com.sas.metadata"  );
                ...
                cancelButton = new JButton( bundle.getString("Common.Cancel.txt") );
 
Or If needed a specific resource class can be used (if you use this feature you probably should create a new package):

                static WAdminResource bundle = new WAdminResource();
                ...
                bundle.load( "com.sas.metadata.FilterEditDialogResourceBundle" );
                ...
                cancelButton = new JButton( bundle.getString("Common.Cancel.txt") );
 
Helper routines in this module:

 Constructor for using the default file for this package.
 @param String Package name, ie "com.sas.metadata".
        public WAdminResource( String strResourceFileName )

 Prefered constructor, using the default resource bundle file of
 the package the class resides in.
 @param Class used to get the package for loading a PropertyBundle class.
      public MetadataResource( Class source )

 Returns a string based on the given key value. "Missing resource" is
 returned if the key is not present in the resource file.
        public String getString( String key )

 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    have we already looked for the resource bundle for this package and didn't find it?
    protected ResourceBundle
    The bundle needed for the given class used to create this object.
    protected static Hashtable
    Optimization so that all the classes in a package don't have to load a new copy of the same static resources.
    protected String
    The caller told us the file to open.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MetadataResource(Class source)
     
    MetadataResource(String strResourceFileName)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected ResourceBundle
    _getBundle(String strBundlePath)
     
    protected void
    cacheBundle(String key, ResourceBundle bundle)
     
    protected byte
    convertHexCharsToByte(byte leftChar, byte rightChar)
     
    byte[]
    convertHexStringToByteArray(String strValue)
     
    protected ResourceBundle
    getCachedBundle(String key)
     
    int
    getInt(String key)
     
    int
    getInt(String key, int notFoundReturnValue)
     
    Enumeration
     
    String
    getRawString(String key)
     
    String
    getString(String key)
     
    String
    messageString(String key)
     
    String
    messageString(String key, Object parm1)
     
    String
    messageString(String key, Object parm1, Object parm2)
     
    String
    messageString(String key, Object parm1, Object parm2, Object parm3)
     
    String
    messageString(String key, Object parm1, Object parm2, Object parm3, Object parm4)
     
    String
    messageString(String key, Object parm1, Object parm2, Object parm3, Object parm4, Object parm5)
     
    String
    messageString(String key, Object parm1, Object parm2, Object parm3, Object parm4, Object parm5, Object parm6)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • m_bundleCache

      protected static Hashtable m_bundleCache
      Optimization so that all the classes in a package don't have to load a new copy of the same static resources.
    • m_bResourceFileMissing

      protected boolean m_bResourceFileMissing
      have we already looked for the resource bundle for this package and didn't find it?
    • m_strResourceFileName

      protected String m_strResourceFileName
      The caller told us the file to open.
    • m_bundle

      protected ResourceBundle m_bundle
      The bundle needed for the given class used to create this object.
  • Constructor Details

    • MetadataResource

      public MetadataResource(String strResourceFileName)
    • MetadataResource

      public MetadataResource(Class source)
  • Method Details

    • getCachedBundle

      protected ResourceBundle getCachedBundle(String key)
    • cacheBundle

      protected void cacheBundle(String key, ResourceBundle bundle)
    • _getBundle

      protected ResourceBundle _getBundle(String strBundlePath)
    • getString

      public String getString(String key)
    • getRawString

      public String getRawString(String key)
    • getInt

      public int getInt(String key)
    • getInt

      public int getInt(String key, int notFoundReturnValue)
    • convertHexStringToByteArray

      public byte[] convertHexStringToByteArray(String strValue)
    • convertHexCharsToByte

      protected byte convertHexCharsToByte(byte leftChar, byte rightChar)
    • messageString

      public String messageString(String key)
    • messageString

      public String messageString(String key, Object parm1)
    • messageString

      public String messageString(String key, Object parm1, Object parm2)
    • messageString

      public String messageString(String key, Object parm1, Object parm2, Object parm3)
    • messageString

      public String messageString(String key, Object parm1, Object parm2, Object parm3, Object parm4)
    • messageString

      public String messageString(String key, Object parm1, Object parm2, Object parm3, Object parm4, Object parm5)
    • messageString

      public String messageString(String key, Object parm1, Object parm2, Object parm3, Object parm4, Object parm5, Object parm6)
    • getKeys

      public Enumeration getKeys()