@Deprecated
public class OsgiUtil
extends java.lang.Object
OsgiUtil
is a utility class providing some usefull utility
methods.Constructor and Description |
---|
OsgiUtil()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static org.osgi.service.event.Event |
createEvent(org.osgi.framework.Bundle sourceBundle,
org.osgi.framework.ServiceReference sourceService,
java.lang.String topic,
java.util.Map<java.lang.String,java.lang.Object> props)
Deprecated.
Create an osgi event with the given topic and properties.
|
static java.lang.Comparable<java.lang.Object> |
getComparableForServiceRanking(java.util.Map<java.lang.String,java.lang.Object> props)
Deprecated.
Create a comparable object out of the service properties.
|
static double |
getProperty(java.lang.Object propValue,
double defaultValue)
Deprecated.
since 2.0.4, use
toDouble(Object, double) instead |
static boolean |
toBoolean(java.lang.Object propValue,
boolean defaultValue)
Deprecated.
Returns the boolean value of the parameter or the
defaultValue if the parameter is null . |
static double |
toDouble(java.lang.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(java.lang.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(java.lang.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 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 the
defaultValue if the parameter is null . |
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.
|
public static boolean toBoolean(java.lang.Object propValue, boolean defaultValue)
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.propValue
- the property value or null
defaultValue
- the default boolean valuepublic static java.lang.String toString(java.lang.Object propValue, java.lang.String defaultValue)
defaultValue
if the parameter is null
.propValue
- the property value or null
defaultValue
- the default string valuepublic static long toLong(java.lang.Object propValue, long defaultValue)
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.propValue
- the property value or null
defaultValue
- the default long valuepublic static int toInteger(java.lang.Object propValue, int defaultValue)
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.propValue
- the property value or null
defaultValue
- the default integer value@Deprecated public static double getProperty(java.lang.Object propValue, double defaultValue)
toDouble(Object, double)
insteaddefaultValue
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.propValue
- the property value or null
defaultValue
- the default double valuepublic static double toDouble(java.lang.Object propValue, double defaultValue)
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.propValue
- the property value or null
defaultValue
- the default double valuepublic static java.lang.Object toObject(java.lang.Object propValue)
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.propValue
- the parameter to convert.public static java.lang.String[] toStringArray(java.lang.Object propValue)
null
) null
is
returned.propValue
- The object to convert.public static java.lang.String[] toStringArray(java.lang.Object propValue, java.lang.String[] defaultArray)
null
) a provided default value is
returned.propValue
- The object to convert.defaultArray
- The default array to return.public static org.osgi.service.event.Event createEvent(org.osgi.framework.Bundle sourceBundle, org.osgi.framework.ServiceReference sourceService, java.lang.String topic, java.util.Map<java.lang.String,java.lang.Object> props)
sourceBundle
- Optional source bundlesourceService
- Optional source servicetopic
- The event topic.props
- A non-null map of properties for the event.public static java.lang.Comparable<java.lang.Object> getComparableForServiceRanking(java.util.Map<java.lang.String,java.lang.Object> props)
ServiceReference.compareTo(Object)
.props
- The service properties.Copyright © 2018 The Apache Software Foundation. All rights reserved.