home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 39 / IOPROG_39.ISO / SOFT / sdkjava40.exe / data1.cab / fg_Samples / Samples / afc11 / JNotepad / src / AppSettings.java < prev    next >
Encoding:
Java Source  |  2000-05-04  |  2.0 KB  |  74 lines

  1. //
  2. // (C) Copyright 1995 - 1999 Microsoft Corporation.  All rights reserved.
  3. //
  4.  
  5. /**
  6. *    Static abstract wrapper class for SettingsObject. If an application wants one
  7. *    copy of a SettingsObject that will be shared by all classes in the 
  8. *    application, they can use this class. AppSettings holds an instance
  9. *    of a SettingsObject, and classes can use a static method to obtain
  10. *    this object and manipulate it as necessary. Subclass this to return and
  11. *    manipulate whatever SettingsObject is appropriate for your application.
  12. *
  13. *    @version    1.0, 8/17/97
  14. *    @see        SettingsObject
  15. */
  16.  
  17. public abstract class AppSettings 
  18. {
  19.     /**
  20.     *    The application-wide SettingsObject
  21.     */
  22.     protected static SettingsObject settingsObj;
  23.     
  24.     
  25.     // NOTE: All classes that inherit from AppSettings should provide
  26.     // a getSettings() method that returns the right subclass of SettingsObject.
  27.     
  28.     /**
  29.     *    Public init function. Run this to have the SettingsObject created.
  30.     *    Override this in your subclass and create whatever subclass of SettingsObject
  31.     *    you need and assign it to settingsObj.
  32.     *    
  33.     *    @param    filename    Name of file to pass to the SettingsObject.
  34.     */
  35.     public static void init(String filename)
  36.     {
  37.         settingsObj = new SettingsObject(filename);
  38.     }
  39.     
  40.     /**
  41.     *    Loads the SettingsObject from disk. The file it loads from is the one
  42.     *    pass in init(). Calls the load() method in SettingsObject.
  43.     *
  44.     *    @see    SettingsObject#load
  45.     */
  46.     public static boolean load()
  47.     {
  48.         return settingsObj.load();                
  49.     }
  50.     
  51.     /**
  52.     *    Saves the SettingsObject to disk. The file it loads from is the one
  53.     *    pass in init().  Calls the save() method in SettingsObject.
  54.     *
  55.     *    @see    SettingsObject#save     
  56.     */
  57.     public static void save()
  58.     {
  59.         settingsObj.save();
  60.     }
  61.     
  62.     /**
  63.     *    Loads the default settings for the SettingsObject. Calls the loadDefaults()
  64.     *    method in SettingsObject.
  65.     *
  66.     *    @see    SettingsObject#loadDefaults     
  67.     */
  68.     public static void loadDefaults()
  69.     {
  70.         settingsObj.loadDefaults();
  71.     }
  72. }
  73.  
  74.