Analyze shared preferences.

@param sharedPreference the shared preference
@return the string
513813
private String analyzeSharedPreferences(final TypeElement sharedPreference) {
		Element beanElement = sharedPreference;
		String result = beanElement.getSimpleName().toString();

		// create equivalent entity in the domain of bind processor
		final BindEntity bindEntity = BindEntityBuilder.parse(null, sharedPreference);
		final PrefsEntity currentEntity = new PrefsEntity(beanElement.getSimpleName().toString(), (TypeElement) beanElement,
				AnnotationUtility.buildAnnotationList((TypeElement) beanElement, classAnnotationFilter));

		final boolean bindAllFields = AnnotationUtility.getAnnotationAttributeAsBoolean(currentEntity, BindType.class, AnnotationAttributeType.ALL_FIELDS, Boolean.TRUE);

		PropertyUtility.buildProperties(elementUtils, currentEntity, new PropertyFactory<PrefsEntity, PrefsProperty>() {

			@Override
			public PrefsProperty createProperty(PrefsEntity entity, Element propertyElement) {
				return new PrefsProperty(currentEntity, propertyElement, AnnotationUtility.buildAnnotationList(propertyElement));
			}
		}, propertyAnnotationFilter, new PropertyCreatedListener<PrefsEntity, PrefsProperty>() {

			@Override
			public boolean onProperty(PrefsEntity entity, PrefsProperty property) {
				// if @BindDisabled is present, exit immediately
				if (property.hasAnnotation(BindDisabled.class)) {
					if (bindAllFields) {
						return false;
					} else {
						throw new InvalidDefinition(String.format("@%s can not be used with @%s(allField=false)", BindDisabled.class.getSimpleName(), BindType.class.getSimpleName()));
					}
				}

				if (property.getPropertyType().isArray() || property.getPropertyType().isList()) {
					property.setPreferenceType(PreferenceType.STRING);
				} else {
					if (property.isType(Boolean.TYPE, Boolean.class)) {
						property.setPreferenceType(PreferenceType.BOOL);
					} else if (property.isType(Short.TYPE, Short.class)) {
						property.setPreferenceType(PreferenceType.INT);
					} else if (property.isType(Character.TYPE, Character.class)) {
						property.setPreferenceType(PreferenceType.STRING);
					} else if (property.isType(Integer.TYPE, Integer.class)) {
						property.setPreferenceType(PreferenceType.INT);
					} else if (property.isType(Long.TYPE, Long.class)) {
						property.setPreferenceType(PreferenceType.LONG);
					} else if (property.isType(Float.TYPE, Float.class)) {
						property.setPreferenceType(PreferenceType.FLOAT);
					} else if (property.isType(Double.TYPE, Double.class)) {
						property.setPreferenceType(PreferenceType.STRING);
					} else {
						property.setPreferenceType(PreferenceType.STRING);
					}
				}

				if (!bindAllFields && !property.hasAnnotation(BindPreference.class)) {
					// skip field
					return false;
				}

				// if field disable, skip property definition
				ModelAnnotation annotation = property.getAnnotation(BindPreference.class);
				if (annotation != null && AnnotationUtility.extractAsBoolean(property, annotation, AnnotationAttributeType.ENABLED) == false) {
					return false;
				}

				if (bindEntity.contains(property.getName())) {
					BindProperty bindProperty = bindEntity.get(property.getName());
					if (bindProperty.isBindedArray() || bindProperty.isBindedCollection() || bindProperty.isBindedMap() || bindProperty.isBindedObject()) {
						property.bindProperty = bindProperty;
					}

				} else {
					throw (new KriptonRuntimeException(String.format("In class '%s' property '%s' has a wrong definition to create SharedPreference", sharedPreference.asType(), property.getName())));
				}

				return true;
			}

		});
		
		ImmutableUtility.buildConstructors(elementUtils, currentEntity);

		model.entityAdd(currentEntity);
		return result;

	}
1193816
private int getDividerCount() {
        SharedPreferences sharedPreferences =
                PreferenceManager.getDefaultSharedPreferences(getActivity());
        String key = getString(R.string.divider_count_preference_key);
        String defaultValue = getString(R.string.divider_count_preference_default_value);
        return Integer.valueOf(sharedPreferences.getString(key, defaultValue));
    }
