Package org.osgi.framework
Interface Filter
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*)"
- Since:
- 1.1
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares thisFilterto anotherFilter.inthashCode()Returns the hashCode for thisFilter.booleanmatch(Dictionary<String, ?> dictionary) Filter using aDictionarywith case insensitive key lookup.booleanmatch(ServiceReference<?> reference) Filter using a service's properties.booleanmatchCase(Dictionary<String, ?> dictionary) Filter using aDictionary.booleanFilter using aMap.toString()Returns thisFilter's filter string.
-
Method Details
-
match
Filter using a service's properties.This
Filteris 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:
trueif the service's properties match thisFilter;falseotherwise.
-
match
Filter using aDictionarywith case insensitive key lookup. ThisFilteris executed using the specifiedDictionary's keys and values. The keys are looked up in a case insensitive manner.- Parameters:
dictionary- TheDictionarywhose key/value pairs are used in the match.- Returns:
trueif theDictionary's values match this filter;falseotherwise.- Throws:
IllegalArgumentException- Ifdictionarycontains 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 thisFilterto 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. ThisFilteris executed using the specifiedDictionary's keys and values. The keys are looked up in a normal manner respecting case.- Parameters:
dictionary- TheDictionarywhose key/value pairs are used in the match.- Returns:
trueif theDictionary's values match this filter;falseotherwise.- Since:
- 1.3
-
matches
Filter using aMap. ThisFilteris executed using the specifiedMap's keys and values. The keys are looked up in a normal manner respecting case.- Parameters:
map- TheMapwhose key/value pairs are used in the match. Maps withnullkey or values are not supported. Anullvalue is considered not present to the filter.- Returns:
trueif theMap's values match this filter;falseotherwise.- Since:
- 1.6
-