Package org.osgi.framework
Interface Filter
@ProviderType
public interface Filter
An RFC 1960-based Filter.
Filter
s 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*)"
- Since:
- 1.1
- See Also:
-
- "Core Specification, Filters, for a description of the filter string syntax."
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares thisFilter
to anotherFilter
.int
hashCode()
Returns the hashCode for thisFilter
.boolean
match
(Dictionary<String, ?> dictionary) Filter using aDictionary
with case insensitive key lookup.boolean
match
(ServiceReference<?> reference) Filter using a service's properties.boolean
matchCase
(Dictionary<String, ?> dictionary) Filter using aDictionary
.boolean
Filter using aMap
.toString()
Returns thisFilter
's filter string.
-
Method Details
-
match
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
- The reference to the service whose properties are used in the match.- Returns:
true
if the service's properties match thisFilter
;false
otherwise.
-
match
Filter using aDictionary
with case insensitive key lookup. ThisFilter
is executed using the specifiedDictionary
's keys and values. The keys are looked up in a case insensitive manner.- Parameters:
dictionary
- TheDictionary
whose key/value pairs are used in the match.- Returns:
true
if theDictionary
's values match this filter;false
otherwise.- Throws:
IllegalArgumentException
- Ifdictionary
contains case variants of the same key name.
-
toString
String toString()Returns thisFilter
's filter string.The filter string is normalized by removing whitespace which does not affect the meaning of the filter.
-
equals
Compares thisFilter
to anotherFilter
.This implementation returns the result of calling
this.toString().equals(obj.toString())
. -
hashCode
int hashCode()Returns the hashCode for thisFilter
.This implementation returns the result of calling
this.toString().hashCode()
. -
matchCase
Filter using aDictionary
. ThisFilter
is executed using the specifiedDictionary
's keys and values. The keys are looked up in a normal manner respecting case.- Parameters:
dictionary
- TheDictionary
whose key/value pairs are used in the match.- Returns:
true
if theDictionary
's values match this filter;false
otherwise.- Since:
- 1.3
-
matches
Filter using aMap
. ThisFilter
is executed using the specifiedMap
's keys and values. The keys are looked up in a normal manner respecting case.- Parameters:
map
- TheMap
whose key/value pairs are used in the match. Maps withnull
key or values are not supported. Anull
value is considered not present to the filter.- Returns:
true
if theMap
's values match this filter;false
otherwise.- Since:
- 1.6
-