Class OsgiUtil


  • @Deprecated
    public class OsgiUtil
    extends java.lang.Object
    Deprecated.
    Use org.osgi.util.converter.Converters and ServiceUtil instead
    The OsgiUtil is a utility class providing some usefull utility methods.
    • Constructor Summary

      Constructors 
      Constructor Description
      OsgiUtil()
      Deprecated.
       
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static Event createEvent​(Bundle sourceBundle, 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.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OsgiUtil

        public OsgiUtil()
        Deprecated.
    • Method Detail

      • toBoolean

        public 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. 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 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.
        Parameters:
        propValue - the property value or null
        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 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​(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.
        Parameters:
        propValue - the property value or null
        defaultValue - the default integer value
        Returns:
        Integer value
      • getProperty

        @Deprecated
        public static double getProperty​(java.lang.Object propValue,
                                         double defaultValue)
        Deprecated.
        since 2.0.4, use toDouble(Object, double) instead
        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
      • toDouble

        public 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.
        Parameters:
        propValue - the property value or null
        defaultValue - the default double value
        Returns:
        Double value
        Since:
        2.0.4
      • 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 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 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 is null) 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 is null) 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 Event createEvent​(Bundle sourceBundle,
                                        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. 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 bundle
        sourceService - Optional source service
        topic - The event topic.
        props - A non-null map of properties for the event.
        Returns:
        The OSGi event.
      • getComparableForServiceRanking

        public 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. With the result it is possible to compare service properties based on the service ranking of a service. Therefore this object acts like ServiceReference.compareTo(Object).
        Parameters:
        props - The service properties.
        Returns:
        A comparable for the ranking of the service
        Since:
        2.0.6