/** * Resolve the given path and key against the given Preferences. * @param path the preferences path (placeholder part before '/') * @param key the preferences key (placeholder part after '/') * @param preferences the Preferences to resolve against * @return the value for the placeholder, or {@code null} if none found */ @Nullable protected String resolvePlaceholder(@Nullable String path, String key, Preferences preferences) { if (path != null) { // Do not create the node if it does not exist... try { if (preferences.nodeExists(path)) { return preferences.node(path).get(key, null); } else { return null; } } catch (BackingStoreException ex) { throw new BeanDefinitionStoreException("Cannot access specified node path [" + path + "]", ex); } } else { return preferences.get(key, null); } }
/** * Resolve the given path and key against the given Preferences. * @param path the preferences path (placeholder part before '/') * @param key the preferences key (placeholder part after '/') * @param preferences the Preferences to resolve against * @return the value for the placeholder, or {@code null} if none found */ @Nullable protected String resolvePlaceholder(@Nullable String path, String key, Preferences preferences) { if (path != null) { // Do not create the node if it does not exist... try { if (preferences.nodeExists(path)) { return preferences.node(path).get(key, null); } else { return null; } } catch (BackingStoreException ex) { throw new BeanDefinitionStoreException("Cannot access specified node path [" + path + "]", ex); } } else { return preferences.get(key, null); } }
/** * Retrieves data about he window settings from the previous session and applies * them to the stage. These settings include window size, position and if * it was maximized or not. * * @param stage the stage to apply these settings to * @param name the name under which we stored the settings */ public static void applyStoredDisplaySettings(Stage stage, String name){ try { if( PREFERENCES.nodeExists(name) ){ Preferences stagePreferences = PREFERENCES.node(name); boolean wasMaximized = stagePreferences.getBoolean(WINDOW_MAXIMIZED, false); if( wasMaximized ){ stage.setMaximized(true); } else { stage.setX( stagePreferences.getDouble(WINDOW_X_POS, DEFUALT_X)); stage.setY( stagePreferences.getDouble(WINDOW_Y_POS, DEFUALT_Y)); stage.setWidth( stagePreferences.getDouble(WINDOW_WIDTH, DEFUALT_WIDTH)); stage.setHeight(stagePreferences.getDouble(WINDOW_HEIGHT, DEFUALT_HEIHGT)); } } } catch (BackingStoreException ex) { LOGGER.error(ex, "Could not access preferences for window " + name); } }
public String getPref(String section, String key) { try { if (prefs.nodeExists(section)) return prefs.node(section).get(key, null); } catch (BackingStoreException e) { e.printStackTrace(); } return null; }
/** * Resolve the given path and key against the given Preferences. * @param path the preferences path (placeholder part before '/') * @param key the preferences key (placeholder part after '/') * @param preferences the Preferences to resolve against * @return the value for the placeholder, or <code>null</code> if none found */ protected String resolvePlaceholder(String path, String key, Preferences preferences) { if (path != null) { // Do not create the node if it does not exist... try { if (preferences.nodeExists(path)) { return preferences.node(path).get(key, null); } else { return null; } } catch (BackingStoreException ex) { throw new BeanDefinitionStoreException("Cannot access specified node path [" + path + "]", ex); } } else { return preferences.get(key, null); } }
nodeName = nodeName.substring("system:".length()); try { preferencesNode = preferencesNode.nodeExists(nodeName) ? preferencesNode.node(nodeName) : null; } catch (BackingStoreException ex) { preferencesNode = null; nodeName = nodeName.substring("user:".length()); try { preferencesNode = preferencesNode.nodeExists(nodeName) ? preferencesNode.node(nodeName) : null; } catch (BackingStoreException ex) { preferencesNode = null; if (preferencesNode != null) { try { preferencesNode = preferencesNode.nodeExists(nodeName) ? preferencesNode.node(nodeName) : null; } catch (BackingStoreException ex) { preferencesNode = null;
@Override public boolean nodeExists(String pathName) throws BackingStoreException { return actualPreferences.nodeExists(pathName); }
private java.util.prefs.Preferences getList(String listKey, boolean create) { try { if (create || preferences.nodeExists(listKey)){ return preferences.node(listKey); } } catch (BackingStoreException e) { throw new RuntimeException(e); } return null; }
private java.util.prefs.Preferences getList(String listKey, boolean create) { try { if (create || preferences.nodeExists(listKey)){ return preferences.node(listKey); } } catch (BackingStoreException e) { throw new RuntimeException(e); } return null; }
private java.util.prefs.Preferences getList(String listKey, boolean create) { try { if (create || preferences.nodeExists(listKey)){ return preferences.node(listKey); } } catch (BackingStoreException e) { throw new RuntimeException(e); } return null; }
@Override public void setScope(TaskScanningScope scope, Callback callback) { try { // XXX make Installer.active into API if (!NbPreferences.root().nodeExists("org/netbeans/modules/hudson/instances")) { return; // avoid loading any more classes } } catch (BackingStoreException x) { LOG.log(Level.INFO, null, x); } doSetScope(scope, callback); } // in a separate method to avoid resolving anything else if shortcut above is used
SuggestionProvider(Preferences preferences) { try { if (preferences.nodeExists(NAME)) { preferences = preferences.node(NAME); } } catch (BackingStoreException ex) { } if (preferences.absolutePath().endsWith("/"+NAME)) { //NOI18N myPreferences = new AuditPreferences(preferences); } else { myPreferences = new AuditPreferences(preferences.node(NAME)); } }
/** @see java.util.prefs.Preferences#nodeExists(String) */ public boolean nodeExists(final String pathName) { try { return p.nodeExists(safeName(pathName)); } catch (final java.util.prefs.BackingStoreException exc) { if (log != null) log.error(exc); return false; } }
/** @see java.util.prefs.Preferences#nodeExists(String) */ public boolean nodeExists(final String pathName) { try { return p.nodeExists(safeName(pathName)); } catch (final java.util.prefs.BackingStoreException exc) { if (log != null) log.error(exc); return false; } }
JavaStorage(Log log, String storageFileName) { this.log = log; Preferences prefs = null; try { isPersisted = Preferences.userRoot().nodeExists(storageFileName); prefs = Preferences.userRoot().node(storageFileName); } catch (Exception e) { log.warn("Couldn't open Preferences: " + e.getMessage()); isPersisted = false; prefs = new MemoryPreferences(); } preferences = prefs; }
JavaStorage(Log log, String storageFileName) { this.log = log; Preferences prefs = null; try { isPersisted = Preferences.userRoot().nodeExists(storageFileName); prefs = Preferences.userRoot().node(storageFileName); } catch (Exception e) { log.warn("Couldn't open Preferences: " + e.getMessage()); isPersisted = false; prefs = new MemoryPreferences(); } preferences = prefs; }
JavaStorage(JavaPlatform platform, JavaPlatform.Config config) { this.platform = platform; Preferences prefs = null; try { isPersisted = Preferences.userRoot().nodeExists(config.storageFileName); prefs = Preferences.userRoot().node(config.storageFileName); } catch (Exception e) { platform.log().warn("Couldn't open Preferences: " + e.getMessage()); isPersisted = false; prefs = new MemoryPreferences(); } preferences = prefs; }
JavaStorage(JavaPlatform platform, JavaPlatform.Config config) { this.platform = platform; Preferences prefs = null; try { isPersisted = Preferences.userRoot().nodeExists(config.storageFileName); prefs = Preferences.userRoot().node(config.storageFileName); } catch (Exception e) { platform.log().warn("Couldn't open Preferences: " + e.getMessage()); isPersisted = false; prefs = new MemoryPreferences(); } preferences = prefs; }
@Override public String versionOf( EntityStoreUnitOfWork unitOfWork, EntityReference reference ) { try { if( !root.nodeExists( reference.identity().toString() ) ) { throw new NoSuchEntityException( reference, UnknownType.class, unitOfWork.usecase() ); } Preferences entityPrefs = root.node( reference.identity().toString() ); return entityPrefs.get( "version", "" ); } catch( BackingStoreException e ) { throw new EntityStoreException( e ); } }
@Override public boolean nodeExists(final String... nodes) { try { return this.preferences.nodeExists(new PathFactory().create(nodes)); } catch (final BackingStoreException exception) { logger.log(ILevel.DEBUG, exception.getMessage()); logger.log(ILevel.ALL, exception.getMessage(), exception); return false; } }