org.apache.sling.commons.osgi

## Class PropertiesUtil

- java.lang.Object
- - org.apache.sling.commons.osgi.PropertiesUtil

Deprecated.
Use `org.osgi.util.converter.Converters` instead

    @Deprecated
    public class PropertiesUtil
    extends Object

The `PropertiesUtil` is a utility class providing some useful utility methods for converting property types.

Since:
  2.1

### Constructor Summary

Constructors
Constructor and Description
`PropertiesUtil()` Deprecated.

### Method Summary

All Methods Static Methods Concrete Methods Deprecated Methods
`static boolean` `toBoolean(Object propValue, boolean defaultValue)` Deprecated. Returns the boolean value of the parameter or the `defaultValue` if the parameter is `null`.
`static double` `toDouble(Object propValue, double defaultValue)` Deprecated. Returns the parameter as a double or the `defaultValue` if the parameter is `null` or if the parameter is not a `Double` and cannot be converted to a `Double` from the parameter's string value.
`static int` `toInteger(Object propValue, int defaultValue)` Deprecated. Returns the parameter as an integer or the `defaultValue` if the parameter is `null` or if the parameter is not an `Integer` and cannot be converted to an `Integer` from the parameter's string value.
`static long` `toLong(Object propValue, long defaultValue)` Deprecated. Returns the parameter as a long or the `defaultValue` if the parameter is `null` or if the parameter is not a `Long` and cannot be converted to a `Long` from the parameter's string value.
`static Map<String,String>` `toMap(Object propValue, String[] defaultArray)` Deprecated. Returns the parameter as a map with string keys and string values.
`static Object` `toObject(Object propValue)` Deprecated. Returns the parameter as a single value.
`static String` `toString(Object propValue, String defaultValue)` Deprecated. Returns the parameter as a string or the `defaultValue` if the parameter is `null`.
`static String[]` `toStringArray(Object propValue)` Deprecated. Returns the parameter as an array of Strings.
`static String[]` `toStringArray(Object propValue, String[] defaultArray)` Deprecated. Returns the parameter as an array of Strings.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### PropertiesUtil

    public PropertiesUtil()

Deprecated.

### Method Detail

#### toBoolean

    public static boolean toBoolean(Object propValue,
                                    boolean defaultValue)

Deprecated.
Returns the boolean value of the parameter or the `defaultValue` if the parameter is `null`. If the parameter is not a `Boolean` it is converted by calling `Boolean.valueOf` on the string value of the object.

Parameters:
  `propValue` - the property value or `null`
  `defaultValue` - the default boolean value
Returns:
  Boolean value

#### toString

    public static String toString(Object propValue,
                                  String defaultValue)

Deprecated.
Returns the parameter as a string or the `defaultValue` if the parameter is `null`.

Parameters:
  `propValue` - the property value or `null`
  `defaultValue` - the default string value
Returns:
  String value

#### toLong

    public static long toLong(Object propValue,
                              long defaultValue)

Deprecated.
Returns the parameter as a long or the `defaultValue` if the parameter is `null` or if the parameter is not a `Long` and cannot be converted to a `Long` from the parameter's string value.

Parameters:
  `propValue` - the property value or `null`
  `defaultValue` - the default long value
Returns:
  Long value

#### toInteger

    public static int toInteger(Object propValue,
                                int defaultValue)

Deprecated.
Returns the parameter as an integer or the `defaultValue` if the parameter is `null` or if the parameter is not an `Integer` and cannot be converted to an `Integer` from the parameter's string value.

Parameters:
  `propValue` - the property value or `null`
  `defaultValue` - the default integer value
Returns:
  Integer value

#### toDouble

    public static double toDouble(Object propValue,
                                  double defaultValue)

Deprecated.
Returns the parameter as a double or the `defaultValue` if the parameter is `null` or if the parameter is not a `Double` and cannot be converted to a `Double` from the parameter's string value.

Parameters:
  `propValue` - the property value or `null`
  `defaultValue` - the default double value
Returns:
  Double value

#### toObject

    public static Object toObject(Object propValue)

Deprecated.
Returns the parameter as a single value. If the parameter is neither an array nor a `java.util.Collection` the parameter is returned unmodified. If the parameter is a non-empty array, the first array element is returned. If the property is a non-empty `java.util.Collection`, the first collection element is returned. Otherwise `null` is returned.

Parameters:
  `propValue` - the parameter to convert.
Returns:
  Object value

#### toStringArray

    public static String[] toStringArray(Object propValue)

Deprecated.
Returns the parameter as an array of Strings. If the parameter is a scalar value its string value is returned as a single element array. If the parameter is an array, the elements are converted to String objects and returned as an array. If the parameter is a collection, the collection elements are converted to String objects and returned as an array. Otherwise (if the parameter is `null`) `null` is returned.

Parameters:
  `propValue` - The object to convert.
Returns:
  String array value

#### toStringArray

    public static String[] toStringArray(Object propValue,
                                         String[] defaultArray)

Deprecated.
Returns the parameter as an array of Strings. If the parameter is a scalar value its string value is returned as a single element array. If the parameter is an array, the elements are converted to String objects and returned as an array. If the parameter is a collection, the collection elements are converted to String objects and returned as an array. Otherwise (if the property is `null`) a provided default value is returned.

Parameters:
  `propValue` - The object to convert.
  `defaultArray` - The default array to return.
Returns:
  String array value

#### toMap

    public static Map<String,String> toMap(Object propValue,
                                           String[] defaultArray)

Deprecated.
Returns the parameter as a map with string keys and string values. The parameter is considered as a collection whose entries are of the form key=value. The conversion has following rules

- Entries are of the form key=value
- key is trimmed
- value is trimmed. If a trimmed value results in an empty string it is treated as null
- Malformed entries like 'foo','foo=' are ignored
- Map entries maintain the input order

Otherwise (if the property is `null`) a provided default value is returned.

Parameters:
  `propValue` - The object to convert.
  `defaultArray` - The default array converted to map.
Returns:
  Map value