Package java.util.prefs

Examples of java.util.prefs.Preferences


      public X509Certificate[] getAcceptedIssuers() {
        return new X509Certificate[0];
      }
    }
    // Hack to get Base64-encoded credentials
    Preferences tempNode = Preferences.userRoot().node("xxx");
    tempNode.putByteArray("xxx", url.getUserInfo().getBytes());
    String authInfo = tempNode.get("xxx", null);
    tempNode.removeNode();
    //
    sslContext.init(null, new TrustManager[] { new TrustEveryone() }, null);
    HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
//    HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
    urlConnection.setRequestProperty("User-Agent", "jhg/0.1.0");
View Full Code Here


  private String buildAuthValue(String username, String password) {
    String ai = null;
    try {
      // Hack to get Base64-encoded credentials
      Preferences tempNode = Preferences.userRoot().node("xxx");
      tempNode.putByteArray("xxx", String.format("%s:%s", username, password).getBytes());
      ai = tempNode.get("xxx", null);
      tempNode.removeNode();
    } catch (BackingStoreException ex) {
      ctx.getLog().dump(getClass(), Info, ex, null);
      // IGNORE
    }
    return ai;
View Full Code Here

        }
        return uniqueInstance;
    }

    public void store() {
        Preferences prefs = NbPreferences.forModule(DummyCorePreference.class);
        prefs.put("separatorJS", separatorJS != null ? separatorJS.toString() : null);
        prefs.put("separatorCSS", separatorCSS != null ? separatorCSS.toString() : null);
        prefs.put("separatorHTML", separatorHTML != null ? separatorHTML.toString() : null);
        prefs.put("separatorXML", getSeparatorXML() != null ? getSeparatorXML().toString() : null);
        prefs.put("separatorJSON", getSeparatorJSON() != null ? getSeparatorJSON().toString() : null);

        Class<?> clazz = this.getClass();

        for (Field field : clazz.getDeclaredFields()) {
            if (field.getType() == boolean.class) {
                try {
                    prefs.putBoolean(field.getName(), field.getBoolean(this));
                } catch (IllegalArgumentException ex) {
                    Exceptions.printStackTrace(ex);
                } catch (IllegalAccessException ex) {
                    Exceptions.printStackTrace(ex);
                }
            } else if (field.getType() == String.class) {
                try {
                    prefs.put(field.getName(), (String) field.get(this));
                } catch (IllegalArgumentException ex) {
                    Exceptions.printStackTrace(ex);
                } catch (IllegalAccessException ex) {
                    Exceptions.printStackTrace(ex);
                }
            } else if (field.getType() == int.class) {
                try {
                    prefs.putInt(field.getName(), field.getInt(this));
                } catch (IllegalArgumentException ex) {
                    Exceptions.printStackTrace(ex);
                } catch (IllegalAccessException ex) {
                    Exceptions.printStackTrace(ex);
                }
View Full Code Here

        }

    }

    public void load() {
        Preferences prefs = NbPreferences.forModule(DummyCorePreference.class);
        Class<?> clazz = this.getClass();
        separatorJS = prefs.get("separatorJS", separatorJS.toString()).toCharArray()[0];
        separatorCSS = prefs.get("separatorCSS", separatorCSS.toString()).toCharArray()[0];
        separatorHTML = prefs.get("separatorHTML", separatorHTML.toString()).toCharArray()[0];
        setSeparatorXML((Character) prefs.get("separatorXML", getSeparatorXML().toString()).toCharArray()[0]);
        setSeparatorJSON((Character) prefs.get("separatorJSON", getSeparatorJSON().toString()).toCharArray()[0]);

        for (Field field : clazz.getDeclaredFields()) {
            if (field.getType() == boolean.class) {
                try {
                    field.setBoolean(this, prefs.getBoolean(field.getName(), field.getBoolean(this)));
                } catch (IllegalArgumentException ex) {
                    Exceptions.printStackTrace(ex);
                } catch (IllegalAccessException ex) {
                    Exceptions.printStackTrace(ex);
                }
            } else if (field.getType() == String.class) {
                try {
                    field.set(this, prefs.get(field.getName(), (String) field.get(this)));
                } catch (IllegalArgumentException ex) {
                    Exceptions.printStackTrace(ex);
                } catch (IllegalAccessException ex) {
                    Exceptions.printStackTrace(ex);
                }
            } else if (field.getType() == int.class) {
                try {
                    prefs.putInt(field.getName(), field.getInt(this));
                    field.setInt(this, prefs.getInt(field.getName(), field.getInt(this)));
                } catch (IllegalArgumentException ex) {
                    Exceptions.printStackTrace(ex);
                } catch (IllegalAccessException ex) {
                    Exceptions.printStackTrace(ex);
                }
View Full Code Here

    }

    public static void clearUserPrefs(final String nodeName,
            final String variableName) {
        if (nodeName != null && variableName != null) {
            Preferences prefs = Preferences.userRoot().node(nodeName);
            prefs.remove(variableName);

        }
    }
View Full Code Here

        }
    }

    public static void setSystemPrefArray(final String nodeName,
            final String variableName, final String[] array) {
        Preferences prefs = Preferences.systemRoot().node(nodeName);
        prefs.put(variableName, arrayToString(array));

    }
View Full Code Here

    }

    public static List<String> getPreferenceList(final String nodeName,
            final String variableName) {
        Preferences prefs = Preferences.userRoot().node(nodeName);
        String value = prefs.get(variableName, "");
        if (value.length() != 0) {
            return stringToList(value);
        }
        prefs = Preferences.systemRoot().node(nodeName);
        value = prefs.get(variableName, "");
        if (value.length() != 0) {
            return stringToList(value);
        }
        return null;
    }
View Full Code Here

        return null;
    }

    public static List<String> getSystemList(final String nodeName,
            final String variableName) {
        Preferences prefs = Preferences.systemRoot().node(nodeName);
        String value = prefs.get(variableName, "");
        if (value.length() != 0) {
            return stringToList(value);
        }
        return null;
    }
View Full Code Here

        }
        return redirectUri;
    }

    private long dontWarnAgainUntil() {
        Preferences prefs = Preferences.userNodeForPackage(UpdateChecker.class);

        String oldSeen = prefs.get("last-plugin-update-seen", "");
        if (oldSeen == null || oldSeen.equals("")) {
            return 0;
        }
        try {
            return Long.parseLong(oldSeen) + DONT_REMIND_WINDOW;
View Full Code Here

        }
    }
    static final long DONT_REMIND_WINDOW = 3L*24*60*60*1000;
    public boolean updatesHaveBeenSeenBefore(Collection<UpdateChecker.PluginUpdate> updates) {
        long now = System.currentTimeMillis();
        Preferences prefs = Preferences.userNodeForPackage(UpdateChecker.class);
        String oldHash = prefs.get("last-plugin-update-hash", "");

        String newHash = Integer.toString(buildPluginUpdateHash(updates));
        if (oldHash.equals(newHash) && dontWarnAgainUntil() > now) {
            LOGGER.fine("Skipping update dialog because these updates have been seen before");
            return true;
        }
        prefs.put("last-plugin-update-hash", newHash);
        prefs.put("last-plugin-update-seen", Long.toString(now));
        return false;
    }
View Full Code Here

TOP

Related Classes of java.util.prefs.Preferences

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.