Package org.apache.sling.commons.osgi
Class OsgiUtil
java.lang.Object
org.apache.sling.commons.osgi.OsgiUtil
Deprecated.
The
OsgiUtil
is a utility class providing some usefull utility
methods.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.osgi.service.event.Event
createEvent
(org.osgi.framework.Bundle sourceBundle, org.osgi.framework.ServiceReference sourceService, String topic, Map<String, Object> props) Deprecated.Create an osgi event with the given topic and properties.static Comparable<Object>
Deprecated.Create a comparable object out of the service properties.static double
getProperty
(Object propValue, double defaultValue) Deprecated.since 2.0.4, usetoDouble(Object, double)
insteadstatic boolean
Deprecated.Returns the boolean value of the parameter or thedefaultValue
if the parameter isnull
.static double
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
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
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 Object
Deprecated.Returns the parameter as a single value.static String
Deprecated.Returns the parameter as a string or thedefaultValue
if the parameter isnull
.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.
-
Constructor Details
-
OsgiUtil
public OsgiUtil()Deprecated.
-
-
Method Details
-
toBoolean
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
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
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
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
-
getProperty
Deprecated.since 2.0.4, usetoDouble(Object, double)
insteadReturns 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
-
toDouble
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
- Since:
- 2.0.4
-
toObject
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
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
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
- Since:
- 2.0.4
-
createEvent
public static org.osgi.service.event.Event createEvent(org.osgi.framework.Bundle sourceBundle, org.osgi.framework.ServiceReference sourceService, String topic, Map<String, Object> props) Deprecated.Create an osgi event with the given topic and properties. If a bundle parameter is provided the symbolic name is added as a property. If a service parameter is provided, information about the service is added to the properties.- Parameters:
sourceBundle
- Optional source bundlesourceService
- Optional source servicetopic
- The event topic.props
- A non-null map of properties for the event.- Returns:
- The OSGi event.
-
getComparableForServiceRanking
Deprecated.Create a comparable object out of the service properties. With the result it is possible to compare service properties based on the service ranking of a service. Therefore this object acts likeServiceReference.compareTo(Object)
.- Parameters:
props
- The service properties.- Returns:
- A comparable for the ranking of the service
- Since:
- 2.0.6
-
org.osgi.util.converter.Converters
andServiceUtil
instead