Top Description Methods
org.osgi.framework

public Interface Filter

Known Direct Implementers
org.osgi.framework.FilterImpl
Annotations
@ProviderType
Imports
java.util.Dictionary, .Map, org.osgi.annotation.versioning.ProviderType

An RFC 1960-based Filter.

Filters can be created by calling BundleContext#createFilter(String) or FrameworkUtil#createFilter(String) with a filter string.

A Filter can be used numerous times to determine if the match argument matches the filter string that was used to create the Filter.

Some examples of LDAP filters are:

 "(cn=Babs Jensen)"
 "(!(cn=Tim Howes))"
 "(&(" + Constants.OBJECTCLASS + "=Person)(|(sn=Jensen)(cn=Babs J*)))"
 "(o=univ*of*mich*)"
Author
$Id: b8bf786f2bde901997f24c6f1bcff61320a533fe $
Since
1.1
See Also
Core Specification, Filters, for a description of the filter string syntax.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

If the other object is a Filter object, then returns the result of calling this.toString().equals(obj.toString()); false otherwise.
equals
(Object
The object to compare against this Filter.
obj
)

Compares this Filter to another Filter.

public int

Returns:

The hashCode of this Filter.
hashCode
()

Returns the hashCode for this Filter.

public boolean

Returns:

true if the service's properties match this Filter; false otherwise.
match
(ServiceReference<?>
The reference to the service whose properties are used in the match.
reference
)

Filter using a service's properties.

public boolean

Returns:

true if the Dictionary's values match this filter; false otherwise.
match
(Dictionary<String, ?>
The Dictionary whose key/value pairs are used in the match.
dictionary
)

Filter using a Dictionary with case insensitive key lookup.

public boolean

Returns:

true if the Dictionary's values match this filter; false otherwise.
matchCase
(Dictionary<String, ?>
The Dictionary whose key/value pairs are used in the match.
dictionary
)

Filter using a Dictionary.

public boolean

Returns:

true if the Map's values match this filter; false otherwise.
matches
(Map<String, ?>
The Map whose key/value pairs are used in the match. Maps with null key or values are not supported. A null value is considered not present to the filter.
map
)

Filter using a Map.

public String

Returns:

This Filter's filter string.
toString
()

Returns this Filter's filter string.

Method Detail

equalsback to summary
public boolean equals(Object obj)

Compares this Filter to another Filter.

This implementation returns the result of calling this.toString().equals(obj.toString()).

Parameters
obj:Object

The object to compare against this Filter.

Returns:boolean

If the other object is a Filter object, then returns the result of calling this.toString().equals(obj.toString()); false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Returns the hashCode for this Filter.

This implementation returns the result of calling this.toString().hashCode().

Returns:int

The hashCode of this Filter.

Annotations
@Override
matchback to summary
public boolean match(ServiceReference<?> reference)

Filter using a service's properties.

This Filter is executed using the keys and values of the referenced service's properties. The keys are looked up in a case insensitive manner.

Parameters
reference:ServiceReference<?>

The reference to the service whose properties are used in the match.

Returns:boolean

true if the service's properties match this Filter; false otherwise.

matchback to summary
public boolean match(Dictionary<String, ?> dictionary)

Filter using a Dictionary with case insensitive key lookup. This Filter is executed using the specified Dictionary's keys and values. The keys are looked up in a case insensitive manner.

Parameters
dictionary:Dictionary<String, ?>

The Dictionary whose key/value pairs are used in the match.

Returns:boolean

true if the Dictionary's values match this filter; false otherwise.

Exceptions
IllegalArgumentException:
If dictionary contains case variants of the same key name.
matchCaseback to summary
public boolean matchCase(Dictionary<String, ?> dictionary)

Filter using a Dictionary. This Filter is executed using the specified Dictionary's keys and values. The keys are looked up in a normal manner respecting case.

Parameters
dictionary:Dictionary<String, ?>

The Dictionary whose key/value pairs are used in the match.

Returns:boolean

true if the Dictionary's values match this filter; false otherwise.

Since
1.3
matchesback to summary
public boolean matches(Map<String, ?> map)

Filter using a Map. This Filter is executed using the specified Map's keys and values. The keys are looked up in a normal manner respecting case.

Parameters
map:Map<String, ?>

The Map whose key/value pairs are used in the match. Maps with null key or values are not supported. A null value is considered not present to the filter.

Returns:boolean

true if the Map's values match this filter; false otherwise.

Since
1.6
toStringback to summary
public String toString()

Returns this Filter's filter string.

The filter string is normalized by removing whitespace which does not affect the meaning of the filter.

Returns:String

This Filter's filter string.

Annotations
@Override