gshute.util
Class Filters.Compound

java.lang.Object
  |
  +--gshute.util.Filters.Compound

public class Filters.Compound
extends java.lang.Object
implements Filter

A Filters.Compound object combines the acceptance decisions of its constituent filters. This class defines int constants AND, NAND, OR, and NOR to specify the combination mode. When a compound filter is in AND mode it accepts an object when all of its constituent filters accept the object. When a compound filter is in OR mode it accepts an object if any of its constituent filters accept the object. A compound filter with no contituent filters accepts all object if it is in AND or NOR mode and accepts no objects if it is in OR or NAND mode.


Field Summary
static int AND
          AND is the combination mode value for a compound filter that accepts an object if all of its filters accept the object.
protected  boolean defaultValue
          defaultValue is the the value returned by the isAcceptable() method of this compound filter when it has no constituent filters.
protected  java.util.Vector filters
          filters is the vector of constituent filters for this compound filter.
static int NAND
          NAND is the combination mode value for a compound filter that accepts an object if at least one of its filters does not accept the object.
static int NOR
          NOR is the combination mode value for a compound filter that accepts an object if none of its filters accepts the object.
static int OR
          OR is the combination mode value for a compound filter that accepts an object if at least one of its filters accepts the object.
protected  boolean stopValue
          When this compound filter calls the isAcceptable() method of its constituent filters, it stops after the first returned value that is equal to stopValue and returns !defaultValue.
 
Constructor Summary
Filters.Compound()
          new Filters.Compound() returns a new compound filter that has mode AND and has no constituent filters.
Filters.Compound(Filter fltr)
          new Filters.Compound(fltr) returns a new compound filter that has mode AND and has fltr as its only constituent filter.
Filters.Compound(Filter fltr1, Filter fltr2)
          new Filters.Compound(fltr1, fltr2) returns a new compound filter that has mode AND and has fltr1 and fltr2 as its only constituent filters.
Filters.Compound(Filter fltr1, Filter fltr2, int md)
          new Filters.Compound(fltr1, fltr2, md) returns a new compound filter that has mode md and has fltr1 and fltr2 as its only constituent filters.
Filters.Compound(Filter fltr, int md)
          new Filters.Compound(fltr, md) returns a new compound filter that has mode md and has fltr as its only constituent filter.
Filters.Compound(int md)
          new Filters.Compound(md) returns a new compound filter that has mode md and has no constituent filters.
 
Method Summary
 void addFilter(Filter fltr)
          cf.addFilter(fltr) adds fltr as a constituent filter of cf.
 boolean isAcceptable(java.lang.Object o)
          cf.isAcceptable(o) returns true if o is accepted by cf.
 void removeFilter(Filter fltr)
          cf.removeFilter(fltr) removes the constituent filter fltr from cf.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAND

public static final int NAND
NAND is the combination mode value for a compound filter that accepts an object if at least one of its filters does not accept the object.

OR

public static final int OR
OR is the combination mode value for a compound filter that accepts an object if at least one of its filters accepts the object.

AND

public static final int AND
AND is the combination mode value for a compound filter that accepts an object if all of its filters accept the object.

NOR

public static final int NOR
NOR is the combination mode value for a compound filter that accepts an object if none of its filters accepts the object.

defaultValue

protected boolean defaultValue
defaultValue is the the value returned by the isAcceptable() method of this compound filter when it has no constituent filters.

stopValue

protected boolean stopValue
When this compound filter calls the isAcceptable() method of its constituent filters, it stops after the first returned value that is equal to stopValue and returns !defaultValue.

filters

protected java.util.Vector filters
filters is the vector of constituent filters for this compound filter.
Constructor Detail

Filters.Compound

public Filters.Compound()
new Filters.Compound() returns a new compound filter that has mode AND and has no constituent filters.

Filters.Compound

public Filters.Compound(int md)
new Filters.Compound(md) returns a new compound filter that has mode md and has no constituent filters.

Filters.Compound

public Filters.Compound(Filter fltr)
new Filters.Compound(fltr) returns a new compound filter that has mode AND and has fltr as its only constituent filter.

Filters.Compound

public Filters.Compound(Filter fltr,
                        int md)
new Filters.Compound(fltr, md) returns a new compound filter that has mode md and has fltr as its only constituent filter.

Filters.Compound

public Filters.Compound(Filter fltr1,
                        Filter fltr2)
new Filters.Compound(fltr1, fltr2) returns a new compound filter that has mode AND and has fltr1 and fltr2 as its only constituent filters.

Filters.Compound

public Filters.Compound(Filter fltr1,
                        Filter fltr2,
                        int md)
new Filters.Compound(fltr1, fltr2, md) returns a new compound filter that has mode md and has fltr1 and fltr2 as its only constituent filters.
Method Detail

addFilter

public void addFilter(Filter fltr)
cf.addFilter(fltr) adds fltr as a constituent filter of cf.

removeFilter

public void removeFilter(Filter fltr)
cf.removeFilter(fltr) removes the constituent filter fltr from cf.

isAcceptable

public boolean isAcceptable(java.lang.Object o)
cf.isAcceptable(o) returns true if o is accepted by cf.
Specified by:
isAcceptable in interface Filter