com.monad.homerun.filter
Class Filter

java.lang.Object
  extended by com.monad.homerun.base.DataObject
      extended by com.monad.homerun.filter.Filter
All Implemented Interfaces:
java.io.Serializable

public class Filter
extends DataObject

A Filter is an ordered list of Screens, minimum one. When a filter is applied, the result is a collection of objects that satisfy all the constituent screens. One primary use is in the definition of group objects. Filters are domain-specific, and have syntax and semantics that closely resemble Rules, in that each Screen is like a Condition, and can be alternated or combined with other Screens, validated, traced, etc. They also may contain a list of derived value types, which are the application of a function to the object collection with respect to an invariant component (model, property, etc). Filters are maintained by the FilterMaker app.

See Also:
Serialized Form

Constructor Summary
Filter()
           
Filter(java.lang.String filterName, java.lang.String domain)
           
Filter(java.lang.String setName, java.lang.String domain, Filter filterSet)
           
 
Method Summary
 void addScreen(Screen screen)
          Adds a screen to the filter.
 void addValue(FilterValue value)
          Adds a value to the filter.
 java.lang.String[] getIComps(Screener screener)
          Returns a list of 'invariant' components of given type.
 int getNumScreens()
          Returns the number of screens in the filter
 int getNumValues()
          Returns the number of values in the filter
 Screen getScreen(int index)
          Return the screen at the specified index
 FilterValue getValue(int index)
           
 FilterValue getValue(java.lang.String name)
          Returns the FilterValue matching the specified name
 FilterValue[] getValues()
           
 boolean isRuntime(Screener screener)
          Does filter contain any runtime screens?
 boolean pass(Screener screener, java.lang.String objectName, java.util.List<java.lang.String> callStack, FilterTrace trace)
          Tests the object against the filter (with optional tracing)
 void removeScreen(int index)
          Removes a screen from the filter at the position indicated by index.
 void removeValue(FilterValue value)
          Removes a value from the filter.
 void replaceScreen(int index, Screen screen)
          Replaces a screen in the filter at the position indicated by index.
 boolean validate(Screener screener, java.util.List<java.lang.String> callStack, FilterTrace trace)
          Verifies that: (a) filter is syntactically valid, (b) all the terms of the filter are valid references, and (c) filter does not circularly invoke itself
 
Methods inherited from class com.monad.homerun.base.DataObject
getCategory, getModificationTime, getName, getNote, setCategory, setModificationTime, setName, setNote
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Filter

public Filter()

Filter

public Filter(java.lang.String filterName,
              java.lang.String domain)

Filter

public Filter(java.lang.String setName,
              java.lang.String domain,
              Filter filterSet)
Method Detail

addScreen

public void addScreen(Screen screen)
Adds a screen to the filter. Screen is placed at the end of the list

Parameters:
screen - the screen to add

removeScreen

public void removeScreen(int index)
Removes a screen from the filter at the position indicated by index.

Parameters:
index - the index of the screen to remove

replaceScreen

public void replaceScreen(int index,
                          Screen screen)
Replaces a screen in the filter at the position indicated by index.

Parameters:
index - the index of the screen to remove
screen - the screen to add

addValue

public void addValue(FilterValue value)
Adds a value to the filter. Value is placed at the end of the list

Parameters:
value - the filter value to add

removeValue

public void removeValue(FilterValue value)
Removes a value from the filter.

Parameters:
value - the filter value to remove

validate

public boolean validate(Screener screener,
                        java.util.List<java.lang.String> callStack,
                        FilterTrace trace)
Verifies that: (a) filter is syntactically valid, (b) all the terms of the filter are valid references, and (c) filter does not circularly invoke itself

Parameters:
screener - the Screener to use
callStack - the stack of filters called
trace - optional trace object
Returns:
true if filter is valid

pass

public boolean pass(Screener screener,
                    java.lang.String objectName,
                    java.util.List<java.lang.String> callStack,
                    FilterTrace trace)
Tests the object against the filter (with optional tracing)

Parameters:
screener - the Screening agent
objectName - the object being screened
trace - the optional trace object
Returns:
true if object passes the filter

isRuntime

public boolean isRuntime(Screener screener)
Does filter contain any runtime screens?

Parameters:
screener - the Screener object
Returns:
true if runtime state is required

getIComps

public java.lang.String[] getIComps(Screener screener)
Returns a list of 'invariant' components of given type. An inariant component is one that belongs to all objects passing the filter

Returns:
icomps array of invariant component names

getNumScreens

public int getNumScreens()
Returns the number of screens in the filter

Returns:
the number of screens

getScreen

public Screen getScreen(int index)
Return the screen at the specified index

Parameters:
index - the index of the screen
Returns:
screen the Screen

getNumValues

public int getNumValues()
Returns the number of values in the filter

Returns:
the number of filter values

getValue

public FilterValue getValue(int index)

getValues

public FilterValue[] getValues()

getValue

public FilterValue getValue(java.lang.String name)
Returns the FilterValue matching the specified name

Parameters:
name - the name of the value
Returns:
screen the Screen


Copyright © 2006-2009 Richard Rodgers. All Rights Reserved.