DESY ACOP Beans Home

com.cosylab.gui.displayers
Class DoubleConsumerMulticaster

java.lang.Object
  extended by com.cosylab.gui.displayers.DoubleConsumerMulticaster
All Implemented Interfaces:
DataConsumer, DoubleConsumer, LongConsumer, NumberConsumer, ObjectConsumer, StringConsumer

public class DoubleConsumerMulticaster
extends java.lang.Object
implements DoubleConsumer, NumberConsumer, LongConsumer, StringConsumer, ObjectConsumer

DoubleConsumerMulticaster casts different data consumers to DoubleConsumer. ObjectConsumer cast must receive Number instances. Delegate must be set, before any other method can be used.

Since:
Dec 4, 2003.
Version:
$Id: DoubleConsumerMulticaster.java,v 1.8 2008-04-22 12:31:02 jbobnar Exp $
Author:
Igor Kriznar

Field Summary
static java.lang.Class[] PREFERED_CONSUMER_TYPES
          Types of data consumers, that should be prefered by DoubleConsumer parent.
static java.lang.Class[] SUPPORTED_CONSUMER_TYPES
          Types of data consumers, that are supported by this multicaster.
 
Constructor Summary
DoubleConsumerMulticaster()
          Creates a new DoubleConsumerMulticaster object.
DoubleConsumerMulticaster(DoubleConsumer delegate)
          Creates a new DoubleConsumerMulticaster object.
 
Method Summary
static DoubleConsumer createDataConsumer(java.lang.Class type, DoubleConsumer delegate)
          If multicaster supports type, new multicaster is created, otherwise nullis returned.
<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.
 DoubleConsumer getDelegate()
          Returns the consumer to which all call sare delegated.
 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 setCharacteristics(java.util.Map characteristics)
          Sets new dynamic value characteristics to this data consumer.
 void setDelegate(DoubleConsumer delegate)
          Sets the consumer to which all call sare delegated.
 void updateDataState(DataState state)
          Push data state (quality) update change for dynamic value.
 void updateValue(long timestamp, double value)
          Notifys this consumer about new dynamic value update.
 void updateValue(long timestamp, long value)
          Notifys this consumer about new dynamic value update.
 void updateValue(long timestamp, java.lang.Number value)
          Notifys this consumer about new dynamic value update.
 void updateValue(long timestamp, java.lang.Object value)
          Notifys this consumer about new dynamic value update.
 void updateValue(long timestamp, java.lang.String value)
          Notifys this consumer about new dynamic value update.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUPPORTED_CONSUMER_TYPES

public static final java.lang.Class[] SUPPORTED_CONSUMER_TYPES
Types of data consumers, that are supported by this multicaster.


PREFERED_CONSUMER_TYPES

public static final java.lang.Class[] PREFERED_CONSUMER_TYPES
Types of data consumers, that should be prefered by DoubleConsumer parent.

Constructor Detail

DoubleConsumerMulticaster

public DoubleConsumerMulticaster(DoubleConsumer delegate)
Creates a new DoubleConsumerMulticaster object.

Parameters:
delegate - the consumer to which all call sare delegated

DoubleConsumerMulticaster

public DoubleConsumerMulticaster()
Creates a new DoubleConsumerMulticaster object.

Method Detail

createDataConsumer

public static final DoubleConsumer createDataConsumer(java.lang.Class type,
                                                      DoubleConsumer delegate)
If multicaster supports type, new multicaster is created, otherwise nullis returned.

Parameters:
type - the requested consumer type
delegate - the consumer to which all call sare delegated
Returns:
new multicaster if type is supported, otherwise null

getDelegate

public DoubleConsumer getDelegate()
Returns the consumer to which all call sare delegated.

Returns:
the consumer to which all call sare delegated

setDelegate

public void setDelegate(DoubleConsumer delegate)
Sets the consumer to which all call sare delegated.

Parameters:
delegate - the consumer to which all calls are delegated

updateValue

public void updateValue(long timestamp,
                        double value)
                 throws CommonException
Description copied from interface: DoubleConsumer
Notifys this consumer about new dynamic value update.

Specified by:
updateValue in interface DoubleConsumer
Parameters:
timestamp - the time of dynamic value event
value - new value
Throws:
CommonException

updateValue

public void updateValue(long timestamp,
                        java.lang.Number value)
                 throws CommonException
Description copied from interface: NumberConsumer
Notifys this consumer about new dynamic value update.

Specified by:
updateValue in interface NumberConsumer
Parameters:
timestamp - the time of dynamic value event
value - new value
Throws:
CommonException

updateValue

public void updateValue(long timestamp,
                        long value)
                 throws CommonException
Description copied from interface: LongConsumer
Notifys this consumer about new dynamic value update.

Specified by:
updateValue in interface LongConsumer
Parameters:
timestamp - the time of dynamic value event
value - new value
Throws:
CommonException

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

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

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

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

updateValue

public void updateValue(long timestamp,
                        java.lang.String value)
                 throws CommonException
Description copied from interface: StringConsumer
Notifys this consumer about new dynamic value update.

Specified by:
updateValue in interface StringConsumer
Parameters:
timestamp - the time of dynamic value event
value - new value
Throws:
CommonException

updateValue

public void updateValue(long timestamp,
                        java.lang.Object value)
                 throws CommonException
Description copied from interface: ObjectConsumer
Notifys this consumer about new dynamic value update.

Specified by:
updateValue in interface ObjectConsumer
Parameters:
timestamp - the time of dynamic value event
value - new value
Throws:
CommonException

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

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

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


Copyright © 2010. All Rights Reserved.