DESY ACOP Beans Home

com.cosylab.gui.adapters
Interface DataSourceJoint<T extends DataSource>

Type Parameters:
T - type of DataSources added to this joint
All Superinterfaces:
DataSource
All Known Implementing Classes:
AcopDataSourceJoint

public interface DataSourceJoint<T extends DataSource>
extends DataSource

DataSourceJoint combines several DataSources and dispatch all their data in a prescribed manner. Each DataSource should be added to this joint together with an identifer that specifies what this joint should do with the data received from that particular source. The first DataSource in the joint should always have an identifier FIRST_IN_A_ROW, following by data sources with any other operation identifier. There can be only one source with identifier FIRST_IN_A_ROW.

When a new DataSource is added it should be the last in the chain of all data sources if not specified otherwise. Value from each DataSource should meet an arythmetic operation with the value calculated from sources that are higher up in the chain (were added to this joint earlier).

addDataSource(source1, FIRST_IN_A_ROW); addDataSource(source2, ADD); addDataSource(source3, MULTIPLY); should give a result of (source1 + source2)* source3.

Author:
Jaka Bobnar, Cosylab

Field Summary
static java.lang.String ADD
          Identifier for addition
static java.lang.String DIVIDE
          Identifier for division
static java.lang.String FIRST_IN_A_ROW
          Identifier for the first DataSource
static java.lang.String MULTIPLY
          Identifier for multiplication
static java.lang.String SUBSTRACT
          Identifier for substraction
 
Method Summary
 void addDataSource(T dataSource, java.lang.String operation)
          Adds a DataSource to the chain of source as the last dataSource.
 void addDataSource(T dataSource, java.lang.String operation, int index)
          Adds a DataSource to the chain of source at the position specified by index.
 java.util.Map<T,java.lang.String> getDataSources()
          Returns a Map of all dataSources and their identifiers.
 java.lang.String removeDataSource(T dataSource)
          Removes the dataSource from this joint.
 
Methods inherited from interface com.cosylab.gui.displayers.DataSource
addConsumer, getAcceptableConsumerTypes, getConsumers, removeAllConsumers, removeConsumer
 

Field Detail

FIRST_IN_A_ROW

static final java.lang.String FIRST_IN_A_ROW
Identifier for the first DataSource

See Also:
Constant Field Values

MULTIPLY

static final java.lang.String MULTIPLY
Identifier for multiplication

See Also:
Constant Field Values

DIVIDE

static final java.lang.String DIVIDE
Identifier for division

See Also:
Constant Field Values

ADD

static final java.lang.String ADD
Identifier for addition

See Also:
Constant Field Values

SUBSTRACT

static final java.lang.String SUBSTRACT
Identifier for substraction

See Also:
Constant Field Values
Method Detail

addDataSource

void addDataSource(T dataSource,
                   java.lang.String operation)
                   throws java.lang.IllegalArgumentException,
                          java.beans.PropertyVetoException
Adds a DataSource to the chain of source as the last dataSource. The operation between added DataSource and the existing chain is specified by operation parameter, which can be one of the public identifiers.

Parameters:
dataSource -
operation -
Throws:
java.lang.IllegalArgumentException - when a given datasource have operation FIRST_IN_A_ROW and a DataSource with this identifier already exists
java.beans.PropertyVetoException

addDataSource

void addDataSource(T dataSource,
                   java.lang.String operation,
                   int index)
                   throws java.lang.IllegalArgumentException,
                          java.beans.PropertyVetoException
Adds a DataSource to the chain of source at the position specified by index. The operation between added DataSource and the existing chain is specified by operation parameter, which can be one of the public identifiers. The FIRST_IN_A_ROW is specified by index 0. If a DataSource is added as first in a row it would replace the existing first DataSource and its identifier should be automatically changed to FIRST_IN_A_ROW if a different one is given.

Parameters:
dataSource -
operation -
index -
Throws:
java.lang.IllegalArgumentException - when a given index is invalid (larger than the number of data sources in this joint)
java.beans.PropertyVetoException

removeDataSource

java.lang.String removeDataSource(T dataSource)
Removes the dataSource from this joint. When a single DataSource is removed, it should not have any effects on the complete chain of sources. The sources that are further down in the chain should be moves upward. Method should return identifier of the operation associated with the removed data source.

Parameters:
dataSource - DataSource to be removed
Returns:
operation associated with the data source

getDataSources

java.util.Map<T,java.lang.String> getDataSources()
Returns a Map of all dataSources and their identifiers. The map is expected to use data sources as keys and operation identifiers as values. The order of data sources should be preserved.

Returns:
a map of all data sources


Copyright © 2010. All Rights Reserved.