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, MutableVariant 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
 boolean setValue(Variant nodeId, Variant value)
          Write value to datasource
 

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,
                 MutableVariant 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 in the node, otherwise true
Throws:
DatasourceException - if node does not exist

setValue

boolean setValue(Variant nodeId,
                 Variant value)
                 throws DatasourceException
Write value to datasource

Parameters:
nodeId - node
value - value
Returns:
true if value was written
Throws:
DatasourceException

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

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 -