EMMA Coverage Report (generated Tue Feb 12 22:23:49 ICT 2008)
[all classes][net.sourceforge.hiveevents]

COVERAGE SUMMARY FOR SOURCE FILE [FiltersChain.java]

nameclass, %method, %block, %line, %
FiltersChain.java0%   (0/1)0%   (0/4)0%   (0/59)0%   (0/13)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FiltersChain0%   (0/1)0%   (0/4)0%   (0/59)0%   (0/13)
FiltersChain (): void 0%   (0/1)0%   (0/8)0%   (0/2)
addFilter (Filter): void 0%   (0/1)0%   (0/6)0%   (0/2)
create (Filter []): Filter 0%   (0/1)0%   (0/25)0%   (0/4)
passEvent (Object): boolean 0%   (0/1)0%   (0/20)0%   (0/5)

1//  Copyright 2004-2007 Jean-Francois Poilpret
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14 
15package net.sourceforge.hiveevents;
16 
17import java.util.ArrayList;
18import java.util.List;
19 
20/**
21 * Chain of event filters. Allows to daisy chain several filters (makes it
22 * easier to build complex filters).
23 *
24 * @author Jean-Francois Poilpret
25 */
26public class FiltersChain<T> implements Filter<T>
27{
28        /**
29         * Create a chain of filters.
30         */
31        static public<T> Filter<T>        create(Filter<T>... filters)
32        {
33                FiltersChain<T> chain = new FiltersChain<T>();
34                for (Filter<T> filter: filters)
35                {
36                        chain.addFilter(filter);
37                }
38                return chain;
39        }
40        
41        /**
42         * Add a filter at the end of the chain.
43         */        
44        public void        addFilter(Filter<T> filter)
45        {
46                _filters.add(filter);
47        }
48        
49        /**
50         * Checks if an event passes through ALL the filters in the chain.
51         * If one only filter does not allow the event to pass, then the event will
52         * NOT pass.
53         */
54        public boolean        passEvent(T event)
55        {
56                for (Filter<T> filter: _filters)
57                {
58                        if (!filter.passEvent(event))
59                        {
60                                return false;
61                        }
62                }
63                return true;
64        }
65        
66        private final List<Filter<T>>        _filters = new ArrayList<Filter<T>>();
67}

[all classes][net.sourceforge.hiveevents]
EMMA 2.0.5312 (C) Vladimir Roubtsov