quoggles.stdboxes.complexfilter
Class ComplexFilter_Box

java.lang.Object
  |
  +--quoggles.boxes.Box
        |
        +--quoggles.stdboxes.complexfilter.ComplexFilter_Box
All Implemented Interfaces:
IBox

public class ComplexFilter_Box
extends Box

Input: one or several objects

Output:

  1. null if the input has been null
  2. only those elements from the input for which holds: When set as input to the sub query starting at the second output of this box, this sub query yields a result that can be interpreted as true.
  3. every element from the input (or the input itself, if it is not a collection) is used as the input to the sub query starting at this output.
The sub query rooted at the second output of this box is searched for sinks (i.e. boxes that have free outputs). There must not be any sinks. If there is exactly one sink found (with only one free output) a BoolPredicateEnd_Box is implicitly added. Otherwise, an error is generated.

The output is a collection of input elements for which the predicate holds (i.e. the sub query yields a true result).

If the resulting list contains only one element, this element is returned (not a one-element list).


Field Summary
private  java.util.Stack currentNodesTodo
          The nodes that still have to be processed.
private  java.util.List currentResult
          The current result table.
private  int currentTestCount
          If this number is greater than 0, the currently tested object has passed the test (predicate yielded true for this).
private  org.graffiti.graph.Node firstPredNode
          Node representing the first box of the predicate of this filter
private  java.util.Collection inputCol
          The input collection
private  int nextInIndex
           
private  org.graffiti.plugin.parameter.Parameter orderParam
           
private  boolean predicateExists
          Specifies whether or not a predicate exists
private  RunQuery queryRunner
           
private  java.util.List resultRowNrs
           
private  java.util.List resultRows
          Holds additional output
private  java.lang.Object singleInput
          Only set if input is not a collection
 
Fields inherited from class quoggles.boxes.Box
boxExecuted, iBoxGRep, inputs, outputs, parameters
 
Constructor Summary
ComplexFilter_Box()
          Default constructor.
 
Method Summary
private static void beforeException(org.graffiti.graph.Node n)
          Is called before an exception is throws.
static org.graffiti.util.Pair checkSinks(org.graffiti.graph.Node fstPredNode, IBox thisBox)
          Assures that there is exactly one BoolPredicateEnd_Box in the sub query.
 void currentTestSucceded()
          If a BoolPredicateEnd_Box finds out that the test succeded, it calls this method of all its registered complex filters.
 void execute()
          See interpretAsBoolean for a definition of what it means that a sub query evaluates to true.
 IBoxRepresentation getGraphicalRepresentation()
          This implementation returns a new instance of DefaultBoxRepresentation.
 int[] getInputTypes()
          This implementation returns ONE element, the most general type.
 int getNumberOfOutputs()
          Returns 2.
 int[] getOutputTypes()
          Override this method to specify more restricted types for the output(s) of the box.
 java.util.List getResult()
          An entry in the list is created for each IOutput_Box that is found in the predicate query.
 java.util.List getResultRowNumbers()
          An entry in the list is created for each IOutput_Box that is found in the predicate query.
 boolean needsQueryRunner()
          Returns false.
 void reset()
          Should be called by all classes that override this method.
 void setCurrentNodesTodo(java.util.Stack nodesTodo)
          Empty implementation.
 void setCurrentResult(java.util.List res)
          Empty implementation.
 void setInputs(java.lang.Object[] inputs)
          Checks if the number of inputs is correct and sets the inputs.
 void setNotExecuted()
           
 void setQueryRunner(RunQuery qr)
          Empty implementation.
 
Methods inherited from class quoggles.boxes.Box
areAllInputsNull, getClassName, getId, getNode, getNumberOfInputs, getOutputAt, getOutputs, getParameters, hasBeenExecuted, ignoreBox, isGraphicalRepNull, isInputSet, isInputSetAt, removeNullValues, reset, setBoxNumber, setDefaultParameters, setIgnoreBox, setInputAt, setNode, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputCol

private java.util.Collection inputCol
The input collection


singleInput

private java.lang.Object singleInput
Only set if input is not a collection


firstPredNode

private org.graffiti.graph.Node firstPredNode
Node representing the first box of the predicate of this filter


queryRunner

private RunQuery queryRunner

nextInIndex

private int nextInIndex
See Also:
setnextinputIndex(int)

resultRows

private java.util.List resultRows
Holds additional output


resultRowNrs

private java.util.List resultRowNrs

predicateExists

private boolean predicateExists
Specifies whether or not a predicate exists


currentTestCount

private int currentTestCount
If this number is greater than 0, the currently tested object has passed the test (predicate yielded true for this).


currentResult

private java.util.List currentResult
The current result table.


currentNodesTodo

private java.util.Stack currentNodesTodo
The nodes that still have to be processed.


orderParam

private org.graffiti.plugin.parameter.Parameter orderParam
Constructor Detail

ComplexFilter_Box

public ComplexFilter_Box()
Default constructor.

Method Detail

getResult

public java.util.List getResult()
An entry in the list is created for each IOutput_Box that is found in the predicate query.

Returns:

getResultRowNumbers