151634
private List<String> getChildrenList() {
        if (childrenList != null) return childrenList;

        SharedPreferences prefs = loadSharedPreferences("children");

        String list = prefs.getString(getId(), null);

        childrenList = (list == null) ? new ArrayList<String>() : new ArrayList<>(Arrays.asList(list.split(",")));
        return childrenList;
    }
1017045
public static void saveToUserPreferences(final QuickAnalysisStrategy strategy,
            final UserPreferences userPreferences) {
        final Map<String, String> properties = userPreferences.getAdditionalProperties();

        properties.put(USER_PREFERENCES_NAMESPACE + ".columnsPerAnalyzer", "" + strategy.columnsPerAnalyzer);
        properties
                .put(USER_PREFERENCES_NAMESPACE + ".includeValueDistribution", "" + strategy.includeValueDistribution);
        properties.put(USER_PREFERENCES_NAMESPACE + ".includePatternFinder", "" + strategy.includePatternFinder);
    }
263948
public function getUserPreference($preference)
    {
        $user = $this->getBackendUser();
        if ($user && $user->getPreferences()) {
            return $user->getPreferences()->get($preference) ?: null;
        }
    }
126802
private String getPositiveButtonText() {
        SharedPreferences sharedPreferences =
                PreferenceManager.getDefaultSharedPreferences(getActivity());
        String key = getString(R.string.positive_button_text_preference_key);
        String defaultValue = getString(R.string.positive_button_text_preference_default_value);
        return sharedPreferences.getString(key, defaultValue);
    }
1321468
def _parse_read_preference(options):
    """"""
    if 'read_preference' in options:
        return options['read_preference']

    name = options.get('readpreference', 'primary')
    mode = read_pref_mode_from_name(name)
    tags = options.get('readpreferencetags')
    max_staleness = options.get('maxstalenessseconds', -1)
    return make_read_preference(mode, tags, max_staleness)
340615
public void addPreferencesToParser(final String preferencesKey, final String preferencesPath) {
        parser.getData().addPreferences(preferencesKey, ApplicationPreferences.getPreferences(preferencesPath));
    }
1130234
private boolean shouldDividerTitleBeShown() {
        SharedPreferences sharedPreferences =
                PreferenceManager.getDefaultSharedPreferences(getActivity());
        String key = getString(R.string.show_divider_title_preference_key);
        boolean defaultValue =
                getResources().getBoolean(R.bool.show_divider_title_preference_default_value);
        return sharedPreferences.getBoolean(key, defaultValue);
    }
1127497
function(options) {
  var r = null;
  if (options.readPreference) {
    r = options.readPreference;
  } else {
    return options;
  }

  if (typeof r === 'string') {
    options.readPreference = new ReadPreference(r);
  } else if (r && !(r instanceof ReadPreference) && typeof r === 'object') {
    const mode = r.mode || r.preference;
    if (mode && typeof mode === 'string') {
      options.readPreference = new ReadPreference(mode, r.tags, {
        maxStalenessSeconds: r.maxStalenessSeconds
      });
    }
  } else if (!(r instanceof ReadPreference)) {
    throw new TypeError('Invalid read preference: ' + r);
  }

  return options;
}
261987
def get_preferences(self):
        
        schema = PreferencesSchema()
        resp = self.service.get(self.base+'preferences/')
        return self.service.decode(schema, resp)
654137
private String getDialogTitle() {
        SharedPreferences sharedPreferences =
                PreferenceManager.getDefaultSharedPreferences(getActivity());
        String key = getString(R.string.dialog_title_preference_key);
        String defaultValue = getString(R.string.dialog_title_preference_default_value);
        return sharedPreferences.getString(key, defaultValue);
    }
