org.simantics.databoard.datasource
Interface IStepwiseDatasource

All Known Implementing Classes:
ExampleDatasource, StepwiseDatasource

public interface IStepwiseDatasource

Interface for stepwise data sources. The values of a Stepwise Datasource changes only at #step(). Root node is mandatory. The identifier of root node is the an empty record. You can instantiate root node id with ID_BINDING.createDefaultUnchecked()

Author:
Toni Kalajainen
See Also:
ExampleDatasource, StepwiseDatasourceAccessor

Nested Class Summary
static interface IStepwiseDatasource.DatasourceListener
           
 
Method Summary
 void addListener(IStepwiseDatasource.DatasourceListener listener)
          Add datamodel listener
 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.
 

Method Detail

getAll

void getAll(java.util.Collection<Variant> list)
Get a list of all node identifiers.

Parameters:
list - to be filled with identifiers.

hasNode

boolean hasNode(Variant nodeId)
Verifies that the datasource has a node

Parameters:
nodeId -
Returns:
true if node exists, false if not

getChildren

void getChildren(Variant nodeId,
                 java.util.Collection<Variant> children)
                 throws DatasourceException
Get children of a node

Parameters:
nodeId -
children - a collection to be filled with children
Throws:
DatasourceException - if the node does not exist

getValue

boolean getValue(Variant nodeId,
                 Variant value)
                 throws DatasourceException
Get value of a node

Parameters:
nodeId -
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

DataType getNodeType(Variant nodeId)
                     throws DatasourceException
Get the value type of a node.

Parameters:
nodeId -
Returns:
value type or null if there is no value
Throws:
DatasourceException - if the node does not exist

step

java.util.Collection<Variant> step(java.util.Collection<Variant> monitorSet)
                                   throws DatasourceException
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.

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

java.lang.String getLabel(Variant nodeId,
                          java.lang.String locale)
                          throws DatasourceException
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.

Parameters:
nodeId -
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

void getLabels(Variant nodeId,
               java.util.Map<java.lang.String,java.lang.String> labels)
               throws DatasourceException
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.

Parameters:
nodeId -
labels - a collection to be filled
Throws:
DatasourceException - if error occurs

addListener

void addListener(IStepwiseDatasource.DatasourceListener listener)
Add datamodel listener

Parameters:
listener -

removeListener

void removeListener(IStepwiseDatasource.DatasourceListener listener)
Remove datamodel listener

Parameters:
listener -