/** * This implementation eagerly fetches the Preferences instances * for the required system and user tree nodes. */ @Override public void afterPropertiesSet() { if (this.systemTreePath != null) { this.systemPrefs = this.systemPrefs.node(this.systemTreePath); } if (this.userTreePath != null) { this.userPrefs = this.userPrefs.node(this.userTreePath); } }
public static int getHistorySize() { return prefs.getInt(PREF_HISTORY_SIZE, DEFAULT_HISTORY_SIZE); } public static void setHistorySize(int historySize) { prefs.putInt(PREF_HISTORY_SIZE, historySize); }
public static boolean getMatchPortionOnly() { return prefs.getBoolean(PREF_MATCH_PORTION_ONLY, DEFAULT_MATCH_PORTION_ONLY); } public static void setMatchPortionOnly(boolean matchPortionOnly) { prefs.putBoolean(PREF_MATCH_PORTION_ONLY, matchPortionOnly); }
// Retrieve the user preference node for the package com.mycompany Preferences prefs = Preferences.userNodeForPackage(com.mycompany.MyClass.class); // Preference key name final String PREF_NAME = "name_of_preference"; // Set the value of the preference String newValue = "a string"; prefs.put(PREF_NAME, newValue); // Get the value of the preference; // default value is returned if the preference does not exist String defaultValue = "default string"; String propertyValue = prefs.get(PREF_NAME, defaultValue); // "a string"
private static void exportEntries(Preferences prefs, BufferedWriter out) throws BackingStoreException, IOException { String[] keys = prefs.keys(); String[] values = new String[keys.length]; for (int i = 0; i < keys.length; i++) { values[i] = prefs.get(keys[i], null); } exportEntries(keys, values, out); }
public static String getFont() { return prefs.get(PREF_FONT, DEFAULT_FONT); } public static void setFont(String font) { prefs.put(PREF_FONT, font); }
public static void setEncoding(String encoding) { prefs.put(PREF_ENCODING, encoding); }
private static void exportSubTree(Preferences prefs, BufferedWriter out) throws BackingStoreException, IOException { String[] names = prefs.childrenNames(); if (names.length > 0) { for (int i = 0; i < names.length; i++) { Preferences child = prefs.node(names[i]); flushStartTag("node", new String[] { "name" }, new String[] { names[i] }, out); exportEntries(child, out); exportSubTree(child, out); flushEndTag("node", out); } } }
public static void setHistorySize(int historySize) { prefs.putInt(PREF_HISTORY_SIZE, historySize); }
public static void setEnableTsurgeon(boolean enableTsurgeon) { prefs.putBoolean(PREF_ENABLE_TSURGEON, enableTsurgeon); }
public static String getEncoding() { return prefs.get(PREF_ENCODING, DEFAULT_ENCODING); } public static void setEncoding(String encoding) { prefs.put(PREF_ENCODING, encoding); }
public static void setFont(String font) { prefs.put(PREF_FONT, font); }
public static int getMaxMatches() { return prefs.getInt(PREF_MAX_MATCHES, DEFAULT_MAX_MATCHES); } public static void setMaxMatches(int maxMatches) { prefs.putInt(PREF_MAX_MATCHES, maxMatches); }
public static boolean getEnableTsurgeon() { return prefs.getBoolean(PREF_ENABLE_TSURGEON, DEFAULT_ENABLE_TSURGEON); } public static void setEnableTsurgeon(boolean enableTsurgeon) { prefs.putBoolean(PREF_ENABLE_TSURGEON, enableTsurgeon); }
public static void setMaxMatches(int maxMatches) { prefs.putInt(PREF_MAX_MATCHES, maxMatches); }
public static void setMatchPortionOnly(boolean matchPortionOnly) { prefs.putBoolean(PREF_MATCH_PORTION_ONLY, matchPortionOnly); }
/** * This implementation eagerly fetches the Preferences instances * for the required system and user tree nodes. */ @Override public void afterPropertiesSet() { if (this.systemTreePath != null) { this.systemPrefs = this.systemPrefs.node(this.systemTreePath); } if (this.userTreePath != null) { this.userPrefs = this.userPrefs.node(this.userTreePath); } }
public static int getFontSize() { return prefs.getInt(PREF_FONT_SIZE, DEFAULT_FONT_SIZE); } public static void setFontSize(int fontSize) { prefs.putInt(PREF_FONT_SIZE, fontSize); }
public static void setFontSize(int fontSize) { prefs.putInt(PREF_FONT_SIZE, fontSize); }