ostore.dispatch
Class Filter

java.lang.Object
  |
  +--ostore.dispatch.Filter

public class Filter
extends Object

A specification for an event class. Each Filter consists of a set of restrictions, the intersection of which describe the set of QueueElementIF events objects which satisfy the Filter .

Version:
$Id: Filter.java,v 1.23 2002/07/22 20:54:53 srhea Exp $
Author:
Dennis Geels

Field Summary
 double acceptance_rate
          The fraction of qualifying events which the Classifier should pass through the Filter.
 LinkedList ordered_restrictions
          A List containing all the restrictions in the order they were added.
 Class required_type
          The most recently required type.
 HashMap restrictions
          A HashMap containing all the restrictions for this Filter.
protected static HashMap valid_types
          A HashMap containing the set of valid types for fields whose value we would like to restrict.
 
Constructor Summary
Filter()
           
 
Method Summary
 boolean requireType(Class type)
          Add a type restriction.
 boolean requireType(String type_name)
          Add a type restriction.
 boolean requireValue(Field field, Object value)
          Add a restriction of a field's value.
 boolean requireValue(String field_name, Object value)
          Add a restriction of a field's value.
 boolean setAcceptanceRate(double rate)
          Name the fraction of qualifying events which the Classifier should pass through the Filter.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

valid_types

protected static HashMap valid_types
A HashMap containing the set of valid types for fields whose value we would like to restrict. If the type is a Java primitive wrapper, it maps to the Class object for the associated primitive.

Update this HashMap (through the static initializer) if you want to add an allowable type restriction. NOTE all added types should override the default hashCode method with their own deterministic version.


acceptance_rate

public double acceptance_rate
The fraction of qualifying events which the Classifier should pass through the Filter. Must be between 0 and 1, inclusive. Use this variable if we want to sample the event stream.


restrictions

public HashMap restrictions
A HashMap containing all the restrictions for this Filter. The key is a Field object, mapped to the value which the Field should have.


ordered_restrictions

public LinkedList ordered_restrictions
A List containing all the restrictions in the order they were added.


required_type

public Class required_type
The most recently required type. This Class must be the most restrictive one mentioned, so we can forget all previous requireType calls and store just the last one.

Constructor Detail

Filter

public Filter()
Method Detail

requireType

public boolean requireType(String type_name)
Add a type restriction. This method just looks up the named Class and calls requireType( Class ).

Parameters:
type_name - The name of the Class of which filtered QueueElementIFs must be a member.
Returns:
true iff the requirement was registered without errors.

requireType

public boolean requireType(Class type)
Add a type restriction. QueueElementIF objects must now be members of the specified class, or they will not pass the filter. The class must be a subclass of all classes required so far, which makes sense.

Parameters:
type - The Class of which filtered QueueElementIFs must be a member.
Returns:
true iff the requirement was registered without errors.

requireValue

public boolean requireValue(String field_name,
                            Object value)
Add a restriction of a field's value. This method just looks up the named Field and calls requireValue( Field, Object ).

Parameters:
field_name - The name of the Field whose value we are restricting.
value - The desired value.
Returns:
true iff the requirement was registered without errors.

requireValue

public boolean requireValue(Field field,
                            Object value)
Add a restriction of a field's value. The appropriate Field of the events must match the specified value, or it will not pass the filter.

Parameters:
field - The Field whose value we are restricting. It must be a member of the most recently specified Class.
value - The desired value. It must be of the same type as the specified Field, or the appropriate wrapper if the Field is a primitive. Currently only simple types are allowed, such as Integer, GUID, String, etc.
Returns:
true iff the requirement was registered without errors.

setAcceptanceRate

public boolean setAcceptanceRate(double rate)
Name the fraction of qualifying events which the Classifier should pass through the Filter.

Returns:
true iff the rate was set without errors.

toString

public String toString()
Overrides:
toString in class Object