下面列出了org.eclipse.core.runtime.Preferences#getString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static byte[] readFromPrefs( String prefName){
try {
Plugin pl = (Plugin) CoreContext.getContext().getObject("p");
Preferences prefs = pl.getPluginPreferences();
String str64 = prefs.getString(prefName);
byte[] data = Base64.decodeBase64(str64.getBytes("UTF8"));
return data;
} catch (UnsupportedEncodingException e) {
ExceptionHandler.handle(e);
} catch (Exception ignore) {
ExceptionHandler.handle(ignore);
}
return null;
}
private Object[] findCheckedElements() {
Preferences preferences = TextUMLUIPlugin.getDefault().getPluginPreferences();
String rawString = preferences.getString(TextUMLUIPlugin.OPTIONS);
List a = new ArrayList();
if (isNotEmpty(rawString)) {
String[] selected = rawString.split(",");
for (String optId : selected) {
a.add(options.get(optId));
}
}
return a.toArray();
}
public String getString( String name )
{
if ( this.preferenceType == SPECIAL_TYPE && project != null )
{
Preferences preference = prefs.getReportPreference( project );
if ( preference != null && preference.contains( name ) )
return preference.getString( name );
}
return prefsStore.getString( name );
}
/**
* Gets the uima pref string.
*
* @param key the key
* @param defaultValue the default value
* @return the uima pref string
*/
private static String getUimaPrefString(String key, String defaultValue) {
TAEConfiguratorPlugin plugin = TAEConfiguratorPlugin.getDefault();
Preferences prefs = plugin.getPluginPreferences();
boolean isDefault = prefs.isDefault(key);
if (isDefault)
prefs.setDefault(key, defaultValue);
return prefs.getString(key);
}
/**
* returns the value of given key as a string.
*/
public static String getString(String key) {
Preferences prefs = getPreferences();
return prefs.getString(key);
}
public static IPath getEclipseHome( )
{
Preferences preferences = PDECore.getDefault( ).getPluginPreferences( );
return new Path( preferences.getString( ICoreConstants.PLATFORM_PATH ) );
}
/**
* Loads a history from an XML encoded preference value.
*
* @param preferences the preferences to retrieve the history from
* @param key the key under which the history is stored
* @return the deserialized history, or <code>null</code> if there is nothing stored under the
* given key
* @throws CoreException if deserialization fails
* @see #store(ContentAssistHistory, Preferences, String) on how to store a history such that it
* can be read by this method
*/
public static ContentAssistHistory load(Preferences preferences, String key) throws CoreException {
String value= preferences.getString(key);
if (value != null && value.length() > 0) {
return new ReaderWriter().load(new InputSource(new StringReader(value)));
}
return null;
}