org.simantics.databoard.datasource
Class StepwiseDatasource

java.lang.Object
  extended by org.simantics.databoard.datasource.StepwiseDatasource
All Implemented Interfaces:
IStepwiseDatasource
Direct Known Subclasses:
ExampleDatasource

public class StepwiseDatasource
extends java.lang.Object
implements IStepwiseDatasource

Composite Datasource aggregates nodes

Author:
Toni Kalajainen

Nested Class Summary
static interface StepwiseDatasource.Node
           
 
Nested classes/interfaces inherited from interface org.simantics.databoard.datasource.IStepwiseDatasource
IStepwiseDatasource.DatasourceListener
 
Constructor Summary
StepwiseDatasource()
          Create new stepwise data source
 
Method Summary
 void addListener(IStepwiseDatasource.DatasourceListener listener)
          Add datamodel listener
 void addNode(StepwiseDatasource.Node node)
           
 void addRoot(StepwiseDatasource.Node node)
           
 void getAll(java.util.Collection<Variant> list)
          Get a list of all node identifiers.
 void getChildren(Variant nodeId, java.util.Collection<Variant> children)
          Get children of a node
 java.lang.String getLabel(Variant nodeId, java.lang.String locale)
          Get all labels of a node.
 void getLabels(Variant nodeId, java.util.Map<java.lang.String,java.lang.String> labels)
          Get all labels of a node.
 DataType getNodeType(Variant nodeId)
          Get the value type of a node.
 boolean getValue(Variant nodeId, Variant value)
          Get value of a node
 boolean hasNode(Variant nodeId)
          Verifies that the datasource has a node
 void removeListener(IStepwiseDatasource.DatasourceListener listener)
          Remove datamodel listener
 java.util.Collection<Variant> step(java.util.Collection<Variant> monitorSet)
          Go to the next step of value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StepwiseDatasource

public StepwiseDatasource()
Create new stepwise data source

Method Detail

addNode

public void addNode(StepwiseDatasource.Node node)

addRoot

public void addRoot(StepwiseDatasource.Node node)

hasNode

public boolean hasNode(Variant nodeId)
Description copied from interface: IStepwiseDatasource
Verifies that the datasource has a node

Specified by:
hasNode in interface IStepwiseDatasource
Returns:
true if node exists, false if not

getAll

public void getAll(java.util.Collection<Variant> list)
Description copied from interface: IStepwiseDatasource
Get a list of all node identifiers.

Specified by:
getAll in interface IStepwiseDatasource
Parameters:
list - to be filled with identifiers.

getChildren

public void getChildren(Variant nodeId,
                        java.util.Collection<Variant> children)
                 throws DatasourceException
Description copied from interface: IStepwiseDatasource
Get children of a node

Specified by:
getChildren in interface IStepwiseDatasource
children - a collection to be filled with children
Throws:
DatasourceException - if the node does not exist

getValue

public boolean getValue(Variant nodeId,
                        Variant value)
                 throws DatasourceException
Description copied from interface: IStepwiseDatasource
Get value of a node

Specified by:
getValue in interface IStepwiseDatasource
value - variant where the value is written to
Returns:
false if there is no value, otherwise true
Throws:
DatasourceException - if node does not exist

getNodeType

public DataType getNodeType(Variant nodeId)
                     throws DatasourceException
Description copied from interface: IStepwiseDatasource
Get the value type of a node.

Specified by:
getNodeType in interface IStepwiseDatasource
Returns:
value type or null if there is no value
Throws:
DatasourceException - if the node does not exist

step

public java.util.Collection<Variant> step(java.util.Collection<Variant> monitorSet)
                                   throws DatasourceException
Description copied from interface: IStepwiseDatasource
Go to the next step of value. In case of exception, the state of the values is undetermined. The values may be from previous step, or from the failed step.

Specified by:
step in interface IStepwiseDatasource
Parameters:
monitorSet - a collection of nodes that are monitored for change, or null
Returns:
a list of nodes whose value changed.
Throws:
DatasourceException - if error occurs

getLabel

public java.lang.String getLabel(Variant nodeId,
                                 java.lang.String locale)
                          throws DatasourceException
Description copied from interface: IStepwiseDatasource
Get all labels of a node. Locale is ISO-639 coded. Label for locale "en" is always available. See https://www.simantics.org/wiki/index.php/Databoard_Specification#Utility_types for details about localized text.

Specified by:
getLabel in interface IStepwiseDatasource
locale - ISO-639 coded locale.
Returns:
the label or null if there is no label for the locale. "en" is available.
Throws:
DatasourceException - if error occurs

getLabels

public void getLabels(Variant nodeId,
                      java.util.Map<java.lang.String,java.lang.String> labels)
               throws DatasourceException
Description copied from interface: IStepwiseDatasource
Get all labels of a node. locales map is filled with locale specific labels. Locale is ISO-639 encoded language/region code. Label for "en" is always available.

Specified by:
getLabels in interface IStepwiseDatasource
labels - a collection to be filled
Throws:
DatasourceException - if error occurs

addListener

public void addListener(IStepwiseDatasource.DatasourceListener listener)
Description copied from interface: IStepwiseDatasource
Add datamodel listener

Specified by:
addListener in interface IStepwiseDatasource

removeListener

public void removeListener(IStepwiseDatasource.DatasourceListener listener)
Description copied from interface: IStepwiseDatasource
Remove datamodel listener

Specified by:
removeListener in interface IStepwiseDatasource