home *** CD-ROM | disk | FTP | other *** search
-
- package com.symantec.itools.swing;
-
- import java.util.ResourceBundle;
- import java.util.ListResourceBundle;
- import com.symantec.itools.swing.DateMaskResourceBundle;
-
- /**
- * <P>This class loads the Resource.
- * <P>It implements the Singleton Design Pattern.
- *
- * @version 1.0
- * @author Symantec
- * @see java.util.ResourceBundle
- * @see java.util.ListResourceBundle
- */
- public final class DateMaskResourceLoader {
-
- //////////////////////////////////////////////////
- // Singleton pattern implementation - BEGIN //
- //////////////////////////////////////////////////
-
- //
- // Class variables
- //
- private static DateMaskResourceLoader instance = null;
-
- //
- // Instance variables
- //
- private ResourceBundle bundle = null;
-
- public static synchronized DateMaskResourceLoader getInstance() {
- if( instance == null ) {
- instance = new DateMaskResourceLoader();
- }
- return instance;
- }
-
- private DateMaskResourceLoader() {
- super();
-
- try {
- // Try to load the resource bundle
- bundle = ResourceBundle.getBundle(
- "com.symantec.itools.swing.DateMaskResourceBundle");
- }
- catch( java.util.MissingResourceException ex ) {
- System.err.println(
- "Could not load [com.symantec.itools.swing.DateMaskResourceBundle]\n"
- + ex);
- }
- }
-
- ////////////////////////////////////////////////
- // Singleton pattern implementation - END //
- ////////////////////////////////////////////////
-
- /**
- * This method is the same as:
- * <code>java.util.ResourceBundle.getBundle("com.symantec.itools.swing.DateMaskResourceBundle"))</code>
- * Unfortunately we cannot override getBundle() - it is final.
- * Everywhere where you need to load Resource use this:
- * <code>DateMaskResourceLoader.getBundle()</code>
- * It prevents from loading the same resource file multiple times.
- * The usage of the resource remains the same:
- * <code>MyResource.getString()</code> - MyResource is the reference that is in your code
- */
- public ResourceBundle getBundle() {
- return bundle;
- }
-
-
- // main() is provided here ONLY for testing puposes
- public static void main(String[] args) {
- DateMaskResourceLoader inst = getInstance();
- inst.getBundle();
- }
- }
-