DESY ACOP Beans Home

com.cosylab.gui.displayers
Class PatternConsumerMulticaster

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

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

PatternConsumerMulticaster casts different data consumers to PatternConsumer. Delegate must be set, before any other method can be used.

Since:
Jul 27, 2004.
Version:
$Id: PatternConsumerMulticaster.java,v 1.7 2008-04-22 12:31:02 jbobnar Exp $
Author:
Anze Zupanc

Field Summary
static java.lang.Class[] SUPPORTED_CONSUMER_TYPES
          Types of data consumers, that are supported by this multicaster.
 
Constructor Summary
PatternConsumerMulticaster()
          Creates a new PatternConsumerMulticaster object.
PatternConsumerMulticaster(PatternConsumer delegate)
          Creates a new PatternConsumerMulticaster object.
 
Method Summary
static PatternConsumer createDataConsumer(java.lang.Class type, PatternConsumer 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.
 PatternConsumer 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[] 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(PatternConsumer 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, java.util.BitSet value)
          Notifys this consumer about new dynamic value update.
 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.

Constructor Detail

PatternConsumerMulticaster

public PatternConsumerMulticaster()
Creates a new PatternConsumerMulticaster object.


PatternConsumerMulticaster

public PatternConsumerMulticaster(PatternConsumer delegate)
Creates a new PatternConsumerMulticaster object.

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

createDataConsumer

public static final PatternConsumer createDataConsumer(java.lang.Class type,
                                                       PatternConsumer 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

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

getDelegate

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

Returns:
the consumer to which all call sare delegated

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[] 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

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

setDelegate

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

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

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.util.BitSet value)
                 throws CommonException
Description copied from interface: PatternConsumer
Notifys this consumer about new dynamic value update.

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

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,
                        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

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,
                        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

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

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


Copyright © 2010. All Rights Reserved.