org.embl.ebi.escience.scuflworkers.java
Class FlattenList

java.lang.Object
  extended by org.embl.ebi.escience.scuflworkers.java.FlattenList
All Implemented Interfaces:
LocalWorker, LocalWorkerWithPorts, XMLExtensible

public class FlattenList
extends java.lang.Object
implements LocalWorkerWithPorts, XMLExtensible

Consume a list of lists and emit a list containing the given level of flattening of the input. By default (and historical reasons) the level is 2, meaning that the output list will be 1 level flatter.

The level can be set with setDepth(int) - as done through the FlattenListEditAction.

Author:
Tom Oinn, Stian Soiland

Field Summary
 
Fields inherited from interface org.embl.ebi.escience.scuflworkers.java.LocalWorker
BINARY, BINARY_ARRAY, HTML, HTML_ARRAY, PNG_IMAGE, PNG_IMAGE_ARRAY, STRING, STRING_ARRAY, UNTYPED, UNTYPED_ARRAY
 
Constructor Summary
FlattenList()
           
 
Method Summary
 void consumeXML(org.jdom.Element element)
          Extract the <flattenlist depth="X" /> number from the element.
 java.util.Map<java.lang.String,DataThing> execute(java.util.Map inputs)
          Copy each entry in the input list into the output list iff it matches the supplied regular expression.
 int getDepth()
          Get the depth of this flattener.
 java.lang.String[] inputNames()
          Get an array of the names of input ports for this processor
 java.util.List<InputPort> inputPorts(LocalServiceProcessor processor)
          The InputPorts for this localworker, to be used by LocalServiceProcessor
 java.lang.String[] inputTypes()
          Get an array of the string types for the inputs defined by the inputNames() method, these should probably use the constants defined in this interface but may use any valid Baclava data type specifier.
 java.lang.String[] outputNames()
          Names of the output ports
 java.util.List<OutputPort> outputPorts(LocalServiceProcessor processor)
          The OutputPorts for this localworker, to be used by LocalServiceProcessor
 java.lang.String[] outputTypes()
          Types of the output ports
 org.jdom.Element provideXML()
          Export depth as <extensions><flattenlist depth="X" /></extensions>
 void setDepth(int depth)
          Set the depth of this flattener.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FlattenList

public FlattenList()
Method Detail

setDepth

public void setDepth(int depth)
Set the depth of this flattener. The depth means how deeply it should flatten lists. The minimum (and default) depth is 2, which means to strip away the outermost list. A depth of 3 would strip away the two outermost lists, etc.

If a depth less than 2 is given, a warning is logged and the depth is set to 2 instead.

Parameters:
depth - Depth of flattener, minimum 2

getDepth

public int getDepth()
Get the depth of this flattener. The default value is 2.

Returns:
The current depth

inputNames

public java.lang.String[] inputNames()
Description copied from interface: LocalWorker
Get an array of the names of input ports for this processor

Specified by:
inputNames in interface LocalWorker

inputTypes

public java.lang.String[] inputTypes()
Description copied from interface: LocalWorker
Get an array of the string types for the inputs defined by the inputNames() method, these should probably use the constants defined in this interface but may use any valid Baclava data type specifier.

Specified by:
inputTypes in interface LocalWorker

outputNames

public java.lang.String[] outputNames()
Description copied from interface: LocalWorker
Names of the output ports

Specified by:
outputNames in interface LocalWorker

outputTypes

public java.lang.String[] outputTypes()
Description copied from interface: LocalWorker
Types of the output ports

Specified by:
outputTypes in interface LocalWorker

execute

public java.util.Map<java.lang.String,DataThing> execute(java.util.Map inputs)
                                                  throws TaskExecutionException
Copy each entry in the input list into the output list iff it matches the supplied regular expression.

Specified by:
execute in interface LocalWorker
Throws:
TaskExecutionException - thrown if there is an error during invocation of the task.

inputPorts

public java.util.List<InputPort> inputPorts(LocalServiceProcessor processor)
                                     throws DuplicatePortNameException,
                                            PortCreationException
Description copied from interface: LocalWorkerWithPorts
The InputPorts for this localworker, to be used by LocalServiceProcessor

Specified by:
inputPorts in interface LocalWorkerWithPorts
Throws:
DuplicatePortNameException
PortCreationException

outputPorts

public java.util.List<OutputPort> outputPorts(LocalServiceProcessor processor)
                                       throws DuplicatePortNameException,
                                              PortCreationException
Description copied from interface: LocalWorkerWithPorts
The OutputPorts for this localworker, to be used by LocalServiceProcessor

Specified by:
outputPorts in interface LocalWorkerWithPorts
Throws:
DuplicatePortNameException
PortCreationException

consumeXML

public void consumeXML(org.jdom.Element element)
Extract the <flattenlist depth="X" /> number from the element.

Specified by:
consumeXML in interface XMLExtensible

provideXML

public org.jdom.Element provideXML()
Export depth as <extensions><flattenlist depth="X" /></extensions>

Specified by:
provideXML in interface XMLExtensible