edu.iris.Fissures.seed.builder
Class BuilderFilter

java.lang.Object
  extended by edu.iris.Fissures.seed.builder.BuilderFilter
Direct Known Subclasses:
SeedBuilderFilter

public abstract class BuilderFilter
extends java.lang.Object

Abstract class for all filters applied to Builders. These filters act as a 'request template' to help Builders select which objects to keep and which to throw out as they are built. The filter consists of one or more 'parameters', which are value/key pairs that are used in comparison to the contents of a built object. When the qualify() method is used, the built object passed to the filter determines whether the object fits the criteria or not. The list of parameters can have the same key many times over, with different values. This is interpreted in an OR fashion, where a match to any one of the values will result in a passing grade. Glob-style wildcards ('?','*') can be used in a parameter value to generalize the matching criteria even further.

Version:
7/17/2002
Author:
Robert Casey, IRIS DMC

Field Summary
protected  java.lang.String filterType
           
protected  java.util.HashMap parameterMap
           
protected  java.util.Iterator paramIterator
           
 
Constructor Summary
BuilderFilter()
          Create new Builder Filter.
 
Method Summary
 void addParameter(java.lang.String key, java.lang.String value)
          Add a key/value pair to the filter.
 java.lang.String[] getNext()
          Get the next key/value pair from the iterator.
 java.util.Vector getParameter(java.lang.String key)
          Get filter parameter(s).
 java.lang.String getType()
          Get filter type.
protected  boolean globMatch(java.lang.String criteria, java.lang.String value)
          Glob-match value to criteria.
 int iterate()
          Set up the iterator.
protected  int numCompare(java.lang.String value1, java.lang.String value2)
          Compare two numeric or Btime strings to each other.
abstract  boolean qualify(java.lang.Object o)
          Comparative method that accepts and object of expected type and compares the instance values within to the parameter list in this filter.
 void reset()
          Reset the filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parameterMap

protected java.util.HashMap parameterMap

paramIterator

protected java.util.Iterator paramIterator

filterType

protected java.lang.String filterType
Constructor Detail

BuilderFilter

public BuilderFilter()
Create new Builder Filter.

Method Detail

getType

public java.lang.String getType()
                         throws BuilderException
Get filter type. This method returns the type of filter we are in the form of a unique string. The filter type should match the builder type it is matched to.

Throws:
BuilderException

addParameter

public void addParameter(java.lang.String key,
                         java.lang.String value)
Add a key/value pair to the filter. Because we can have more than one value per unique key, we will make the value parameter be a Vector of Strings.


getParameter

public java.util.Vector getParameter(java.lang.String key)
Get filter parameter(s). Get one or more values from the filter matching the provided key. Multiple values will result from having different values assigned to the same key. Return a Vector of Strings, being the list of values attached to that key. Return null if the key is not listed.


reset

public void reset()
Reset the filter. Erase the parameter map to reset the filter.


iterate

public int iterate()
Set up the iterator. Pass through the key/value pairs one by one in the case of multiple values, each value associated with a key will be displayed individually per iteration. Return the number of iterative elements.


getNext

public java.lang.String[] getNext()
Get the next key/value pair from the iterator. Returns a two-element array, with the first element being the key and the second element the value. In the case of multiple values, each value associated with a key will be displayed individually per iteration. Return null if there are no more elements.


qualify

public abstract boolean qualify(java.lang.Object o)
                         throws BuilderException
Comparative method that accepts and object of expected type and compares the instance values within to the parameter list in this filter. Return true if the Object fits the criteria, false if not.

Throws:
BuilderException

globMatch

protected boolean globMatch(java.lang.String criteria,
                            java.lang.String value)
Glob-match value to criteria. criteria can have wildcards '*' and '?', whereas value does not treat these characters as wildcards. return true if match successful.


numCompare

protected int numCompare(java.lang.String value1,
                         java.lang.String value2)
Compare two numeric or Btime strings to each other. Return -1 if first value less than second value. Return 1 if first value greater than second value.