本文整理汇总了Java中java.util.prefs.Preferences.userRoot方法的典型用法代码示例。如果您正苦于以下问题:Java Preferences.userRoot方法的具体用法?Java Preferences.userRoot怎么用?Java Preferences.userRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.prefs.Preferences
的用法示例。
在下文中一共展示了Preferences.userRoot方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPreferencesProvider
import java.util.prefs.Preferences; //导入方法依赖的package包/类
private static Provider getPreferencesProvider() {
Provider retval = Lookup.getDefault().lookup(Provider.class);
if (retval == null) {
retval = new Provider() {
public Preferences preferencesForModule(Class cls) {
return Preferences.userNodeForPackage(cls);
}
public Preferences preferencesRoot() {
return Preferences.userRoot();
}
};
// Avoided warning in case it is set
//(e.g. from NbTestCase - org.netbeans.junit.internal.MemoryPreferencesFactory).
String prefsFactory = System.getProperty("java.util.prefs.PreferencesFactory");//NOI18N
if (!"org.netbeans.junit.internal.MemoryPreferencesFactory".equals(prefsFactory)) {//NOI18N
Logger logger = Logger.getLogger(NbPreferences.class.getName());
logger.log(prefsFactory == null ? Level.WARNING : Level.FINE,
"NetBeans implementation of Preferences not found");//NOI18N
}
}
return retval;
}
示例2: loadConfig
import java.util.prefs.Preferences; //导入方法依赖的package包/类
/**
* Load config from properties in ressource
* @throws IOException
*/
private static void loadConfig() throws IOException {
String authConfigFile = "auth.properties";
InputStream authConfigStream = AuthHelper.class.getClassLoader().getResourceAsStream(authConfigFile);
if (authConfigStream != null) {
props = new Properties();
props.load(authConfigStream);
} else {
throw new FileNotFoundException("Property file '" + authConfigFile + "' not found in the classpath.");
}
Preferences p = Preferences.userRoot();
int OwaNotifierMute = p.getInt("OwaNotifierMute", 0);
if(OwaNotifierMute > 0) {
setMute(true);
} else {
setMute(false);
}
}
示例3: getLast
import java.util.prefs.Preferences; //导入方法依赖的package包/类
public static ProjectConfig getLast() {
Preferences prefs = Preferences.userRoot();
try {
if (prefs.nodeExists(userPrefFolder)
&& (prefs = prefs.node(userPrefFolder)).nodeExists(userPrefKey)
&& (prefs = prefs.node(userPrefKey)).nodeExists(pathsAKey) && prefs.nodeExists(pathsBKey) && prefs.nodeExists(pathsSharedKey)) {
Function<String, Path> deserializer = str -> Paths.get(str);
List<Path> pathsA = loadList(prefs.node(pathsAKey), deserializer);
List<Path> pathsB = loadList(prefs.node(pathsBKey), deserializer);
List<Path> classPathA = loadList(prefs.node(classPathAKey), deserializer);
List<Path> classPathB = loadList(prefs.node(classPathBKey), deserializer);
List<Path> pathsShared = loadList(prefs.node(pathsSharedKey), deserializer);
boolean inputsBeforeClassPath = prefs.getBoolean(inputsBeforeClassPathKey, false);
ProjectConfig ret = new ProjectConfig(pathsA, pathsB, classPathA, classPathB, pathsShared, inputsBeforeClassPath);
ret.setUidSettings(prefs.get("uidHost", null),
prefs.getInt("uidPort", 0),
prefs.get("uidUser", null),
prefs.get("uidPassword", null),
prefs.get("uidProject", null),
prefs.get("uidVersionA", null),
prefs.get("uidVersionB", null));
return ret;
}
} catch (BackingStoreException e) { }
return new ProjectConfig();
}
示例4: testNodeExists
import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void testNodeExists() throws Exception {
Preferences pref = getPreferencesNode();
Preferences pref2 = pref.node("a/b/c");
while(pref2 != Preferences.userRoot()) {
assertTrue(pref2.nodeExists(""));
Preferences parent = pref2.parent();
pref2.removeNode();
assertFalse(pref2.nodeExists(""));
pref2 = parent;
}
assertNotNull(getPreferencesNode().node("a/b/c/d"));
assertTrue(getPreferencesNode().node("a/b/c/d").nodeExists(""));
}
示例5: setMute
import java.util.prefs.Preferences; //导入方法依赖的package包/类
/**
* Update mute status in Java/Prefs, this state is saving and restoring at OwaNotifier boot
* @param value
* true to set OwaNotifier in mute mode
*/
public static void setMute(boolean value) {
Preferences p = Preferences.userRoot();
if(value) {
p.putInt("OwaNotifierMute", 1);
OwaNotifier.mute = true;
} else {
p.putInt("OwaNotifierMute", 0);
OwaNotifier.mute = false;
}
}
示例6: afterPropertiesSet
import java.util.prefs.Preferences; //导入方法依赖的package包/类
/**
* This implementation eagerly fetches the Preferences instances
* for the required system and user tree nodes.
*/
@Override
public void afterPropertiesSet() {
this.systemPrefs = (this.systemTreePath != null) ?
Preferences.systemRoot().node(this.systemTreePath) : Preferences.systemRoot();
this.userPrefs = (this.userTreePath != null) ?
Preferences.userRoot().node(this.userTreePath) : Preferences.userRoot();
}
示例7: getRootPreference
import java.util.prefs.Preferences; //导入方法依赖的package包/类
@Override
public Preferences getRootPreference() {
if (rootPreference == null) {
rootPreference = Preferences.userRoot();
}
return rootPreference;
}
示例8: main
import java.util.prefs.Preferences; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
Preferences prefs = Preferences.userRoot();
System.out.println("grumpy/homePage: " + prefs.node("grumpy").get("homePage", null));
System.out.println(prefs.getClass());
}
示例9: testUserRoot
import java.util.prefs.Preferences; //导入方法依赖的package包/类
@Test public void testUserRoot() throws Exception
{
Preferences prefs = Preferences.userRoot();
assertNotNull(prefs);
assertEquals(IniPreferences.class, prefs.getClass());
assertSame(prefs, Preferences.userRoot());
}
示例10: run
import java.util.prefs.Preferences; //导入方法依赖的package包/类
public @Override void run(final TestResult result) {
//just do registration before code NbTestCase
NbPreferencesFactory.doRegistration();
Preferences.userRoot();
super.run(result);
}
示例11: Prefs
import java.util.prefs.Preferences; //导入方法依赖的package包/类
private Prefs(){
p = Preferences.userRoot();
}
示例12: DBInstallerConsole
import java.util.prefs.Preferences; //导入方法依赖的package包/类
public DBInstallerConsole(String db, String dir)
{
System.out.println("Welcome to L2J DataBase installer");
final Preferences prop = Preferences.userRoot();
RunTasks rt = null;
try (Scanner scn = new Scanner(new CloseShieldedInputStream(System.in)))
{
while (_con == null)
{
System.out.printf("%s (%s): ", "Host", prop.get("dbHost_" + db, "localhost"));
String dbHost = scn.nextLine();
System.out.printf("%s (%s): ", "Port", prop.get("dbPort_" + db, "3306"));
String dbPort = scn.nextLine();
System.out.printf("%s (%s): ", "Username", prop.get("dbUser_" + db, "root"));
String dbUser = scn.nextLine();
System.out.printf("%s (%s): ", "Password", "");
final String dbPass = scn.nextLine();
System.out.printf("%s (%s): ", "Database", prop.get("dbDbse_" + db, db));
String dbDbse = scn.nextLine();
dbHost = dbHost.isEmpty() ? prop.get("dbHost_" + db, "localhost") : dbHost;
dbPort = dbPort.isEmpty() ? prop.get("dbPort_" + db, "3306") : dbPort;
dbUser = dbUser.isEmpty() ? prop.get("dbUser_" + db, "root") : dbUser;
dbDbse = dbDbse.isEmpty() ? prop.get("dbDbse_" + db, db) : dbDbse;
final MySqlConnect connector = new MySqlConnect(dbHost, dbPort, dbUser, dbPass, dbDbse, true);
_con = connector.getConnection();
}
System.out.print("(C)lean install, (U)pdate or (E)xit? ");
final String resp = scn.next();
if (resp.equalsIgnoreCase("c"))
{
System.out.print("Do you really want to destroy your db (Y/N)?");
if (scn.next().equalsIgnoreCase("y"))
{
rt = new RunTasks(this, db, dir);
}
}
else if (resp.equalsIgnoreCase("u"))
{
rt = new RunTasks(this, db, dir);
}
}
if (rt != null)
{
rt.run();
}
else
{
System.exit(0);
}
}
示例13: localUserRoot
import java.util.prefs.Preferences; //导入方法依赖的package包/类
default Preferences localUserRoot() {
return Preferences.userRoot();
}