org.springframework.osgi.util
Class OsgiFilterUtils

java.lang.Object
  extended by org.springframework.osgi.util.OsgiFilterUtils

public abstract class OsgiFilterUtils
extends Object

Utility class for creating OSGi filters. This class allows filter creation and concatenation from common parameters such as class names.

Author:
Costin Leau

Constructor Summary
OsgiFilterUtils()
           
 
Method Summary
static Filter createFilter(String filter)
          Creates an OSGi Filter from the given String.
static boolean isValidFilter(String filter)
          Validates the given String as a OSGi filter.
static String unifyFilter(Class[] classes, String filter)
          Adds the given classes to the given filter.
static String unifyFilter(Class clazz, String filter)
          Adds the given class to the given filter.
static String unifyFilter(String[] classes, String filter)
          Adds the given classes as an 'and'(&) Constants.OBJECTCLASS constraint to the given filter.
static String unifyFilter(String clazz, String filter)
          Adds the given class as an 'and'(&) Constants.OBJECTCLASS constraint to the given filter.
static String unifyFilter(String key, String[] items, String filter)
          Concatenates the given strings with an 'and'(&) constraint under the given key to the given filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OsgiFilterUtils

public OsgiFilterUtils()
Method Detail

unifyFilter

public static String unifyFilter(String clazz,
                                 String filter)
Adds the given class as an 'and'(&) Constants.OBJECTCLASS constraint to the given filter. At least one parameter must be valid (non-null).

Parameters:
clazz - class name (can be null)
filter - valid OSGi filter (can be null)
Returns:
OSGi filter containing the Constants.OBJECTCLASS constraint and the given filter

unifyFilter

public static String unifyFilter(Class clazz,
                                 String filter)
Adds the given class to the given filter. At least one parameter must be valid (non-null).

Parameters:
clazz - fully qualified class name (can be null)
filter - valid OSGi filter (can be null)
Returns:
an OSGi filter concatenating the given parameters
See Also:
unifyFilter(String, String)

unifyFilter

public static String unifyFilter(Class[] classes,
                                 String filter)
Adds the given classes to the given filter. At least one parameter must be valid (non-null).

Parameters:
classes - array of fully qualified class names (can be null/empty)
filter - valid OSGi filter (can be null)
Returns:
an OSGi filter concatenating the given parameters
See Also:
unifyFilter(String[], String)

unifyFilter

public static String unifyFilter(String[] classes,
                                 String filter)
Adds the given classes as an 'and'(&) Constants.OBJECTCLASS constraint to the given filter. At least one parameter must be valid (non-null).

Parameters:
classes - array of fully qualified class names (can be null/empty)
filter - valid OSGi filter (can be null)
Returns:
an OSGi filter concatenating the given parameters

unifyFilter

public static String unifyFilter(String key,
                                 String[] items,
                                 String filter)
Concatenates the given strings with an 'and'(&) constraint under the given key to the given filter. At least one of the items/filter parameters must be valid (non-null).

Parameters:
key - the key under which the items are being concatenated (required)
items - an array of strings concatenated to the existing filter
filter - valid OSGi filter (can be null)
Returns:
an OSGi filter concatenating the given parameters

isValidFilter

public static boolean isValidFilter(String filter)
Validates the given String as a OSGi filter.

Parameters:
filter - OSGi filter
Returns:
true if the filter is valid, false otherwise

createFilter

public static Filter createFilter(String filter)
Creates an OSGi Filter from the given String. Translates the InvalidSyntaxException checked exception into an unchecked IllegalArgumentException.

Parameters:
filter - OSGi filter given as a String
Returns:
OSGi filter (as Filter)


Copyright © 2006-2009 Spring Framework. All Rights Reserved.