Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AndFilter |
|
| 2.3333333333333335;2.333 |
1 | /* | |
2 | * $Id: AndFilter.java 10489 2008-01-23 17:53:38Z dfeist $ | |
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.api.MuleMessage; | |
14 | import org.mule.api.routing.filter.Filter; | |
15 | ||
16 | import java.util.Iterator; | |
17 | ||
18 | /** | |
19 | * <code>AndFilter</code> accepts only if the leftFilter and rightFilter filter | |
20 | * accept. | |
21 | */ | |
22 | ||
23 | public class AndFilter extends AbstractFilterCollection | |
24 | { | |
25 | ||
26 | public AndFilter() | |
27 | { | |
28 | 4 | super(); |
29 | 4 | } |
30 | ||
31 | /** | |
32 | * | |
33 | * @param left | |
34 | * @param right | |
35 | */ | |
36 | public AndFilter(Filter left, Filter right) | |
37 | { | |
38 | 2 | super(left, right); |
39 | 2 | } |
40 | ||
41 | public boolean accept(MuleMessage message) | |
42 | { | |
43 | 16 | if(getFilters().size()==0) |
44 | { | |
45 | 2 | return false; |
46 | } | |
47 | 14 | int counter=0; |
48 | 14 | for (Iterator iterator = getFilters().iterator(); iterator.hasNext();) |
49 | { | |
50 | 26 | Filter umoFilter = (Filter) iterator.next(); |
51 | 26 | if(umoFilter.accept(message)) |
52 | { | |
53 | 18 | counter++; |
54 | } | |
55 | 26 | } |
56 | ||
57 | 14 | return counter == getFilters().size(); |
58 | } | |
59 | } |