public java.util.List getResultRowNumbers()
An entry in the list is created for each IOutput_Box that is found in the predicate query. It is the number of the row where the respective output should be put.

Returns:
See Also:
getResult()

needsQueryRunner

public boolean needsQueryRunner()
Description copied from class: Box
Returns false.

Specified by:
needsQueryRunner in interface IBox
Overrides:
needsQueryRunner in class Box
See Also:
quoggles.boxes.IBox#neeedsQueryRunner()

setQueryRunner

public void setQueryRunner(RunQuery qr)
Description copied from class: Box
Empty implementation.

Specified by:
setQueryRunner in interface IBox
Overrides:
setQueryRunner in class Box
See Also:
IBox.setQueryRunner(quoggles.auxiliary.RunQuery)

currentTestSucceded

public void currentTestSucceded()
If a BoolPredicateEnd_Box finds out that the test succeded, it calls this method of all its registered complex filters. This indicates that the currently tested object will be added to th eoutput of this filter. Calling this method several times will cause the filter to add the element several times.


setNotExecuted

public void setNotExecuted()

reset

public void reset()
Description copied from class: Box
Should be called by all classes that override this method.

Specified by:
reset in interface IBox
Overrides:
reset in class Box
See Also:
IBox.reset()

beforeException

private static void beforeException(org.graffiti.graph.Node n)
Is called before an exception is throws. Ensures that the query is in a valid state.

Parameters:
n - the node that holds the BoolPredicateEnd_Box

checkSinks

public static org.graffiti.util.Pair checkSinks(org.graffiti.graph.Node fstPredNode,
                                                IBox thisBox)
                                         throws QueryExecutionException
Assures that there is exactly one BoolPredicateEnd_Box in the sub query. The node containing this box is the first entry in the Pair that is returned. The second entry indicates whether or not a new boolean predicate end box has been added automatically.

Parameters:
fstPredNode - the node where the predicate starts
thisBox - the box for which the search is started. Used to prevent that the predicates of nested complex filter boxes are checked in this call already.
QueryExecutionException

execute

public void execute()
             throws QueryExecutionException
See interpretAsBoolean for a definition of what it means that a sub query evaluates to true.

Specified by:
execute in interface IBox
Overrides:
execute in class Box
QueryExecutionException
See Also:
IBox.execute(), quoggles.auxialiary.Util#interpretAsBoolean(Object)

setCurrentResult

public void setCurrentResult(java.util.List res)
Description copied from class: Box
Empty implementation.

Specified by:
setCurrentResult in interface IBox
Overrides:
setCurrentResult in class Box
See Also:
IBox.setCurrentResult(java.util.List)

setCurrentNodesTodo

public void setCurrentNodesTodo(java.util.Stack nodesTodo)
Description copied from class: Box
Empty implementation.

Specified by:
setCurrentNodesTodo in interface IBox
Overrides:
setCurrentNodesTodo in class Box
See Also:
IBox.setCurrentNodesTodo(java.util.Stack)

getGraphicalRepresentation

public IBoxRepresentation getGraphicalRepresentation()
Description copied from class: Box
This implementation returns a new instance of DefaultBoxRepresentation. If your subclass has any parameters, you will probably have to design your own representation and override this method for example as follows: if (iBoxGRep == null || !(iBoxGRep instanceof MYOWNBOX_Rep)) { iBoxGRep = new MYOWNBOX_Rep(this); } return iBoxGRep;

Specified by:
getGraphicalRepresentation in interface IBox
Overrides:
getGraphicalRepresentation in class Box
See Also:
IBox.getGraphicalRepresentation()

getInputTypes

public int[] getInputTypes()
Description copied from class: Box
This implementation returns ONE element, the most general type. Override this method to specify more restricted types for the input(s) of the box. The size of the returned array must be consistent with the return value of getNumberOfInputs.

Specified by:
getInputTypes in interface IBox
Overrides:
getInputTypes in class Box
See Also:
IBox.getInputTypes()

getNumberOfOutputs

public int getNumberOfOutputs()
Returns 2.

Specified by:
getNumberOfOutputs in interface IBox
Overrides:
getNumberOfOutputs in class Box
See Also:
IBox.getNumberOfOutputs()

getOutputTypes

public int[] getOutputTypes()
Description copied from class: Box
Override this method to specify more restricted types for the output(s) of the box. The size of the returned array must be consistent with the return value of getNumberOfOutputs. This implementation returns the same as a call to getInputTypes yields.

Specified by:
getOutputTypes in interface IBox
Overrides:
getOutputTypes in class Box
See Also:
IBox.getOutputTypes()

setInputs

public void setInputs(java.lang.Object[] inputs)
               throws InvalidInputException
Description copied from class: Box
Checks if the number of inputs is correct and sets the inputs. Subclasses probably will want to override this method to avoid many casts necessary when working with the input array. They should however first call this method (via super.setInputs(inputs)) so that consistency checks are done and some flags are correctly set.

Specified by:
setInputs in interface IBox
Overrides:
setInputs in class Box
InvalidInputException
See Also:
IBox.setInputs(java.lang.Object[])