org.epics.pvmanager
Class TypeSupport<T>

java.lang.Object
  extended by org.epics.pvmanager.TypeSupport<T>
Direct Known Subclasses:
TimedTypeSupport

public abstract class TypeSupport<T>
extends java.lang.Object

Implements the mechanism for registering different types so that the library knows how to handle them.

For a type to be usable by the library it needs to be defined:

Author:
carcassi

Nested Class Summary
static class TypeSupport.Notification<T>
           
 
Constructor Summary
TypeSupport()
           
 
Method Summary
static
<T> void
addTypeSupport(java.lang.Class<T> typeClass, TypeSupport<T> typeSupport)
          Adds support for a new type.
static
<T> TypeSupport.Notification<T>
notification(T oldValue, T newValue)
          Returns the final value by using the appropriate type support.
abstract  TypeSupport.Notification<T> prepareNotification(T oldValue, T newValue)
          Given the old and new value, prepare the final value that will be notified.
static
<T> TimeStamp
timestampOf(T value)
          Extracts the TimeStamp of the value using the appropriate type support.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeSupport

public TypeSupport()
Method Detail

prepareNotification

public abstract TypeSupport.Notification<T> prepareNotification(T oldValue,
                                                                T newValue)
Given the old and new value, prepare the final value that will be notified. This method is guaranteed to be called in the notification thread (the UI thread). This method may either update the old value or return the new value, depending on whether the type is immutable or what is more efficient.

Parameters:
oldValue - the oldValue, which was previously in the previous notification
newValue - the newValue, which was computed during the scanning
Returns:
the value to be notified

addTypeSupport

public static <T> void addTypeSupport(java.lang.Class<T> typeClass,
                                      TypeSupport<T> typeSupport)
Adds support for a new type.

Type Parameters:
T - the type to add support for
Parameters:
typeClass - the class of the type
typeSupport - the support for the type

notification

public static <T> TypeSupport.Notification<T> notification(T oldValue,
                                                           T newValue)
Returns the final value by using the appropriate type support.

Type Parameters:
T - the type of the value
Parameters:
oldValue - the oldValue, which was previously in the previous notification
newValue - the newValue, which was computed during the scanning
Returns:
the value to be notified

timestampOf

public static <T> TimeStamp timestampOf(T value)
Extracts the TimeStamp of the value using the appropriate type support.

Type Parameters:
T - the type of the value
Parameters:
value - the value from which to extract the timestamp
Returns:
the extracted timestamp


Copyright © 2010. All Rights Reserved.