View Javadoc

1   /*
2    * $Id: OrFilter.java 7976 2007-08-21 14:26:13Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.routing.filters.logic;
12  
13  import org.mule.umo.UMOFilter;
14  import org.mule.umo.UMOMessage;
15  
16  /**
17   * <code>OrFilter</code> accepts if the leftFilter or rightFilter filter accept.
18   */
19  
20  public class OrFilter implements UMOFilter
21  {
22      private UMOFilter leftFilter;
23      private UMOFilter rightFilter;
24  
25      public OrFilter(UMOFilter leftFilter, UMOFilter rightFilder)
26      {
27          this.leftFilter = leftFilter;
28          this.rightFilter = rightFilder;
29      }
30  
31      public OrFilter()
32      {
33          super();
34      }
35  
36      public void setLeftFilter(UMOFilter leftFilter)
37      {
38          this.leftFilter = leftFilter;
39      }
40  
41      public void setRightFilter(UMOFilter rightFilter)
42      {
43          this.rightFilter = rightFilter;
44      }
45  
46      public UMOFilter getLeftFilter()
47      {
48          return leftFilter;
49      }
50  
51      public UMOFilter getRightFilter()
52      {
53          return rightFilter;
54      }
55  
56      public boolean accept(UMOMessage message)
57      {
58          return ((leftFilter != null && leftFilter.accept(message)) || (rightFilter != null && rightFilter
59              .accept(message)));
60      }
61  
62  }