Package com.sas.metadata.remote
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
FieldsModifier and TypeFieldDescriptionprotected booleanhave we already looked for the resource bundle for this package and didn't find it?protected ResourceBundleThe bundle needed for the given class used to create this object.protected static HashtableOptimization so that all the classes in a package don't have to load a new copy of the same static resources.protected StringThe caller told us the file to open. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ResourceBundle_getBundle(String strBundlePath) protected voidcacheBundle(String key, ResourceBundle bundle) protected byteconvertHexCharsToByte(byte leftChar, byte rightChar) byte[]convertHexStringToByteArray(String strValue) protected ResourceBundlegetCachedBundle(String key) intgetInt(String key) intgetInt(String key, int notFoundReturnValue) EnumerationgetKeys()StringgetRawString(String key) StringgetString(String key) StringmessageString(String key) StringmessageString(String key, Object parm1) StringmessageString(String key, Object parm1, Object parm2) StringmessageString(String key, Object parm1, Object parm2, Object parm3) StringmessageString(String key, Object parm1, Object parm2, Object parm3, Object parm4) StringmessageString(String key, Object parm1, Object parm2, Object parm3, Object parm4, Object parm5) StringmessageString(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_bundleCacheOptimization 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_bResourceFileMissinghave we already looked for the resource bundle for this package and didn't find it? -
m_strResourceFileName
protected String m_strResourceFileNameThe caller told us the file to open. -
m_bundle
protected ResourceBundle m_bundleThe 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()
-