The logical Filter
operators allow you to
combine multiple filters to run in a single Pipe, instead of chaining
multiple Pipes together to get the same logical result.
The cascading.operation.filter.And
Filter
performs a logical "and" on the
results of the constructor-provided
Filter
instances. That is, if
Filter#isRemove()
returns
true
for all of the given instances, this filter
returns true
.
The cascading.operation.filter.Or
Filter
performs a logical "or" on the
results of the constructor-provided
Filter
instances. That is, if
Filter#isRemove()
returns
true
for any of the given instances, this filter
returns true
.
The cascading.operation.filter.Not
Filter
performs a logical "not"
(negation) on the results of the constructor-provided
Filter
instance. That is, if
Filter#isRemove()
returns
true
for the given instance, this filter returns
false
, and if
Filter#isRemove()
returns
false
for the given instance, this filter returns
true
.
The cascading.operation.filter.Xor
Filter
performs a logical "xor"
(exclusive or) on the results of the constructor-provided
Filter
instances. Xor can only be applied
to two instances at a time. It returns true
if the
two instances have different truth values, and
false
if they have the same truth value. That is,
if Filter.isRemove()
returns
true
for both, or returns false
for
both, this filter returns false
; otherwise it
returns true
.
Example 9.1. Combining Filters
// incoming -> "ip", "time", "method", "event", "status", "size"
FilterNull filterNull = new FilterNull();
RegexFilter regexFilter = new RegexFilter( "(GET|HEAD|POST)" );
And andFilter = new And( filterNull, regexFilter );
assembly = new Each( assembly, new Fields( "method" ), andFilter );
// outgoing -> "ip", "time", "method", "event", "status", "size"
The example above performs a logical "and" on the two filters. Both must be satisfied for the data to pass through this one Pipe.
Copyright © 2007-2012 Concurrent, Inc. All Rights Reserved.