org.apache.excalibur.event.impl
Class ThresholdEnqueuePredicate

java.lang.Object
  extended byorg.apache.excalibur.event.impl.ThresholdEnqueuePredicate
All Implemented Interfaces:
EnqueuePredicate

public final class ThresholdEnqueuePredicate
extends java.lang.Object
implements EnqueuePredicate

The ThresholdEnqueuePredicate limits the elements that can be enqueued based on the size of the Queue.

Author:
Avalon Development Team

Constructor Summary
ThresholdEnqueuePredicate(int limit)
          Create a new ThresholdEnqueuePredicate with the supplied limit.
 
Method Summary
 boolean accept(java.lang.Object[] elements, Sink modifyingSink)
          Returns true if the Sink size + the number of elements is less than the threshold.
 boolean accept(java.lang.Object element, Sink modifyingSink)
          Returns true if the Sink size + 1 (the element) is less than the threshold.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThresholdEnqueuePredicate

public ThresholdEnqueuePredicate(int limit)
Create a new ThresholdEnqueuePredicate with the supplied limit.

Parameters:
limit - A number greater than zero
Method Detail

accept

public boolean accept(java.lang.Object element,
                      Sink modifyingSink)
Returns true if the Sink size + 1 (the element) is less than the threshold.

Specified by:
accept in interface EnqueuePredicate
Parameters:
element - The element to enqueue
modifyingSink - The sink that is used for this predicate
Returns:
true if the sink accepts the element; false otherwise.

accept

public boolean accept(java.lang.Object[] elements,
                      Sink modifyingSink)
Returns true if the Sink size + the number of elements is less than the threshold.

Specified by:
accept in interface EnqueuePredicate
Parameters:
elements - The array of elements to enqueue
modifyingSink - The sink that is used for this predicate
Returns:
true if the sink accepts all the elements; false otherwise.


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.