313323
private void readPreferences() {
    boolean runOnStartup = pref.getBoolean("runOnStartup", true);
    getRunOnStartupCheckBox().setSelected(runOnStartup);

    int maxCpus = pref.getInt("maxCpus", 0);
    if (maxCpus <= 0) {
      getLimitCpusCheckBox().setSelected(false);
      getMaxCpusTextField().setValue(Runtime.getRuntime().availableProcessors());
      getMaxCpusTextField().setEnabled(false);
    } else {
      getLimitCpusCheckBox().setSelected(true);
      getMaxCpusTextField().setValue(maxCpus);
      getMaxCpusTextField().setEnabled(true);
    }

    if (getRequireACCheckBox().isEnabled()) {
      boolean requireAC = pref.getBoolean("requireAC", false);
      int minBattLife = pref.getInt("minBattLife", 0);
      int minBattLifeWhileChg = pref.getInt("minBattLifeWhileChg", 0);
      getRequireACCheckBox().setSelected(requireAC);
      getMinBatteryLifeSlider().setEnabled(!requireAC);
      getMinBatteryLifeSlider().setValue(minBattLife);
      getMinBatteryLifeWhileChargingSlider().setValue(minBattLifeWhileChg);
    } else {
      getRequireACCheckBox().setSelected(false);
      getMinBatteryLifeSlider().setValue(0);
      getMinBatteryLifeWhileChargingSlider().setValue(0);
      getRequireACCheckBox().setEnabled(false);
      getMinBatteryLifeSlider().setEnabled(false);
      getMinBatteryLifeWhileChargingSlider().setEnabled(false);
    }

    boolean cacheClassDefinitions = pref.getBoolean("cacheClassDefinitions", true);
    getCacheClassDefinitionsCheckBox().setSelected(cacheClassDefinitions);
  }
565418
@Override
	public Filter getFilter() {
		Filter filter = new Filter() {
			@Override
			protected FilterResults performFiltering(CharSequence constraint) {
				ArrayList<Pair<String, ?>> filteredPrefs = new ArrayList<Pair<String, ?>>();
				FilterResults filterFriends = new FilterResults();
				if (!SharedPreferenceUtils.isEmptyString(constraint)) {
					for (Pair<String, ?> keyValue : keyValSet) {
						String constraintString = constraint.toString();
						String prefixKey = "key: ";
						String prefixValue = "value: ";
						String first = keyValue.first;
						Object second = keyValue.second;
						if (constraintString.toLowerCase().startsWith(prefixKey)) {
							if (first.toLowerCase().contains(constraintString.toLowerCase().substring(prefixKey.length()))) {
								filteredPrefs.add(keyValue);
							}
						} else if (constraintString.toLowerCase().startsWith(prefixValue)) {
							if (second != null) {
								if (second.toString().contains(constraintString.toLowerCase().substring(prefixValue.length()))) {
									filteredPrefs.add(keyValue);
								}
							}
						} else {
							if (first.equalsIgnoreCase(constraintString) || (second != null && second.toString()
							                                                                         .equalsIgnoreCase(constraintString))) {
								filteredPrefs.add(keyValue);
							}
						}
					}
				} else {
					filteredPrefs = keyValSet;
				}
				filterFriends.count = filteredPrefs.size();
				filterFriends.values = filteredPrefs;
				return filterFriends;
			}

			@Override
			protected void publishResults(CharSequence constraint, FilterResults results) {
				filteredCollection = (ArrayList<Pair<String, ?>>) results.values;

				notifyDataSetChanged();
			}
		};
		return filter;
	}
1253982
private boolean shouldIconBeShown() {
        SharedPreferences sharedPreferences =
                PreferenceManager.getDefaultSharedPreferences(getActivity());
        String key = getString(R.string.show_dialog_icon_preference_key);
        boolean defaultValue =
                getResources().getBoolean(R.bool.show_dialog_icon_preference_default_value);
        return sharedPreferences.getBoolean(key, defaultValue);
    }
991696
public Integer loadPreferenceAsInteger(String key, Integer defaultValue) {
		Integer value = defaultValue;
		if (hasPreference(key)) {
			value = getSharedPreferences().getInt(key, 0);
		}
		logLoad(key, value);
		return value;
	}
893719
private Preferences getPreferences(final HttpServletRequest req) {
        final String preferencesToken = req.getHeader(Headers.PREFERECES.getName());
        return StringUtils.isNotBlank(preferencesToken)
                ? preferencesService.parsePreferences(preferencesToken)
                : MissingModelElement.PREFERENCES;
    }