List of usage examples for org.eclipse.jdt.core JavaCore getEncoding
public static String getEncoding()
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
public Hashtable getDefaultOptions() { Hashtable defaultOptions = new Hashtable(10); // see JavaCorePreferenceInitializer#initializeDefaultPluginPreferences() for changing default settings // If modified, also modify the method getDefaultOptionsNoInitialization() IEclipsePreferences defaultPreferences = getDefaultPreferences(); // initialize preferences to their default Iterator iterator = this.optionNames.iterator(); while (iterator.hasNext()) { String propertyName = (String) iterator.next(); String value = defaultPreferences.get(propertyName, null); if (value != null) defaultOptions.put(propertyName, value); }//w w w . j a v a2s . c om // get encoding through resource plugin defaultOptions.put(JavaCore.CORE_ENCODING, JavaCore.getEncoding()); // backward compatibility addDeprecatedOptions(defaultOptions); return defaultOptions; }
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
public String getOption(String optionName) { if (JavaCore.CORE_ENCODING.equals(optionName)) { return JavaCore.getEncoding(); }/* ww w . j a v a2 s.c om*/ // backward compatibility if (isDeprecatedOption(optionName)) { return JavaCore.ERROR; } int optionLevel = getOptionLevel(optionName); if (optionLevel != UNKNOWN_OPTION) { IPreferencesService service = Platform.getPreferencesService(); String value = service.get(optionName, null, this.preferencesLookup); if (value == null && optionLevel == DEPRECATED_OPTION) { // May be a deprecated option, retrieve the new value in compatible options String[] compatibleOptions = (String[]) this.deprecatedOptions.get(optionName); value = service.get(compatibleOptions[0], null, this.preferencesLookup); } return value == null ? null : value.trim(); } return null; }
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
public Hashtable getOptions() { // return cached options if already computed Hashtable cachedOptions; // use a local variable to avoid race condition (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=256329 ) if ((cachedOptions = this.optionsCache) != null) { return new Hashtable(cachedOptions); }// ww w. j a va2s . c o m if (!Platform.isRunning()) { this.optionsCache = getDefaultOptionsNoInitialization(); return new Hashtable(this.optionsCache); } // init Hashtable options = new Hashtable(10); IPreferencesService service = Platform.getPreferencesService(); // set options using preferences service lookup Iterator iterator = this.optionNames.iterator(); while (iterator.hasNext()) { String propertyName = (String) iterator.next(); String propertyValue = service.get(propertyName, null, this.preferencesLookup); if (propertyValue != null) { options.put(propertyName, propertyValue); } } // set deprecated options using preferences service lookup Iterator deprecatedEntries = this.deprecatedOptions.entrySet().iterator(); while (deprecatedEntries.hasNext()) { Entry entry = (Entry) deprecatedEntries.next(); String propertyName = (String) entry.getKey(); String propertyValue = service.get(propertyName, null, this.preferencesLookup); if (propertyValue != null) { options.put(propertyName, propertyValue); String[] compatibleOptions = (String[]) entry.getValue(); for (int co = 0, length = compatibleOptions.length; co < length; co++) { String compatibleOption = compatibleOptions[co]; if (!options.containsKey(compatibleOption)) options.put(compatibleOption, propertyValue); } } } // get encoding through resource plugin options.put(JavaCore.CORE_ENCODING, JavaCore.getEncoding()); // backward compatibility addDeprecatedOptions(options); Util.fixTaskTags(options); // store built map in cache this.optionsCache = new Hashtable(options); // return built map return options; }
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
public void setOptions(Hashtable newOptions) { Hashtable cachedValue = newOptions == null ? null : new Hashtable(newOptions); IEclipsePreferences defaultPreferences = getDefaultPreferences(); IEclipsePreferences instancePreferences = getInstancePreferences(); if (newOptions == null) { try {/*w w w .j a v a2s.c om*/ instancePreferences.clear(); } catch (BackingStoreException e) { // ignore } } else { Enumeration keys = newOptions.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); int optionLevel = getOptionLevel(key); if (optionLevel == UNKNOWN_OPTION) continue; // unrecognized option if (key.equals(JavaCore.CORE_ENCODING)) { if (cachedValue != null) { cachedValue.put(key, JavaCore.getEncoding()); } continue; // skipped, contributed by resource prefs } String value = (String) newOptions.get(key); String defaultValue = defaultPreferences.get(key, null); // Store value in preferences if (defaultValue != null && defaultValue.equals(value)) { value = null; } storePreference(key, value, instancePreferences); } try { // persist options instancePreferences.flush(); } catch (BackingStoreException e) { // ignore } } // update cache Util.fixTaskTags(cachedValue); this.optionsCache = cachedValue; }