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 $
|
105
|
3 *
|
86
|
4 * Copyright (c) OSGi Alliance (2000, 2007). All Rights Reserved.
|
105
|
5 *
|
86
|
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 */
|
105
|
18 // Port to the D programming language:
|
|
19 // Frank Benoit <benoit@tionex.de>
|
86
|
20 module org.osgi.framework.Filter;
|
|
21
|
|
22 import java.lang.all;
|
105
|
23
|
|
24 import org.osgi.framework.ServiceReference; // packageimport
|
|
25
|
86
|
26 import java.util.Dictionary;
|
|
27
|
|
28 /**
|
|
29 * An RFC 1960-based Filter.
|
|
30 * <p>
|
|
31 * <code>Filter</code> objects can be created by calling
|
|
32 * {@link BundleContext#createFilter} with the chosen filter string.
|
|
33 * <p>
|
|
34 * A <code>Filter</code> object can be used numerous times to determine if the
|
|
35 * match argument matches the filter string that was used to create the
|
|
36 * <code>Filter</code> object.
|
|
37 * <p>
|
|
38 * Some examples of LDAP filters are:
|
105
|
39 *
|
86
|
40 * <pre>
|
|
41 * "(cn=Babs Jensen)"
|
|
42 * "(!(cn=Tim Howes))"
|
|
43 * "(&(" + Constants.OBJECTCLASS + "=Person)(|(sn=Jensen)(cn=Babs J*)))"
|
|
44 * "(o=univ*of*mich*)"
|
|
45 * </pre>
|
105
|
46 *
|
86
|
47 * @since 1.1
|
|
48 * @see "Core Specification, section 5.5, for a description of the filter string
|
|
49 * syntax."
|
|
50 * @ThreadSafe
|
|
51 * @version $Revision: 1.16 $
|
|
52 */
|
|
53 public interface Filter {
|
|
54 /**
|
|
55 * Filter using a service's properties.
|
|
56 * <p>
|
|
57 * The filter is executed using the keys and values of the referenced
|
|
58 * service's properties. The keys are case insensitively matched with the
|
|
59 * filter.
|
105
|
60 *
|
86
|
61 * @param reference The reference to the service whose properties are used
|
|
62 * in the match.
|
105
|
63 *
|
86
|
64 * @return <code>true</code> if the service's properties match this
|
|
65 * filter; <code>false</code> otherwise.
|
|
66 */
|
|
67 public bool match(ServiceReference reference);
|
|
68
|
|
69 /**
|
|
70 * Filter using a <code>Dictionary</code> object. The Filter is executed
|
|
71 * using the <code>Dictionary</code> object's keys and values. The keys
|
|
72 * are case insensitively matched with the filter.
|
105
|
73 *
|
86
|
74 * @param dictionary The <code>Dictionary</code> object whose keys are
|
|
75 * used in the match.
|
105
|
76 *
|
86
|
77 * @return <code>true</code> if the <code>Dictionary</code> object's
|
|
78 * keys and values match this filter; <code>false</code>
|
|
79 * otherwise.
|
105
|
80 *
|
86
|
81 * @throws IllegalArgumentException If <code>dictionary</code> contains
|
|
82 * case variants of the same key name.
|
|
83 */
|
|
84 public bool match(Dictionary dictionary);
|
|
85
|
|
86 /**
|
|
87 * Returns this <code>Filter</code> object's filter string.
|
|
88 * <p>
|
|
89 * The filter string is normalized by removing whitespace which does not
|
|
90 * affect the meaning of the filter.
|
105
|
91 *
|
86
|
92 * @return Filter string.
|
|
93 */
|
|
94 public String toString();
|
|
95
|
|
96 /**
|
|
97 * Compares this <code>Filter</code> object to another object.
|
105
|
98 *
|
86
|
99 * @param obj The object to compare against this <code>Filter</code>
|
|
100 * object.
|
105
|
101 *
|
86
|
102 * @return If the other object is a <code>Filter</code> object, then
|
|
103 * returns <code>this.toString().equals(obj.toString()</code>;<code>false</code>
|
|
104 * otherwise.
|
|
105 */
|
105
|
106 public equals_t opEquals(Object obj);
|
86
|
107
|
|
108 /**
|
|
109 * Returns the hashCode for this <code>Filter</code> object.
|
105
|
110 *
|
86
|
111 * @return The hashCode of the filter string; that is,
|
|
112 * <code>this.toString().hashCode()</code>.
|
|
113 */
|
105
|
114 public hash_t toHash();
|
86
|
115
|
|
116 /**
|
|
117 * Filter with case sensitivity using a <code>Dictionary</code> object.
|
|
118 * The Filter is executed using the <code>Dictionary</code> object's keys
|
|
119 * and values. The keys are case sensitively matched with the filter.
|
105
|
120 *
|
86
|
121 * @param dictionary The <code>Dictionary</code> object whose keys are
|
|
122 * used in the match.
|
105
|
123 *
|
86
|
124 * @return <code>true</code> if the <code>Dictionary</code> object's
|
|
125 * keys and values match this filter; <code>false</code>
|
|
126 * otherwise.
|
105
|
127 *
|
86
|
128 * @since 1.3
|
|
129 */
|
|
130 public bool matchCase(Dictionary dictionary);
|
|
131 }
|