KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > routing > filters > logic > AndFilter


1 /*
2  * $Id: AndFilter.java 4219 2006-12-09 10:15:14Z lajos $
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 MuleSource MPL
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>AndFilter</code> accepts only if the leftFilter and rightFilter filter
18  * accept.
19  */

20
21 public class AndFilter implements UMOFilter
22 {
23     private UMOFilter leftFilter;
24     private UMOFilter rightFilter;
25
26     public AndFilter()
27     {
28         super();
29     }
30
31     public AndFilter(UMOFilter left, UMOFilter right)
32     {
33         this.leftFilter = left;
34         this.rightFilter = right;
35     }
36
37     public void setLeftFilter(UMOFilter leftFilter)
38     {
39         this.leftFilter = leftFilter;
40     }
41
42     public void setRightFilter(UMOFilter rightFilter)
43     {
44         this.rightFilter = rightFilter;
45     }
46
47     public UMOFilter getLeftFilter()
48     {
49         return leftFilter;
50     }
51
52     public UMOFilter getRightFilter()
53     {
54         return rightFilter;
55     }
56
57     public boolean accept(UMOMessage message)
58     {
59         if (leftFilter != null && rightFilter != null)
60         {
61             return leftFilter.accept(message) && rightFilter.accept(message);
62         }
63         else
64         {
65             return false;
66         }
67     }
68
69 }
70
Popular Tags