static void setPreference()

in src/main/java/org/apache/sling/reqanalyzer/impl/gui/Util.java [112:140]


    static void setPreference(final String name, final Object value, final boolean flush) {
        Preferences prefs = getPreferences();
        try {
            prefs.sync();
            if (value instanceof Long) {
                prefs.putLong(name, (Long) value);
            } else if (value instanceof Integer) {
                prefs.putInt(name, (Integer) value);
            } else if (value instanceof int[]) {
                String string = null;
                for (int val : (int[]) value) {
                    if (string == null) {
                        string = String.valueOf(val);
                    } else {
                        string += "," + val;
                    }
                }
                prefs.put(name, string);
            } else if (value != null) {
                prefs.put(name, value.toString());
            }

            if (flush) {
                prefs.flush();
            }
        } catch (BackingStoreException ioe) {
            // ignore
        }
    }