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 OSGi filters.

Allows filter creation(as well as modication) using multiple classnames.

Author:
Costin Leau

Constructor Summary
OsgiFilterUtils()
           
 
Method Summary
static Filter createFilter(String filter)
          Create an OSGi filter from the given String.
static boolean isValidFilter(String filter)
          Validate the given String as a OSGi filter.
static String unifyFilter(Class[] classes, String filter)
          Add the given classes to the given filter.
static String unifyFilter(Class clazz, String filter)
          Add the given class to the given filter.
static String unifyFilter(String[] classes, String filter)
          Add the given classese as an 'and'(&) Constants.OBJECTCLASS constraint to the given filter.
static String unifyFilter(String clazz, String filter)
          Add 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)
Add 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 - an existing, valid filter
Returns:
updated filter containg the Constants.OBJECTCLASS constraint

unifyFilter

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

Parameters:
clazz -
filter -
Returns:
See Also:
unifyFilter(String, String)

unifyFilter

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

Parameters:
classes -
filter -
Returns:
See Also:
unifyFilter(String[], String)

unifyFilter

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

Parameters:
classes - array of classes name - can be null/empty
filter - an existing, valid filter
Returns:
updated filter containg the Constants.OBJECTCLASS constraint

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 parameter must be valid (non-null). At least the filter or the key and the items have to be not null.

Parameters:
key - the key under which the items are being concatenated
items - an array of strings concatenated to the existing filter
filter - an existing, valid filter
Returns:
updated filter containg the new constraint

isValidFilter

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

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

createFilter

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

Parameters:
filter - filter string representation
Returns:
OSGi filter


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