org.epics.pvmanager
Class DataSourceTypeSupport

java.lang.Object
  extended by org.epics.pvmanager.DataSourceTypeSupport
Direct Known Subclasses:
JCATypeSupport

public class DataSourceTypeSupport
extends java.lang.Object

The type support for a datasource. This optional class is provided to help create a more flexible type support in a datasource, so that support for individual types is done through runtime configuration. It provides default implementation for matching typeAdapters from the desired cache and connection payload.

Author:
carcassi

Constructor Summary
DataSourceTypeSupport()
           
 
Method Summary
protected
<C,T extends DataSourceTypeAdapter<? super C,?>>
T
find(java.util.Collection<T> typeAdapters, ValueCache<?> cache, C connection)
          Given a collection of type datapters, finds the one that can store data in the cache given the channel information described in the connection payload.
protected  java.lang.String formatMessage(ValueCache<?> cache, java.lang.Object connection, int match, java.util.List<? extends DataSourceTypeAdapter<?,?>> matchedConverters)
          Formats the error message in case of not unique match.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSourceTypeSupport

public DataSourceTypeSupport()
Method Detail

find

protected <C,T extends DataSourceTypeAdapter<? super C,?>> T find(java.util.Collection<T> typeAdapters,
                                                                  ValueCache<?> cache,
                                                                  C connection)
Given a collection of type datapters, finds the one that can store data in the cache given the channel information described in the connection payload. If there isn't a unique match, an exception is thrown.

Type Parameters:
C - type of connection payload
T - datasource specific type adapter type
Parameters:
typeAdapters - a collection of type adapters
cache - the cache where to store the data
connection - the connection payload
Returns:
0 if the type was not matched

formatMessage

protected java.lang.String formatMessage(ValueCache<?> cache,
                                         java.lang.Object connection,
                                         int match,
                                         java.util.List<? extends DataSourceTypeAdapter<?,?>> matchedConverters)
Formats the error message in case of not unique match. This allows data sources to give more specific error messages.

Parameters:
cache - the cache used for the match
connection - the connection payload used for the match
match - the result of the match
matchedConverters - the matched converters; will either be 0 (no match) or more than 1 (non unique match)
Returns:
the message to be passed with the exception