Exemplo n.º 1
0
 /**
  * Used to return all of the Preferences used across the application. Preferences can then be
  * edited locally within the calling class.
  *
  * @return A new instance of Preferences to be used locally
  */
 public static Preferences getOdinPrefs() {
   // Obtain a logger to write progress to
   Logger log = LoggerFactory.getLogger("odin.odin.object.OdinPreferences");
   log.log(Level.FINEST, "Examining preferences to see if it's null or not.", prefsOdin);
   if (prefsOdin == null) {
     log.finest(
         "Preferences object was null, creating a new one from the default file (odin.prefs.xml).");
     try {
       // Obtain the FileInputStream for the central Preferences file
       BufferedInputStream bisXMLPrefs = new BufferedInputStream(new FileInputStream(sPrefsPath));
       // Providing the file isn't null then import the preferences
       if (bisXMLPrefs != null) {
         prefsOdin.importPreferences(bisXMLPrefs);
       }
     } catch (Exception x) {
       // If any errors are thrown then record them in the logger
       log.throwing("OdinPreferences", "getOdinPrefs()", x);
     }
   }
   // Obtain the Preferences for this class, this allows for everything to be centralised within
   // the file
   prefsOdin = Preferences.userNodeForPackage(OdinPreferences.class);
   // Return the Preferences to the receiver.
   return prefsOdin;
 }
Exemplo n.º 2
0
 /** Used to update any changes within the preferences to the main XML file. */
 public static void updateOdinPrefs() {
   // Obtain a logger to write progress to
   Logger log = LoggerFactory.getLogger("odin.odin.object.OdinPreferences");
   try {
     log.finest("Exporting preferences to file: " + sPrefsPath);
     // Record all of the preferences in the odin.prefs.xml file
     prefsOdin.exportNode(new FileOutputStream(sPrefsPath));
   } catch (Exception x) {
     // If an error was encountered during the update then write the details to the log
     log.throwing("OdinPreferences", "updateOdinPrefs()", x);
   }
 }