List of usage examples for java.util.prefs Preferences absolutePath
public abstract String absolutePath();
From source file:Main.java
public static void main(String args[]) throws Exception { Preferences prefsRoot = Preferences.userRoot(); Preferences myPrefs = prefsRoot.node("PreferenceExample"); myPrefs.put("A", "a"); myPrefs.put("B", "b"); myPrefs.put("C", "c"); System.out.println("Node's absolute path: " + myPrefs.absolutePath()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { // Get the system root Preferences prefs = Preferences.systemRoot(); // Get the user root prefs = Preferences.userRoot(); // The name of a root is "" String name = prefs.name();// w w w .ja v a2 s . c o m // The parent of a root is null Preferences parent = prefs.parent(); // The absolute path of a root is "/" String path = prefs.absolutePath(); }
From source file:PreferenceExample.java
public void printInformation(Preferences p) throws BackingStoreException { System.out.println("Node's absolute path: " + p.absolutePath()); System.out.print("Node's children: "); for (String s : p.childrenNames()) { System.out.print(s + " "); }// w ww . j a v a 2 s. c om System.out.println(""); System.out.print("Node's keys: "); for (String s : p.keys()) { System.out.print(s + " "); } System.out.println(""); System.out.println("Node's name: " + p.name()); System.out.println("Node's parent: " + p.parent()); System.out.println("NODE: " + p); System.out.println("userNodeForPackage: " + Preferences.userNodeForPackage(PreferenceExample.class)); System.out.println("All information in node"); for (String s : p.keys()) { System.out.println(" " + s + " = " + p.get(s, "")); } }
From source file:de.ingrid.usermanagement.jetspeed.IngridRoleManager.java
/** * @see org.apache.jetspeed.security.RoleManager#addRole(java.lang.String) *///ww w . ja v a2s . c om public void addRole(String roleFullPathName) throws SecurityException { ArgUtil.notNull(new Object[] { roleFullPathName }, new String[] { "roleFullPathName" }, "addRole(java.lang.String)"); // Check if role already exists. if (roleExists(roleFullPathName)) { throw new SecurityException(SecurityException.ROLE_ALREADY_EXISTS.create(roleFullPathName)); } RolePrincipal rolePrincipal = new RolePrincipalImpl(roleFullPathName); String fullPath = rolePrincipal.getFullPath(); // Add the preferences. Preferences preferences = Preferences.userRoot().node(fullPath); if (log.isDebugEnabled()) { log.debug("Added role preferences node: " + fullPath); } try { if ((null != preferences) && preferences.absolutePath().equals(fullPath)) { // Add role principal. roleSecurityHandler.setRolePrincipal(rolePrincipal); if (log.isDebugEnabled()) { log.debug("Added role: " + fullPath); } } } catch (SecurityException se) { KeyedMessage msg = SecurityException.UNEXPECTED.create("RoleManager.addRole", "RoleSecurityHandler.setRolePrincipal(" + rolePrincipal.getName() + ")", se.getMessage()); log.error(msg, se); // Remove the preferences node. try { preferences.removeNode(); } catch (BackingStoreException bse) { bse.printStackTrace(); } throw new SecurityException(msg, se); } }
From source file:org.apache.cayenne.modeler.Application.java
public Preferences getMainPreferenceForProject() { DataChannelDescriptor descriptor = (DataChannelDescriptor) getFrameController().getProjectController() .getProject().getRootNode(); // if new project if (descriptor.getConfigurationSource() == null) { return getPreferencesNode(getProject().getClass(), getNewProjectTemporaryName()); }// w ww . j a va 2 s . c o m String path = CayennePreference .filePathToPrefereceNodePath(descriptor.getConfigurationSource().getURL().getPath()); Preferences pref = getPreferencesNode(getProject().getClass(), ""); return pref.node(pref.absolutePath() + path); }
From source file:org.apache.cayenne.modeler.util.CayenneController.java
/** * Returns preference for this component view. *///from w w w . ja v a 2 s .co m protected Preferences getViewPreferences() { if (getApplication().getProject() == null) { return getApplication().getPreferencesNode(getView().getClass(), ""); } Preferences pref = getApplication().getMainPreferenceForProject(); String pathToProject = pref.absolutePath(); String path = pathToProject + "/" + getView().getClass().getName().replace(".", "/"); return pref.node(path); }
From source file:org.cellprofiler.preferences.CellProfilerPreferences.java
@Override public Preferences node(String pathName) { Preferences target = delegate.node(pathName); return retrieveNode(target.absolutePath(), this.nodeMap); }
From source file:verdandi.ui.common.WidthStoringTable.java
/** * Stores thw width of the columns to a preference. The preference is stored * beneath the node for the Package of the implementing class. Preferences are * named {@link #PREFIX_COL_WIDTH} plus the column index. * //from w ww. j av a 2 s . c om * @see #PREFIX_COL_WIDTH */ public void storeWidths() { Preferences prefs = Preferences.userNodeForPackage(getClass()); LOG.debug("Storing widths to " + prefs.absolutePath() + "; " + getModel().getClass().getSimpleName()); for (int i = 0; i < getModel().getColumnCount(); i++) { int width = getColumnModel().getColumn(i).getWidth(); LOG.debug("Store " + widthPref + i + "=" + width); prefs.putInt(widthPref + i, width); } try { prefs.flush(); } catch (BackingStoreException e) { e.printStackTrace(); } }