本文整理匯總了Java中java.util.prefs.Preferences.put方法的典型用法代碼示例。如果您正苦於以下問題:Java Preferences.put方法的具體用法?Java Preferences.put怎麽用?Java Preferences.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.prefs.Preferences
的用法示例。
在下文中一共展示了Preferences.put方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: saveAsLast
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void saveAsLast() {
if (!isValid()) return;
Preferences root = Preferences.userRoot().node(userPrefFolder).node(userPrefKey);
try {
saveList(root.node(pathsAKey), pathsA);
saveList(root.node(pathsBKey), pathsB);
saveList(root.node(classPathAKey), classPathA);
saveList(root.node(classPathBKey), classPathB);
saveList(root.node(pathsSharedKey), sharedClassPath);
root.putBoolean(inputsBeforeClassPathKey, inputsBeforeClassPath);
if (uidHost != null) root.put("uidHost", uidHost);
if (uidPort != 0) root.putInt("uidPort", uidPort);
if (uidUser != null) root.put("uidUser", uidUser);
if (uidPassword != null) root.put("uidPassword", uidPassword);
if (uidProject != null) root.put("uidProject", uidProject);
if (uidVersionA != null) root.put("uidVersionA", uidVersionA);
if (uidVersionB != null) root.put("uidVersionB", uidVersionB);
root.flush();
} catch (BackingStoreException e) {
throw new RuntimeException(e);
}
}
示例2: testConstantFix208072c
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void testConstantFix208072c() throws Exception {
Preferences prefs = CodeStylePreferences.get((FileObject) null, JavacParser.MIME_TYPE).getPreferences();
prefs.put("classMembersOrder", "STATIC_INIT;STATIC METHOD;INSTANCE_INIT;CONSTRUCTOR;METHOD;STATIC CLASS;CLASS;STATIC FIELD;FIELD");
prefs.put("classMemberInsertionPoint", "LAST_IN_CATEGORY");
performFixTest("package test;\n" +
"import java.util.logging.Level;\n" +
"import java.util.logging.Logger;\n" +
"public class Test {\n" +
" {\n" +
" int ii = |1 + 2 * 3|;\n" +
" }\n" +
" private static final int II = 0;\n" +
"}\n",
("package test;\n" +
"import java.util.logging.Level;\n" +
"import java.util.logging.Logger;\n" +
"public class Test {\n" +
" {\n" +
" int ii = ZZ;\n" +
" }\n" +
" private static final int II = 0;\n" +
" private static final int ZZ = 1 + 2 * 3;\n" +
"}\n").replaceAll("[ \t\n]+", " "),
new DialogDisplayerImpl("ZZ", true, true, true, EnumSet.of(Modifier.PRIVATE)),
5, 1);
}
示例3: getExecutionEnvironment
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public ExecutionEnvironment getExecutionEnvironment() {
if (btnKnownHosts.isSelected()) {
last = (ExecutionEnvironment) cbKnownHosts.getSelectedItem();
} else {
if (userField.getText().isEmpty() || hostField.getText().isEmpty()) {
return null;
}
int port = 22;
if (!portField.getText().isEmpty()) {
try {
port = Integer.parseInt(portField.getText());
} catch (NumberFormatException ex) {
}
}
last = ExecutionEnvironmentFactory.createNew(userField.getText(), hostField.getText(), port);
}
Preferences prefs = NbPreferences.forModule(RemoteInfoDialog.class);
prefs.put(LAST_SELECTED_HOST, ExecutionEnvironmentFactory.toUniqueID(last));
return last;
}
示例4: setValues
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private void setValues(Preferences p, Map<String, String> values) {
for (Entry<String, String> e : values.entrySet()) {
if (e.getValue() != null) {
p.put(e.getKey(), e.getValue());
} else {
p.remove(e.getKey());
}
}
}
示例5: testNewLineIndentationBeforeEmptyHalfIndentedBlockEnd
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void testNewLineIndentationBeforeEmptyHalfIndentedBlockEnd() throws Exception {
Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
preferences.put("otherBracePlacement", CodeStyle.BracePlacement.NEW_LINE_HALF_INDENTED.name());
try {
performNewLineIndentationTest("package t;\npublic class T {\n public void op() {\n {|}\n }\n}\n",
"package t;\npublic class T {\n public void op() {\n {\n }\n }\n}\n");
} finally {
preferences.remove("otherBracePlacement");
}
}
示例6: testNode
import java.util.prefs.Preferences; //導入方法依賴的package包/類
@Test
public void testNode() {
Preferences userRoot = factory.remoteUserRoot("brian");
log.debug("userRoot = " + userRoot.absolutePath());
userRoot.put("trash", "foo");
String s0 = userRoot.get("trash", "bar");
assertTrue("Returned value was not what we expected", s0.equals("foo"));
userRoot.put("trash", "bar");
String s1 = userRoot.get("trash", "bar");
assertTrue("Returned value was not what we expected", s1.equals("bar"));
userRoot.remove("trash");
}
示例7: saveFontsTo
import java.util.prefs.Preferences; //導入方法依賴的package包/類
/**
* Save font settings. Save allways, changing L&F shouldn't affect font
* settings.
*/
private void saveFontsTo(Preferences preferences) {
preferences.putInt(PREFIX + PROP_FONT_SIZE, getFont().getSize());
preferences.putInt(PREFIX + PROP_FONT_STYLE, getFont().getStyle());
preferences.putInt(PREFIX + PROP_FONT_SIZE_WRAP,
getFontForWrappedMode().getSize());
preferences.put(PREFIX + PROP_FONT_FAMILY, getFont().getFamily());
preferences.put(PREFIX + PROP_STYLE_LINK, getLinkStyle().name());
}
示例8: testTooLong
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void testTooLong() throws IOException, BackingStoreException {
lookup.setDelegates(Lookups.fixed(new TestAuxiliaryConfigurationImpl()));
AuxiliaryConfiguration ac = p.getLookup().lookup(AuxiliaryConfiguration.class);
assertNotNull(ac);
AuxiliaryConfigBasedPreferencesProvider toSync = new AuxiliaryConfigBasedPreferencesProvider(p, ac, null, true);
Preferences pref = toSync.findModule("test");
//test length of key
char[] keyChars = new char[100];
Arrays.fill(keyChars, 'X');
String key = new String(keyChars);
pref.put(key, "test");
//test length of value
char[] valChars = new char[10 * 1024];
Arrays.fill(valChars, 'X');
String value = new String(valChars);
pref.put("test", value);
pref.flush();
assertEquals(pref.get("test", null), value);
assertEquals(pref.get(key, null), "test");
}
示例9: save
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private void save(Preferences prefs, ResizeOption option) {
prefs.put("displayName", option.getDisplayName()); // NOI18N
prefs.putInt("width", option.getWidth()); // NOI18N
prefs.putInt("height", option.getHeight()); // NOI18N
prefs.putBoolean("toolbar", option.isShowInToolbar()); // NOI18N
prefs.putBoolean("default", option.isDefault()); // NOI18N
prefs.put("type", option.getType().name()); // NOI18N
}
示例10: testEvents1
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void testEvents1() throws Exception {
Preferences prefsA = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
L listenerA = new L();
prefsA.addPreferenceChangeListener(listenerA);
Preferences prefsB = MimeLookup.getLookup(MimePath.parse("text/x-testA")).lookup(Preferences.class);
L listenerB = new L();
prefsB.addPreferenceChangeListener(listenerB);
assertNotNull("'simple-value-setting-A' should not be null", prefsA.get("simple-value-setting-A", null));
assertNotNull("'simple-value-setting-A' should not be null", prefsB.get("simple-value-setting-A", null));
assertEquals("Wrong value for 'testA-1-setting-1'", "value-of-testA-1-setting-1", prefsB.get("testA-1-setting-1", null));
assertEquals("There should be no A events", 0, listenerA.count);
assertEquals("There should be no B events", 0, listenerB.count);
prefsA.put("simple-value-setting-A", "new-value");
assertEquals("Wrong value for 'simple-value-setting-A'", "new-value", prefsA.get("simple-value-setting-A", null));
assertEquals("The value for 'simple-value-setting-A' was not propagated", "new-value", prefsB.get("simple-value-setting-A", null));
Thread.sleep(500);
assertEquals("Wrong number of A events", 1, listenerA.count);
assertEquals("Wrong setting name in the A event", "simple-value-setting-A", listenerA.lastEvent.getKey());
assertEquals("Wrong setting value in the A event", "new-value", listenerA.lastEvent.getNewValue());
assertSame("Wrong Preferences instance in the A event", prefsA, listenerA.lastEvent.getNode());
assertEquals("Wrong number of B events", 1, listenerB.count);
assertEquals("Wrong setting name in the B event", "simple-value-setting-A", listenerB.lastEvent.getKey());
assertEquals("Wrong setting value in the B event", "new-value", listenerB.lastEvent.getNewValue());
assertSame("Wrong Preferences instance in the B event", prefsB, listenerB.lastEvent.getNode());
}
示例11: testLineIndentationBeforeHalfIndentedForEachBlock
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void testLineIndentationBeforeHalfIndentedForEachBlock() throws Exception {
Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
preferences.put("otherBracePlacement", CodeStyle.BracePlacement.NEW_LINE_HALF_INDENTED.name());
try {
performLineIndentationTest("package t;\npublic class T {\n public void op() {\n for (String s : getStrings())\n| {\n }\n}\n",
"package t;\npublic class T {\n public void op() {\n for (String s : getStrings())\n {\n }\n}\n");
} finally {
preferences.remove("otherBracePlacement");
}
}
示例12: setFilePath
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void setFilePath(File f) {
Preferences p = Preferences.userNodeForPackage(MainApp.class);
if (f != null) {
p.put("filePath", f.getPath());
primaryStage.setTitle("Kanphnia2 - " + f.getName());
}
else {
p.remove("filePath");
primaryStage.setTitle("Kanphnia2");
}
}
示例13: writePreferredInputMethod
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private void writePreferredInputMethod(String path, String descriptorName) {
if (userRoot != null) {
Preferences node = userRoot.node(path);
// record it
if (descriptorName != null) {
node.put(descriptorKey, descriptorName);
} else {
node.remove(descriptorKey);
}
}
}
示例14: testLineIndentationBeforeHalfIndentedIfBlock
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void testLineIndentationBeforeHalfIndentedIfBlock() throws Exception {
Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
preferences.put("otherBracePlacement", CodeStyle.BracePlacement.NEW_LINE_HALF_INDENTED.name());
try {
performLineIndentationTest("package t;\npublic class T {\n public void op() {\n if (true)\n| {\n }\n}\n",
"package t;\npublic class T {\n public void op() {\n if (true)\n {\n }\n}\n");
} finally {
preferences.remove("otherBracePlacement");
}
}
示例15: testLineIndentationInsideEmptyHalfIndentedMethodBody
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void testLineIndentationInsideEmptyHalfIndentedMethodBody() throws Exception {
Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
preferences.put("methodDeclBracePlacement", CodeStyle.BracePlacement.NEW_LINE_HALF_INDENTED.name());
try {
performLineIndentationTest("package t;\npublic class T {\n public void op()\n {\n|\n }\n}\n",
"package t;\npublic class T {\n public void op()\n {\n \n }\n}\n");
} finally {
preferences.remove("methodDeclBracePlacement");
}
}