| /* |
| * Copyright (c) OSGi Alliance (2000, 2010). All Rights Reserved. |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| package org.osgi.framework; |
| |
| import java.util.Dictionary; |
| |
| /** |
| * An RFC 1960-based Filter. |
| * <p> |
| * {@code Filter}s can be created by calling |
| * {@link BundleContext#createFilter} or {@link FrameworkUtil#createFilter} with |
| * a filter string. |
| * <p> |
| * A {@code Filter} can be used numerous times to determine if the match |
| * argument matches the filter string that was used to create the |
| * {@code Filter}. |
| * <p> |
| * Some examples of LDAP filters are: |
| * |
| * <pre> |
| * "(cn=Babs Jensen)" |
| * "(!(cn=Tim Howes))" |
| * "(&(" + Constants.OBJECTCLASS + "=Person)(|(sn=Jensen)(cn=Babs J*)))" |
| * "(o=univ*of*mich*)" |
| * </pre> |
| * |
| * @since 1.1 |
| * @see "Core Specification, section 5.5, for a description of the filter string syntax." |
| * @ThreadSafe |
| * @version $Id: 7d78403e84d093db71d5aeb9c2028f859b902c0b $ |
| */ |
| public interface Filter { |
| /** |
| * Filter using a service's properties. |
| * <p> |
| * This {@code Filter} is executed using the keys and values of the |
| * referenced service's properties. The keys are case insensitively matched |
| * with this {@code Filter}. |
| * |
| * @param reference The reference to the service whose properties are used |
| * in the match. |
| * @return {@code true} if the service's properties match this |
| * {@code Filter}; {@code false} otherwise. |
| */ |
| public boolean match(ServiceReference< ? > reference); |
| |
| /** |
| * Filter using a {@code Dictionary}. This {@code Filter} is |
| * executed using the specified {@code Dictionary}'s keys and values. |
| * The keys are case insensitively matched with this {@code Filter}. |
| * |
| * @param dictionary The {@code Dictionary} whose keys are used in the |
| * match. |
| * @return {@code true} if the {@code Dictionary}'s keys and |
| * values match this filter; {@code false} otherwise. |
| * @throws IllegalArgumentException If {@code dictionary} contains case |
| * variants of the same key name. |
| */ |
| public boolean match(Dictionary<String, ? > dictionary); |
| |
| /** |
| * Returns this {@code Filter}'s filter string. |
| * <p> |
| * The filter string is normalized by removing whitespace which does not |
| * affect the meaning of the filter. |
| * |
| * @return This {@code Filter}'s filter string. |
| */ |
| public String toString(); |
| |
| /** |
| * Compares this {@code Filter} to another {@code Filter}. |
| * |
| * <p> |
| * This implementation returns the result of calling |
| * {@code this.toString().equals(obj.toString())}. |
| * |
| * @param obj The object to compare against this {@code Filter}. |
| * @return If the other object is a {@code Filter} object, then returns |
| * the result of calling |
| * {@code this.toString().equals(obj.toString())}; |
| * {@code false} otherwise. |
| */ |
| public boolean equals(Object obj); |
| |
| /** |
| * Returns the hashCode for this {@code Filter}. |
| * |
| * <p> |
| * This implementation returns the result of calling |
| * {@code this.toString().hashCode()}. |
| * |
| * @return The hashCode of this {@code Filter}. |
| */ |
| public int hashCode(); |
| |
| /** |
| * Filter with case sensitivity using a {@code Dictionary}. This |
| * {@code Filter} is executed using the specified |
| * {@code Dictionary}'s keys and values. The keys are case sensitively |
| * matched with this {@code Filter}. |
| * |
| * @param dictionary The {@code Dictionary} whose keys are used in the |
| * match. |
| * @return {@code true} if the {@code Dictionary}'s keys and |
| * values match this filter; {@code false} otherwise. |
| * @since 1.3 |
| */ |
| public boolean matchCase(Dictionary<String, ? > dictionary); |
| } |