There are two filters: AndFilter and OrFilter. Both can filter based on two PacketFilters. However, there are situations in which one would like to filter with more than two PacketFilters. Suppose we have the following PacketFilters:
A, B, C and D
We want to filter all PacketFilters with the logical and-operator:
A && B && C && D
To realise this test with the AndFilter the test should be implemented abstractly the following way:
A && B = AB
C && D = CD
AB && CD
In other words. The AndFilter has to be used two times for testing A/B and C/D. Both boolean results have to be tested on ‘‘trueness’’. Surely there are other ways , but it isn’'t possible to do the test using only one AndFilter.
This could be solved by making it possible to use the AndFilter (and also the OrFilter) with an unlimited number of PacketFilters, by providing a method something like:
public void addFilter(PacketFilter filter);
The method adds the PacketFilter to a collection of filters, on which the and-operator will be applied.