Package org.apache.sling.commons.osgi
Class PropertiesUtil
- java.lang.Object
-
- org.apache.sling.commons.osgi.PropertiesUtil
-
@Deprecated public class PropertiesUtil extends java.lang.Object
Deprecated.Useorg.osgi.util.converter.Converters
insteadThePropertiesUtil
is a utility class providing some useful utility methods for converting property types.- Since:
- 2.1
-
-
Constructor Summary
Constructors Constructor Description PropertiesUtil()
Deprecated.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static boolean
toBoolean(java.lang.Object propValue, boolean defaultValue)
Deprecated.Returns the boolean value of the parameter or thedefaultValue
if the parameter isnull
.static double
toDouble(java.lang.Object propValue, double defaultValue)
Deprecated.Returns the parameter as a double or thedefaultValue
if the parameter isnull
or if the parameter is not aDouble
and cannot be converted to aDouble
from the parameter's string value.static int
toInteger(java.lang.Object propValue, int defaultValue)
Deprecated.Returns the parameter as an integer or thedefaultValue
if the parameter isnull
or if the parameter is not anInteger
and cannot be converted to anInteger
from the parameter's string value.static long
toLong(java.lang.Object propValue, long defaultValue)
Deprecated.Returns the parameter as a long or thedefaultValue
if the parameter isnull
or if the parameter is not aLong
and cannot be converted to aLong
from the parameter's string value.static java.util.Map<java.lang.String,java.lang.String>
toMap(java.lang.Object propValue, java.lang.String[] defaultArray)
Deprecated.Returns the parameter as a map with string keys and string values.static java.lang.Object
toObject(java.lang.Object propValue)
Deprecated.Returns the parameter as a single value.static java.lang.String
toString(java.lang.Object propValue, java.lang.String defaultValue)
Deprecated.Returns the parameter as a string or thedefaultValue
if the parameter isnull
.static java.lang.String[]
toStringArray(java.lang.Object propValue)
Deprecated.Returns the parameter as an array of Strings.static java.lang.String[]
toStringArray(java.lang.Object propValue, java.lang.String[] defaultArray)
Deprecated.Returns the parameter as an array of Strings.
-
-
-
Method Detail
-
toBoolean
public static boolean toBoolean(java.lang.Object propValue, boolean defaultValue)
Deprecated.Returns the boolean value of the parameter or thedefaultValue
if the parameter isnull
. If the parameter is not aBoolean
it is converted by callingBoolean.valueOf
on the string value of the object.- Parameters:
propValue
- the property value ornull
defaultValue
- the default boolean value- Returns:
- Boolean value
-
toString
public static java.lang.String toString(java.lang.Object propValue, java.lang.String defaultValue)
Deprecated.Returns the parameter as a string or thedefaultValue
if the parameter isnull
.- Parameters:
propValue
- the property value ornull
defaultValue
- the default string value- Returns:
- String value
-
toLong
public static long toLong(java.lang.Object propValue, long defaultValue)
Deprecated.Returns the parameter as a long or thedefaultValue
if the parameter isnull
or if the parameter is not aLong
and cannot be converted to aLong
from the parameter's string value.- Parameters:
propValue
- the property value ornull
defaultValue
- the default long value- Returns:
- Long value
-
toInteger
public static int toInteger(java.lang.Object propValue, int defaultValue)
Deprecated.Returns the parameter as an integer or thedefaultValue
if the parameter isnull
or if the parameter is not anInteger
and cannot be converted to anInteger
from the parameter's string value.- Parameters:
propValue
- the property value ornull
defaultValue
- the default integer value- Returns:
- Integer value
-
toDouble
public static double toDouble(java.lang.Object propValue, double defaultValue)
Deprecated.Returns the parameter as a double or thedefaultValue
if the parameter isnull
or if the parameter is not aDouble
and cannot be converted to aDouble
from the parameter's string value.- Parameters:
propValue
- the property value ornull
defaultValue
- the default double value- Returns:
- Double value
-
toObject
public static java.lang.Object toObject(java.lang.Object propValue)
Deprecated.Returns the parameter as a single value. If the parameter is neither an array nor ajava.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-emptyjava.util.Collection
, the first collection element is returned. Otherwisenull
is returned.- Parameters:
propValue
- the parameter to convert.- Returns:
- Object value
-
toStringArray
public static java.lang.String[] toStringArray(java.lang.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 isnull
)null
is returned.- Parameters:
propValue
- The object to convert.- Returns:
- String array value
-
toStringArray
public static java.lang.String[] toStringArray(java.lang.Object propValue, java.lang.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 isnull
) 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 java.util.Map<java.lang.String,java.lang.String> toMap(java.lang.Object propValue, java.lang.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
null
) a provided default value is returned.- Parameters:
propValue
- The object to convert.defaultArray
- The default array converted to map.- Returns:
- Map value
-
-