86
|
1 /*
|
|
2 * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/Filter.java,v 1.16 2007/02/21 16:49:05 hargrave Exp $
|
|
3 *
|
|
4 * Copyright (c) OSGi Alliance (2000, 2007). All Rights Reserved.
|
|
5 *
|
|
6 * Licensed under the Apache License, Version 2.0 (the "License");
|
|
7 * you may not use this file except in compliance with the License.
|
|
8 * You may obtain a copy of the License at
|
|
9 *
|
|
10 * http://www.apache.org/licenses/LICENSE-2.0
|
|
11 *
|
|
12 * Unless required by applicable law or agreed to in writing, software
|
|
13 * distributed under the License is distributed on an "AS IS" BASIS,
|
|
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15 * See the License for the specific language governing permissions and
|
|
16 * limitations under the License.
|
|
17 */
|
|
18 module org.osgi.framework.Filter;
|
|
19 import org.osgi.framework.ServiceReference;
|
|
20
|
|
21 import java.lang.all;
|
|
22 import java.util.Dictionary;
|
|
23
|
|
24 /**
|
|
25 * An RFC 1960-based Filter.
|
|
26 * <p>
|
|
27 * <code>Filter</code> objects can be created by calling
|
|
28 * {@link BundleContext#createFilter} with the chosen filter string.
|
|
29 * <p>
|
|
30 * A <code>Filter</code> object can be used numerous times to determine if the
|
|
31 * match argument matches the filter string that was used to create the
|
|
32 * <code>Filter</code> object.
|
|
33 * <p>
|
|
34 * Some examples of LDAP filters are:
|
|
35 *
|
|
36 * <pre>
|
|
37 * "(cn=Babs Jensen)"
|
|
38 * "(!(cn=Tim Howes))"
|
|
39 * "(&(" + Constants.OBJECTCLASS + "=Person)(|(sn=Jensen)(cn=Babs J*)))"
|
|
40 * "(o=univ*of*mich*)"
|
|
41 * </pre>
|
|
42 *
|
|
43 * @since 1.1
|
|
44 * @see "Core Specification, section 5.5, for a description of the filter string
|
|
45 * syntax."
|
|
46 * @ThreadSafe
|
|
47 * @version $Revision: 1.16 $
|
|
48 */
|
|
49 public interface Filter {
|
|
50 /**
|
|
51 * Filter using a service's properties.
|
|
52 * <p>
|
|
53 * The filter is executed using the keys and values of the referenced
|
|
54 * service's properties. The keys are case insensitively matched with the
|
|
55 * filter.
|
|
56 *
|
|
57 * @param reference The reference to the service whose properties are used
|
|
58 * in the match.
|
|
59 *
|
|
60 * @return <code>true</code> if the service's properties match this
|
|
61 * filter; <code>false</code> otherwise.
|
|
62 */
|
|
63 public bool match(ServiceReference reference);
|
|
64
|
|
65 /**
|
|
66 * Filter using a <code>Dictionary</code> object. The Filter is executed
|
|
67 * using the <code>Dictionary</code> object's keys and values. The keys
|
|
68 * are case insensitively matched with the filter.
|
|
69 *
|
|
70 * @param dictionary The <code>Dictionary</code> object whose keys are
|
|
71 * used in the match.
|
|
72 *
|
|
73 * @return <code>true</code> if the <code>Dictionary</code> object's
|
|
74 * keys and values match this filter; <code>false</code>
|
|
75 * otherwise.
|
|
76 *
|
|
77 * @throws IllegalArgumentException If <code>dictionary</code> contains
|
|
78 * case variants of the same key name.
|
|
79 */
|
|
80 public bool match(Dictionary dictionary);
|
|
81
|
|
82 /**
|
|
83 * Returns this <code>Filter</code> object's filter string.
|
|
84 * <p>
|
|
85 * The filter string is normalized by removing whitespace which does not
|
|
86 * affect the meaning of the filter.
|
|
87 *
|
|
88 * @return Filter string.
|
|
89 */
|
|
90 public String toString();
|
|
91
|
|
92 /**
|
|
93 * Compares this <code>Filter</code> object to another object.
|
|
94 *
|
|
95 * @param obj The object to compare against this <code>Filter</code>
|
|
96 * object.
|
|
97 *
|
|
98 * @return If the other object is a <code>Filter</code> object, then
|
|
99 * returns <code>this.toString().equals(obj.toString()</code>;<code>false</code>
|
|
100 * otherwise.
|
|
101 */
|
|
102 public bool equals(Object obj);
|
|
103
|
|
104 /**
|
|
105 * Returns the hashCode for this <code>Filter</code> object.
|
|
106 *
|
|
107 * @return The hashCode of the filter string; that is,
|
|
108 * <code>this.toString().hashCode()</code>.
|
|
109 */
|
|
110 public int hashCode();
|
|
111
|
|
112 /**
|
|
113 * Filter with case sensitivity using a <code>Dictionary</code> object.
|
|
114 * The Filter is executed using the <code>Dictionary</code> object's keys
|
|
115 * and values. The keys are case sensitively matched with the filter.
|
|
116 *
|
|
117 * @param dictionary The <code>Dictionary</code> object whose keys are
|
|
118 * used in the match.
|
|
119 *
|
|
120 * @return <code>true</code> if the <code>Dictionary</code> object's
|
|
121 * keys and values match this filter; <code>false</code>
|
|
122 * otherwise.
|
|
123 *
|
|
124 * @since 1.3
|
|
125 */
|
|
126 public bool matchCase(Dictionary dictionary);
|
|
127 }
|