org.knime.core.node.workflow
Class FlowObjectStack

java.lang.Object
  extended by org.knime.core.node.workflow.FlowObjectStack
All Implemented Interfaces:
Iterable<FlowObject>

public final class FlowObjectStack
extends Object
implements Iterable<FlowObject>

Container for the stack that keeps for an individual node the FlowObjectStack information.

Author:
Bernd Wiswedel, University of Konstanz

Constructor Summary
FlowObjectStack(NodeID id, FlowObjectStack... predStacks)
          Creates new stack based.
 
Method Summary
 Map<String,FlowVariable> getAvailableFlowVariables()
          Get all (visible!) variables on the stack in a non-modifiable map.
(package private)  List<FlowObject> getFlowObjectsOwnedBy(NodeID id)
          Get all objects on the stack that are owned by the node with the given id.
(package private)  boolean isEmpty()
           
 Iterator<FlowObject> iterator()
          Get iterator on elements, top of stack first.
<T extends FlowObject>
T
peek(Class<T> type)
           
 FlowVariable peekFlowVariable(String name, FlowVariable.Type type)
          Get the variable with the given name or null if no such variable is on the stack.
<T extends FlowObject>
T
pop(Class<T> type)
          Removes all elements from the stack whose class is not of the given type.
 void push(FlowObject item)
           
(package private)  int size()
          Get number of elements in the stack.
 String toDeepString()
           
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FlowObjectStack

FlowObjectStack(NodeID id,
                FlowObjectStack... predStacks)
Creates new stack based. If the argument stack is empty, null or contains only null elements, an empty stack is created. If there is more than one argument stack available, the stacks will be merged.

Parameters:
id - The Node's ID, must not be null.
predStacks - The stacks from the predecessor nodes, may be null or empty.
Throws:
NullPointerException - If id is null.
IllegalFlowObjectStackException - If the stacks can't be merged.
Method Detail

peek

public <T extends FlowObject> T peek(Class<T> type)
Type Parameters:
T - The class type of the context object
Parameters:
type - The desired FlowObject class
Returns:
The top-most element on the stack that complies with the given class argument or null if no such element is found.
See Also:
Stack.peek()

pop

public <T extends FlowObject> T pop(Class<T> type)
Removes all elements from the stack whose class is not of the given type. It also removes the top-most element complying with the given class. If no such element exists, the stack will be empty after this method is called.

Type Parameters:
T - The desired FlowObject type.
Parameters:
type - The class of that type.
Returns:
The first (top-most) element on the stack of class type or null if no such element is available.
See Also:
Stack.pop()

peekFlowVariable

public FlowVariable peekFlowVariable(String name,
                                     FlowVariable.Type type)
Get the variable with the given name or null if no such variable is on the stack.

Parameters:
name - To peek
type - The type of the variable to seek.
Returns:
the variable or null

getAvailableFlowVariables

public Map<String,FlowVariable> getAvailableFlowVariables()
Get all (visible!) variables on the stack in a non-modifiable map. This method is used to show available variables to the user.

Returns:
Such a map.

getFlowObjectsOwnedBy

List<FlowObject> getFlowObjectsOwnedBy(NodeID id)
Get all objects on the stack that are owned by the node with the given id. This method is used to persist the stack.

Parameters:
id - identifies objects of interest.
Returns:
list of all elements that are put onto the stack by the argument node

push

public void push(FlowObject item)
Parameters:
item - FlowObject to be put onto stack.
See Also:
Stack.push(java.lang.Object)

isEmpty

boolean isEmpty()
Returns:
true if stack is empty

size

int size()
Get number of elements in the stack.

Returns:
size of stack.

iterator

public Iterator<FlowObject> iterator()
Get iterator on elements, top of stack first. The iterator is read only and not affected by potential modifications of the stack after this method returns (iterator on copy).

Specified by:
iterator in interface Iterable<FlowObject>

toString

public String toString()

Overrides:
toString in class Object

toDeepString

public String toDeepString()
Returns:
String representation with list of all objects on stack.


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.