Package org.apache.felix.utils.filter
Class FilterImpl
java.lang.Object
org.apache.felix.utils.filter.FilterImpl
- All Implemented Interfaces:
org.osgi.framework.Filter
This filter implementation is based on the official OSGi filter with additional
support for the SUPERSET (>*) and SUBSET (<*) operators.
This filter also has a few optimizations (cached transformation).
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares thisFilter
to anotherFilter
.int
hashCode()
Returns the hashCode for thisFilter
.boolean
match
(Dictionary dictionary) Filter using aDictionary
.boolean
match
(org.osgi.framework.ServiceReference reference) Filter using a service's properties.boolean
matchCase
(Dictionary dictionary) Filter with case sensitivity using aDictionary
.boolean
Filter using aMap
.boolean
Filter using aMap
.static FilterImpl
newInstance
(String filterString) Constructs aFilterImpl
object.static FilterImpl
newInstance
(String filterString, boolean ignoreCase) toString()
Returns thisFilter
's filter string.
-
Method Details
-
newInstance
public static FilterImpl newInstance(String filterString) throws org.osgi.framework.InvalidSyntaxException Constructs aFilterImpl
object. This filter object may be used to match aServiceReference
or a Dictionary.If the filter cannot be parsed, an
InvalidSyntaxException
will be thrown with a human readable message where the filter became unparsable.- Parameters:
filterString
- the filter string.- Returns:
- A new filter
- Throws:
org.osgi.framework.InvalidSyntaxException
- If the filter parameter contains an invalid filter string that cannot be parsed.
-
newInstance
public static FilterImpl newInstance(String filterString, boolean ignoreCase) throws org.osgi.framework.InvalidSyntaxException - Throws:
org.osgi.framework.InvalidSyntaxException
-
match
public boolean match(org.osgi.framework.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 case insensitively matched with thisFilter
.- Specified by:
match
in interfaceorg.osgi.framework.Filter
- 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
. ThisFilter
is executed using the specifiedDictionary
's keys and values. The keys are case insensitively matched with thisFilter
.- Specified by:
match
in interfaceorg.osgi.framework.Filter
- Parameters:
dictionary
- TheDictionary
whose keys are used in the match.- Returns:
true
if theDictionary
's keys and values match this filter;false
otherwise.- Throws:
IllegalArgumentException
- Ifdictionary
contains case variants of the same key name.
-
matchCase
Filter with case sensitivity using aDictionary
. ThisFilter
is executed using the specifiedDictionary
's keys and values. The keys are case sensitively matched with thisFilter
.- Specified by:
matchCase
in interfaceorg.osgi.framework.Filter
- Parameters:
dictionary
- TheDictionary
whose keys are used in the match.- Returns:
true
if theDictionary
's keys and values match this filter;false
otherwise.- Since:
- 1.3
-
matchCase
Filter using aMap
. ThisFilter
is executed using the specifiedMap
's keys and values. The keys are case insensitively matched with thisFilter
.- Parameters:
map
- TheMap
whose keys are used in the match.- Returns:
true
if theMap
's keys and values match this filter;false
otherwise.- Throws:
IllegalArgumentException
- Ifmap
contains case variants of the same key name.
-
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.- Specified by:
matches
in interfaceorg.osgi.framework.Filter
- 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
-
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
public int hashCode()Returns the hashCode for thisFilter
.This implementation returns the result of calling
this.toString().hashCode()
.
-