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 abstract class StepwiseDatasource
extends java.lang.Object
implements IStepwiseDatasource

This is an implementation that composes nodes and forms a datasource.

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, 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
 void step()
           
 
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

step

public void step()
          throws DatasourceException
Throws:
DatasourceException

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

setValue

public boolean setValue(Variant nodeId,
                        Variant value)
                 throws DatasourceException
Description copied from interface: IStepwiseDatasource
Write value to datasource

Specified by:
setValue in interface IStepwiseDatasource
Parameters:
nodeId - node
value - value
Returns:
true if value was written
Throws:
DatasourceException

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

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 http://dev.simantics.org/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