当前位置: 首页>>代码示例>>Java>>正文


Java Preferences.userRoot方法代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:NbPreferences.java

示例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);
    }
}
 
开发者ID:OwaNotifier,项目名称:owa-notifier,代码行数:23,代码来源:OwaNotifier.java

示例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();
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:33,代码来源:ProjectConfig.java

示例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(""));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:TestPreferences.java

示例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;
	}
}
 
开发者ID:OwaNotifier,项目名称:owa-notifier,代码行数:16,代码来源:OwaNotifier.java

示例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();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:PreferencesPlaceholderConfigurer.java

示例7: getRootPreference

import java.util.prefs.Preferences; //导入方法依赖的package包/类
@Override
public Preferences getRootPreference() {
    if (rootPreference == null) {
        rootPreference = Preferences.userRoot();
    }
    return rootPreference;
}
 
开发者ID:apache,项目名称:cayenne-modeler,代码行数:8,代码来源:CayennePreference.java

示例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());
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:8,代码来源:NoImportSample.java

示例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());
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:9,代码来源:IniPreferencesFactoryTest.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:NbPreferencesTest.java

示例11: Prefs

import java.util.prefs.Preferences; //导入方法依赖的package包/类
private Prefs(){
	p = Preferences.userRoot();
}
 
开发者ID:alireza6677,项目名称:BestoonGui,代码行数:4,代码来源:Prefs.java

示例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);
	}
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:56,代码来源:DBInstallerConsole.java

示例13: localUserRoot

import java.util.prefs.Preferences; //导入方法依赖的package包/类
default Preferences localUserRoot() {
    return Preferences.userRoot();
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:4,代码来源:PreferencesFactory.java


注:本文中的java.util.prefs.Preferences.userRoot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。