org.apache.felix.framework
Class FilterImpl

java.lang.Object
  extended by org.apache.felix.framework.FilterImpl
All Implemented Interfaces:
org.osgi.framework.Filter

public class FilterImpl
extends java.lang.Object
implements org.osgi.framework.Filter

This class implements an RFC 1960-based filter. The syntax of the filter string is the string representation of LDAP search filters as defined in RFC 1960. These filters are used to search for services and to track services using ServiceTracker objects.


Constructor Summary
FilterImpl(Logger logger, java.lang.String expr)
          Construct a filter for a given filter expression string.
FilterImpl(java.lang.String expr)
           
 
Method Summary
 boolean equals(java.lang.Object o)
          Compares the Filter object to another.
 int hashCode()
          Returns the hash code for the Filter object.
 boolean match(java.util.Dictionary dict)
          Filter using a Dictionary object.
 boolean match(org.osgi.framework.ServiceReference ref)
          Filter using a service's properties.
 boolean matchCase(java.util.Dictionary dict)
           
 java.lang.String toString()
          Returns the Filter object's filter string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FilterImpl

public FilterImpl(java.lang.String expr)
           throws org.osgi.framework.InvalidSyntaxException
Throws:
org.osgi.framework.InvalidSyntaxException

FilterImpl

public FilterImpl(Logger logger,
                  java.lang.String expr)
           throws org.osgi.framework.InvalidSyntaxException
Construct a filter for a given filter expression string.

Parameters:
expr - the filter expression string for the filter.
Throws:
org.osgi.framework.InvalidSyntaxException
Method Detail

equals

public boolean equals(java.lang.Object o)
Compares the Filter object to another.

Specified by:
equals in interface org.osgi.framework.Filter
Overrides:
equals in class java.lang.Object
Parameters:
o - the object to compare this Filter against.
Returns:
If the other object is a Filter object, it returns this.toString().equals(obj.toString()); false otherwise.

hashCode

public int hashCode()
Returns the hash code for the Filter object.

Specified by:
hashCode in interface org.osgi.framework.Filter
Overrides:
hashCode in class java.lang.Object
Returns:
The value this.toString().hashCode().

match

public boolean match(java.util.Dictionary dict)
              throws java.lang.IllegalArgumentException
Filter using a Dictionary object. The Filter is executed using the Dictionary object's keys and values.

Specified by:
match in interface org.osgi.framework.Filter
Parameters:
dict - the Dictionary object whose keys and values are used to determine a match.
Returns:
true if the Dictionary object's keys and values match this filter; false otherwise.
Throws:
java.lang.IllegalArgumentException - if the dictionary contains case variants of the same key name.

match

public boolean match(org.osgi.framework.ServiceReference ref)
Filter using a service's properties. The Filter is executed using the properties of the referenced service.

Specified by:
match in interface org.osgi.framework.Filter
Parameters:
ref - A reference to the service whose properties are used to determine a match.
Returns:
true if the service's properties match this filter; false otherwise.

matchCase

public boolean matchCase(java.util.Dictionary dict)
Specified by:
matchCase in interface org.osgi.framework.Filter

toString

public java.lang.String toString()
Returns the Filter object's filter string.

Specified by:
toString in interface org.osgi.framework.Filter
Overrides:
toString in class java.lang.Object
Returns:
Filter string.