Package org.apache.felix.utils.filter
Class FilterImpl
- java.lang.Object
-
- org.apache.felix.utils.filter.FilterImpl
-
- All Implemented Interfaces:
org.osgi.framework.Filter
public class FilterImpl extends java.lang.Object implements org.osgi.framework.FilterThis 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Compares thisFilterto anotherFilter.inthashCode()Returns the hashCode for thisFilter.booleanmatch(java.util.Dictionary dictionary)Filter using aDictionary.booleanmatch(org.osgi.framework.ServiceReference reference)Filter using a service's properties.booleanmatchCase(java.util.Dictionary dictionary)Filter with case sensitivity using aDictionary.booleanmatchCase(java.util.Map map)Filter using aMap.booleanmatches(java.util.Map<java.lang.String,?> map)Filter using aMap.static FilterImplnewInstance(java.lang.String filterString)Constructs aFilterImplobject.static FilterImplnewInstance(java.lang.String filterString, boolean ignoreCase)java.lang.StringtoString()Returns thisFilter's filter string.
-
-
-
Method Detail
-
newInstance
public static FilterImpl newInstance(java.lang.String filterString) throws org.osgi.framework.InvalidSyntaxException
Constructs aFilterImplobject. This filter object may be used to match aServiceReferenceor a Dictionary.If the filter cannot be parsed, an
InvalidSyntaxExceptionwill 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(java.lang.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
Filteris executed using the keys and values of the referenced service's properties. The keys are case insensitively matched with thisFilter.- Specified by:
matchin interfaceorg.osgi.framework.Filter- Parameters:
reference- The reference to the service whose properties are used in the match.- Returns:
trueif the service's properties match thisFilter;falseotherwise.
-
match
public boolean match(java.util.Dictionary dictionary)
Filter using aDictionary. ThisFilteris executed using the specifiedDictionary's keys and values. The keys are case insensitively matched with thisFilter.- Specified by:
matchin interfaceorg.osgi.framework.Filter- Parameters:
dictionary- TheDictionarywhose keys are used in the match.- Returns:
trueif theDictionary's keys and values match this filter;falseotherwise.- Throws:
java.lang.IllegalArgumentException- Ifdictionarycontains case variants of the same key name.
-
matchCase
public boolean matchCase(java.util.Dictionary dictionary)
Filter with case sensitivity using aDictionary. ThisFilteris executed using the specifiedDictionary's keys and values. The keys are case sensitively matched with thisFilter.- Specified by:
matchCasein interfaceorg.osgi.framework.Filter- Parameters:
dictionary- TheDictionarywhose keys are used in the match.- Returns:
trueif theDictionary's keys and values match this filter;falseotherwise.- Since:
- 1.3
-
matchCase
public boolean matchCase(java.util.Map map)
Filter using aMap. ThisFilteris executed using the specifiedMap's keys and values. The keys are case insensitively matched with thisFilter.- Parameters:
map- TheMapwhose keys are used in the match.- Returns:
trueif theMap's keys and values match this filter;falseotherwise.- Throws:
java.lang.IllegalArgumentException- Ifmapcontains case variants of the same key name.
-
matches
public boolean matches(java.util.Map<java.lang.String,?> map)
Filter using aMap. ThisFilteris executed using the specifiedMap's keys and values. The keys are case insensitively matched with thisFilter.- Specified by:
matchesin interfaceorg.osgi.framework.Filter- Parameters:
map- TheMapwhose keys are used in the match.- Returns:
trueif theMap's keys and values match this filter;falseotherwise.- Throws:
java.lang.IllegalArgumentException- Ifmapcontains case variants of the same key name.
-
toString
public java.lang.String toString()
Returns thisFilter's filter string.The filter string is normalized by removing whitespace which does not affect the meaning of the filter.
- Specified by:
toStringin interfaceorg.osgi.framework.Filter- Overrides:
toStringin classjava.lang.Object- Returns:
- This
Filter's filter string.
-
equals
public boolean equals(java.lang.Object obj)
Compares thisFilterto anotherFilter.This implementation returns the result of calling
this.toString().equals(obj.toString().- Specified by:
equalsin interfaceorg.osgi.framework.Filter- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- The object to compare against thisFilter.- Returns:
- If the other object is a
Filterobject, then returns the result of callingthis.toString().equals(obj.toString();falseotherwise.
-
hashCode
public int hashCode()
Returns the hashCode for thisFilter.This implementation returns the result of calling
this.toString().hashCode().- Specified by:
hashCodein interfaceorg.osgi.framework.Filter- Overrides:
hashCodein classjava.lang.Object- Returns:
- The hashCode of this
Filter.
-
-