1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.sf.ldaptemplate.support.filter;
18
19 /***
20 * A filter for a logical AND. E.g.:
21 *
22 * <pre>
23 * AndFilter filter = new AndFilter();
24 * filter.and(new EqualsFilter("objectclass", "person");
25 * filter.and(new EqualsFilter("cn", "Some CN");
26 * System.out.println(filter.ecode());
27 * </pre>
28 *
29 * would result in: <code>(&(objectclass=person)(cn=Some CN))</code>
30 *
31 * @see net.sf.ldaptemplate.support.filter.EqualsFilter
32 * @author Adam Skogman
33 * @author Mattias Arthursson
34 */
35 public class AndFilter extends BinaryLogicalFilter {
36
37 private static final String AMPERSAND = "&";
38
39
40
41
42
43
44 protected String getLogicalOperator() {
45 return AMPERSAND;
46 }
47
48 /***
49 * Add a query to the and expression
50 *
51 * @param query
52 * The query to and with the rest of the and:ed queries.
53 * @return This LdapAndQuery
54 */
55 public AndFilter and(Filter query) {
56 queryList.add(query);
57 return this;
58 }
59 }