當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。