quoggles.stdboxes.listoperations2
Class ListOperations2_Box

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

public class ListOperations2_Box
extends Box

Input: two times: an object or a collection

Output: an object or a collection resulting from applying an operation (specified via a parameter) on both inputs. If an input is null, it is converted to an empty list.


Field Summary
private  java.util.Collection[] cols1
           
private  java.util.Collection[] cols2
           
private  int ioNumber
           
 
Fields inherited from class quoggles.boxes.Box
boxExecuted, iBoxGRep, inputs, outputs, parameters
 
Constructor Summary
ListOperations2_Box()
          Constructs the box.
 
Method Summary
private  void checkSameTypes(java.util.Collection[] c1, java.util.Collection[] c2)
          Checks if the given collections have the same schema.
 void execute()
          Should be overridden and called first by subclasses.
 IBoxRepresentation getGraphicalRepresentation()
          This implementation returns a new instance of DefaultBoxRepresentation.
 int[] getInputTypes()
          This implementation returns ONE element, the most general type.
 int getNumberOfInputs()
          Returns 2.
 int[] getOutputTypes()
          Override this method to specify more restricted types for the output(s) of the box.
private  java.lang.Class getType(java.util.Collection col)
          Get (most general) type of the elements contained in the given collection.
 void reset()
          Should be called by all classes that override this method.
 void reset(int index)
          Should be called by all classes that override this method.
 void setInputs(java.lang.Object[] inputs)
          Checks if the number of inputs is correct and sets the inputs.
 void setParameters(org.graffiti.plugin.parameter.Parameter[] pars, boolean fromRep)
          Sets the parameters and - if needed - sets them in the graphical representation.
 
Methods inherited from class quoggles.boxes.Box
areAllInputsNull, getClassName, getId, getNode, getNumberOfOutputs, getOutputAt, getOutputs, getParameters, hasBeenExecuted, ignoreBox, isGraphicalRepNull, isInputSet, isInputSetAt, needsQueryRunner, removeNullValues, setBoxNumber, setCurrentNodesTodo, setCurrentResult, setDefaultParameters, setIgnoreBox, setInputAt, setNode, setQueryRunner
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cols1

private java.util.Collection[] cols1

cols2

private java.util.Collection[] cols2

ioNumber

private int ioNumber
Constructor Detail

ListOperations2_Box

public ListOperations2_Box()
Constructs the box.

Method Detail

getNumberOfInputs

public int getNumberOfInputs()
Returns 2.

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

setParameters

public void setParameters(org.graffiti.plugin.parameter.Parameter[] pars,
                          boolean fromRep)
Description copied from class: Box
Sets the parameters and - if needed - sets them in the graphical representation. Subclasses need not override this method. Just assign your parameters to the protected field parameters.

Specified by:
setParameters in interface IBox
Overrides:
setParameters in class Box
See Also:
IBox.setParameters(org.graffiti.plugin.parameter.Parameter[], boolean)

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()

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[])

checkSameTypes

private void checkSameTypes(java.util.Collection[] c1,
                            java.util.Collection[] c2)
                     throws InvalidInputException
Checks if the given collections have the same schema. Throws an exception if it is not the case.

Parameters:
c1 - first collection
c2 - second collection
Throws:
InvalidInputException - thrown if the collections cannot be unified, i.e. the types do not match (checked recursively)

getType

private java.lang.Class getType(java.util.Collection col)
                         throws NoHomogeneousTypeException
Get (most general) type of the elements contained in the given collection.

// * Never returns null. An empty collection yields // * Object.class. Returns null for an empty collection or a collection that contains only null values.

Parameters:
col - the collection to check
Returns:
the (most general) type of the elements of the collection

// * Object.class for an empty collection null if parameter is an empty collection or one containing only null values.

Throws:
NoHomogeneousTypeException - thrown if the no such type could be found

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()

execute

public void execute()
             throws QueryExecutionException
Description copied from class: Box
Should be overridden and called first by subclasses. Throws InputNotSetException if the inputSet flag indicates the no input has been set for this box. May throw other QueryExecutionExceptions. The implementation of this abstract sets the output to be equal to the input.

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

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()

reset

public void reset(int index)
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(int)