Esempio n. 1
0
 /**
  * Get an integer preference value.
  *
  * @param preferenceName the preference name.
  * @param ignoreMissing true to return 0 when the property is missing.
  * @return one integer representing the preference value or 0 if the preference value is missing
  *     and the ignoreMissing argument is true.
  * @throws MissingPreferenceException if the preference value is missing and the ignoreMissing
  *     argument is false.
  */
 public final int getPreferenceAsInt(final Object preferenceName, final boolean ignoreMissing)
     throws MissingPreferenceException {
   final String value = getPreference(preferenceName, ignoreMissing);
   if (value == null) {
     return 0;
   }
   return NumberUtils.valueOf(value).intValue();
 }
Esempio n. 2
0
  /**
   * Get a preference order.
   *
   * @param preferenceName the preference name.
   * @return the order number for the property (-1 for no order).
   */
  public final int getPreferenceOrder(Object preferenceName) {
    // -1 is the flag value for no order found, so it is the default value.
    int result = -1;

    // If the asked order is NOT about an internal MCS index property
    if (!preferenceName.toString().startsWith(PREFERENCES_ORDER_INDEX_PREFIX)) {
      // Get the corresponding order as a String
      String orderString =
          _currentProperties.getProperty(PREFERENCES_ORDER_INDEX_PREFIX + preferenceName);

      // If an order token was found
      if (orderString != null) {
        // Convert the String in an int
        Integer orderInteger = NumberUtils.valueOf(orderString);
        result = orderInteger.intValue();
      }

      // Otherwise the default -1 value will be returned
    }

    return result;
  }