DESY ACOP Beans Home

com.cosylab.gui.adapters
Class ConverterChain

java.lang.Object
  extended by com.cosylab.gui.adapters.ConverterChain
All Implemented Interfaces:
Converter, DataConsumer, DataSource, java.io.Serializable, java.lang.Cloneable

public class ConverterChain
extends java.lang.Object
implements Converter

ConverterChain combines several converter into a single one. Single converters can be added to this chain. The value will then be converted by each of this single converters resulting in an arbitrary function applied to the input value.

Author:
Igor Kriznar (igor.kriznarATcosylab.com)
See Also:
Serialized Form

Constructor Summary
ConverterChain()
          Creates new instance of ConverterChain.
ConverterChain(Converter[] converters)
          Creates new instance of ConverterChain.
 
Method Summary
 void addConsumer(DataConsumer consumer)
          Registers data consumer at this data source.
 java.lang.Object clone()
           
 Converter get(int index)
          Returns the converter under the specified index.
 java.lang.Class<DataConsumer>[] getAcceptableConsumerTypes()
          Returns the array of consumer types, which are acceptable by this data source.
 DataConsumer[] getConsumers()
          Returns array of registered data consumer.
 Converter[] getConverters()
          Returns all converters in the chain.
<D extends DataConsumer>
D
getDataConsumer(java.lang.Class<D> type)
           Returns data consumer for requested data consumer type.
 DataConsumer getDefaultDataConsumer()
          Returns the implementation of default consumer type supported by this data consumer.
 Converter getFirst()
          Returns the first converter in the chain.
 Converter getLast()
          Returns the last converter in the chain.
 java.lang.String getName()
          Returns name of this data consumer.
 java.lang.String[] getSupportedCharacteristics()
          Resturns array with names of supported characteristics.
 java.lang.Class<DataConsumer>[] getSupportedConsumerTypes()
          Returns array of supported data consumer types, which can be used as parameter and returnned with getDataCosnumer(Class) method.
 void removeAllConsumers()
          Removes all consumers from data source and releases all resources and bindings allocated inside datasource to the consumers.
 void removeConsumer(DataConsumer consumer)
          Deregisters data consumer from this data source.
 void setCharacteristics(java.util.Map characteristics)
          Sets new dynamic value characteristics to this data consumer.
 int size()
          Returns the number of all converters in the chain.
 java.lang.String toString()
           
 void updateDataState(DataState state)
          Push data state (quality) update change for dynamic value.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConverterChain

public ConverterChain()
               throws java.beans.PropertyVetoException
Creates new instance of ConverterChain.

Throws:
java.beans.PropertyVetoException

ConverterChain

public ConverterChain(Converter[] converters)
               throws java.beans.PropertyVetoException
Creates new instance of ConverterChain.

Throws:
java.beans.PropertyVetoException
Method Detail

addConsumer

public void addConsumer(DataConsumer consumer)
                 throws java.beans.PropertyVetoException
Description copied from interface: DataSource
Registers data consumer at this data source. This data source can denay consumer by throwing PropertyVetoException if consumer does not provide necessary DataConsumer type.

Specified by:
addConsumer in interface DataSource
Parameters:
consumer - the data consumer to be regitered at this data source
Throws:
java.beans.PropertyVetoException
See Also:
DataConsumer.getDataConsumer(Class)

removeConsumer

public void removeConsumer(DataConsumer consumer)
Description copied from interface: DataSource
Deregisters data consumer from this data source.

Specified by:
removeConsumer in interface DataSource
Parameters:
consumer - data consumer to be deregistered

getConsumers

public DataConsumer[] getConsumers()
Description copied from interface: DataSource
Returns array of registered data consumer.

Specified by:
getConsumers in interface DataSource
Returns:
array of registered data consumer

getAcceptableConsumerTypes

public java.lang.Class<DataConsumer>[] getAcceptableConsumerTypes()
Description copied from interface: DataSource
Returns the array of consumer types, which are acceptable by this data source.

Specified by:
getAcceptableConsumerTypes in interface DataSource
Returns:
the array of acceptable data source types

removeAllConsumers

public void removeAllConsumers()
Description copied from interface: DataSource
Removes all consumers from data source and releases all resources and bindings allocated inside datasource to the consumers.

Specified by:
removeAllConsumers in interface DataSource

getDataConsumer

public <D extends DataConsumer> D getDataConsumer(java.lang.Class<D> type)
Description copied from interface: DataConsumer

Returns data consumer for requested data consumer type. If this data consumer does not support required data consumer, null is returned.

If this data cosnumer does not support specific data consumer type, then it means, that it is not desirable to cast data of that type to any by this consumer supported data consumer types.

Specified by:
getDataConsumer in interface DataConsumer
Parameters:
type - Class of specific data consumer (e.g. DoubleConsumer)
Returns:
implementation of required data consumer or null if not supported

getDefaultDataConsumer

public DataConsumer getDefaultDataConsumer()
Description copied from interface: DataConsumer
Returns the implementation of default consumer type supported by this data consumer.

Specified by:
getDefaultDataConsumer in interface DataConsumer
Returns:
the implementation of default consumer type supported by this data consumer

updateDataState

public void updateDataState(DataState state)
Description copied from interface: DataConsumer
Push data state (quality) update change for dynamic value. Usually called by data source.

Specified by:
updateDataState in interface DataConsumer
Parameters:
state - new data state(quality) descriptor

setCharacteristics

public void setCharacteristics(java.util.Map characteristics)
Description copied from interface: DataConsumer
Sets new dynamic value characteristics to this data consumer. This is usually called only at initializaation, before first data state or value is updated. Usually carries characteristics such as value minimum or maximum. Name and meaning of atributes is defined with contract betwean data consumer and source implementation.

Specified by:
setCharacteristics in interface DataConsumer
Parameters:
characteristics - the Map with attri

getName

public java.lang.String getName()
Description copied from interface: DataConsumer
Returns name of this data consumer.

Specified by:
getName in interface DataConsumer
Returns:
the name of this data consumer

getSupportedCharacteristics

public java.lang.String[] getSupportedCharacteristics()
Description copied from interface: DataConsumer
Resturns array with names of supported characteristics. Data source can use this method to optimize setting characteristics to this data consumer. If arrray of length 0 is return, then consumer does not need or support any characteristic. If null is returned, than consumer expect all existing characteristics from data source.

Specified by:
getSupportedCharacteristics in interface DataConsumer
Returns:
array with names of supported characteristics

getSupportedConsumerTypes

public java.lang.Class<DataConsumer>[] getSupportedConsumerTypes()
Description copied from interface: DataConsumer
Returns array of supported data consumer types, which can be used as parameter and returnned with getDataCosnumer(Class) method.

Specified by:
getSupportedConsumerTypes in interface DataConsumer
Returns:
array of supported data consumer types

getLast

public Converter getLast()
Returns the last converter in the chain.

Returns:

getFirst

public Converter getFirst()
Returns the first converter in the chain.

Returns:

get

public Converter get(int index)
Returns the converter under the specified index.

Parameters:
index - index of the requested converter
Returns:
the converter

size

public int size()
Returns the number of all converters in the chain.

Returns:

getConverters

public Converter[] getConverters()
Returns all converters in the chain.

Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Specified by:
clone in interface Converter
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException


Copyright © 2010. All Rights Reserved.