|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.sling.commons.osgi.OsgiUtil
public class OsgiUtil
The OsgiUtil is a utility class providing some usefull utility
methods.
| Constructor Summary | |
|---|---|
OsgiUtil()
|
|
| Method Summary | |
|---|---|
static org.osgi.service.event.Event |
createEvent(org.osgi.framework.Bundle sourceBundle,
org.osgi.framework.ServiceReference sourceService,
String topic,
Map<String,Object> props)
Create an osgi event with the given topic and properties. |
static Comparable<Object> |
getComparableForServiceRanking(Map<String,Object> props)
Create a comparable object out of the service properties. |
static double |
getProperty(Object propValue,
double defaultValue)
Deprecated. since 2.0.4, use toDouble(Object, double) instead |
static boolean |
toBoolean(Object propValue,
boolean defaultValue)
Returns the boolean value of the parameter or the defaultValue if the parameter is null. |
static double |
toDouble(Object propValue,
double defaultValue)
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)
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)
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 Object |
toObject(Object propValue)
Returns the parameter as a single value. |
static String |
toString(Object propValue,
String defaultValue)
Returns the parameter as a string or the defaultValue if the parameter is null. |
static String[] |
toStringArray(Object propValue)
Returns the parameter as an array of Strings. |
static String[] |
toStringArray(Object propValue,
String[] defaultArray)
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 |
|---|
public OsgiUtil()
| Method Detail |
|---|
public static boolean toBoolean(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 nulldefaultValue - the default boolean value
public static String toString(Object propValue,
String defaultValue)
defaultValue if the parameter is null.
propValue - the property value or nulldefaultValue - the default string value
public static long toLong(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 nulldefaultValue - the default long value
public static int toInteger(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 nulldefaultValue - the default integer value
@Deprecated
public static double getProperty(Object propValue,
double defaultValue)
toDouble(Object, double) instead
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 nulldefaultValue - the default double value
public static double toDouble(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 nulldefaultValue - the default double valuepublic static Object toObject(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 String[] toStringArray(Object propValue)
null) null is
returned.
propValue - The object to convert.
public static String[] toStringArray(Object propValue,
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,
String topic,
Map<String,Object> props)
sourceBundle - Optional source bundlesourceService - Optional source servicetopic - The event topic.props - A non-null map of properties for the event.
public static Comparable<Object> getComparableForServiceRanking(Map<String,Object> props)
ServiceReference.compareTo(Object).
props - The service properties.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||