View Javadoc

1   /*
2    * Copyright 2002-2005 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package net.sf.ldaptemplate.support.filter;
18  
19  /***
20   * Filter for logical OR.
21   * 
22   * <pre>
23   *        AndFilter filter = new AndFilter();
24   *        filter.or(new EqualsFilter(&quot;objectclass&quot;, &quot;person&quot;);
25   *        filter.or(new EqualsFilter(&quot;objectclass&quot;, &quot;organizationalUnit&quot;);
26   *        System.out.println(filter.ecode());    
27   * </pre>
28   * 
29   * would result in:
30   * <code>(|(objectclass=person)(objectclass=organizationalUnit))</code>
31   * 
32   * @author Adam Skogman
33   * @author Mattias Arthursson
34   */
35  public class OrFilter extends BinaryLogicalFilter {
36  
37      private static final String PIPE_SIGN = "|";
38  
39      /***
40       * Add a query to the OR expression
41       * 
42       * @param query
43       *            The query to or with the rest of the or:ed queries.
44       * @return This LdapOrQuery
45       */
46      public OrFilter or(Filter query) {
47          queryList.add(query);
48          return this;
49      }
50  
51      /*
52       * (non-Javadoc)
53       * 
54       * @see net.sf.ldaptemplate.support.filter.BinaryLogicalFilter#getLogicalOperator()
55       */
56      protected String getLogicalOperator() {
57          return PIPE_SIGN;
58      }
59  }