com.sas.metadata.remote
Class MetadataResource

com.sas.metadata.remote.MetadataResource

public class MetadataResource

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
protected  boolean m_bResourceFileMissing
          have we already looked for the resource bundle for this package and didn't find it?
protected  java.util.ResourceBundle m_bundle
          The bundle needed for the given class used to create this object.
protected static java.util.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.
protected  java.lang.String m_strResourceFileName
          The caller told us the file to open.
 
Constructor Summary
MetadataResource(java.lang.Class source)
           
MetadataResource(java.lang.String strResourceFileName)
           
 
Method Summary
protected  java.util.ResourceBundle _getBundle(java.lang.String strBundlePath)
           
protected  void cacheBundle(java.lang.String key, java.util.ResourceBundle bundle)
           
protected  byte convertHexCharsToByte(byte leftChar, byte rightChar)
           
 byte[] convertHexStringToByteArray(java.lang.String strValue)
           
protected  java.util.ResourceBundle getCachedBundle(java.lang.String key)
           
 int getInt(java.lang.String key)
           
 int getInt(java.lang.String key, int notFoundReturnValue)
           
 java.util.Enumeration getKeys()
           
 java.lang.String getRawString(java.lang.String key)
           
 java.lang.String getString(java.lang.String key)
           
 java.lang.String messageString(java.lang.String key)
           
 java.lang.String messageString(java.lang.String key, java.lang.Object parm1)
           
 java.lang.String messageString(java.lang.String key, java.lang.Object parm1, java.lang.Object parm2)
           
 java.lang.String messageString(java.lang.String key, java.lang.Object parm1, java.lang.Object parm2, java.lang.Object parm3)
           
 java.lang.String messageString(java.lang.String key, java.lang.Object parm1, java.lang.Object parm2, java.lang.Object parm3, java.lang.Object parm4)
           
 java.lang.String messageString(java.lang.String key, java.lang.Object parm1, java.lang.Object parm2, java.lang.Object parm3, java.lang.Object parm4, java.lang.Object parm5)
           
 java.lang.String messageString(java.lang.String key, java.lang.Object parm1, java.lang.Object parm2, java.lang.Object parm3, java.lang.Object parm4, java.lang.Object parm5, java.lang.Object parm6)
           
 

Field Detail

m_bundleCache

protected static java.util.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 java.lang.String m_strResourceFileName
The caller told us the file to open.


m_bundle

protected java.util.ResourceBundle m_bundle
The bundle needed for the given class used to create this object.

Constructor Detail

MetadataResource

public MetadataResource(java.lang.String strResourceFileName)

MetadataResource

public MetadataResource(java.lang.Class source)
Method Detail

getCachedBundle

protected java.util.ResourceBundle getCachedBundle(java.lang.String key)

cacheBundle

protected void cacheBundle(java.lang.String key,
                           java.util.ResourceBundle bundle)

_getBundle

protected java.util.ResourceBundle _getBundle(java.lang.String strBundlePath)

getString

public java.lang.String getString(java.lang.String key)

getRawString

public java.lang.String getRawString(java.lang.String key)

getInt

public int getInt(java.lang.String key)

getInt

public int getInt(java.lang.String key,
                  int notFoundReturnValue)

convertHexStringToByteArray

public byte[] convertHexStringToByteArray(java.lang.String strValue)

convertHexCharsToByte

protected byte convertHexCharsToByte(byte leftChar,
                                     byte rightChar)

messageString

public java.lang.String messageString(java.lang.String key)

messageString

public java.lang.String messageString(java.lang.String key,
                                      java.lang.Object parm1)

messageString

public java.lang.String messageString(java.lang.String key,
                                      java.lang.Object parm1,
                                      java.lang.Object parm2)

messageString

public java.lang.String messageString(java.lang.String key,
                                      java.lang.Object parm1,
                                      java.lang.Object parm2,
                                      java.lang.Object parm3)

messageString

public java.lang.String messageString(java.lang.String key,
                                      java.lang.Object parm1,
                                      java.lang.Object parm2,
                                      java.lang.Object parm3,
                                      java.lang.Object parm4)

messageString

public java.lang.String messageString(java.lang.String key,
                                      java.lang.Object parm1,
                                      java.lang.Object parm2,
                                      java.lang.Object parm3,
                                      java.lang.Object parm4,
                                      java.lang.Object parm5)

messageString

public java.lang.String messageString(java.lang.String key,
                                      java.lang.Object parm1,
                                      java.lang.Object parm2,
                                      java.lang.Object parm3,
                                      java.lang.Object parm4,
                                      java.lang.Object parm5,
                                      java.lang.Object parm6)

getKeys

public java.util.Enumeration getKeys()



Copyright © 2009 SAS Institute Inc. All Rights Reserved.