|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
com.sas.PropertyLinkAdaptor
public class PropertyLinkAdaptor
PropertyLinkAdaptor is the controller which handles a property link between two properties. It listens for PropertyChangeEvents from the source property and calls the write method for the target property. The value of the source property may be transformed to a value suitable for the target property if an appropriate transform is registered (or set when the link is added).
PropertyLinkAdaptor tries to be efficient by caching as much information as possible about how to transform the source value and set it on the target property.
The PropertyLinkAdaptor also has the ability to use another object which implements the PropertyValueQueryInterface to get/set the property values to/from. This is useful in cases where real JavaBeans properties do not exist or the application wishes to avoid using reflection to get/set the property value.
PropertyValueQueryInterface| Field Summary | |
|---|---|
protected boolean |
enabled
true if the link is enabled and PropertyChangeEvents are handled. |
protected java.util.EventListener |
eventListenerProxy
|
protected java.util.Set |
interfaceSet
|
protected boolean |
linkConnected
|
protected com.sas.PropertyValueQueryInterface |
propertyValueSource
null if the property values should be queried from the sourceObject. |
protected com.sas.PropertyValueQueryInterface |
propertyValueTarget
null if the property values should be set by calling the sourceObject. |
protected static java.util.Map |
proxyMap
|
static java.lang.String |
RB_KEY
|
protected java.lang.Class |
sourceClass
The cached Class of the source property value. |
protected java.lang.reflect.Method |
sourceGetMethod
The cached "get" method for the source property. |
protected static java.util.Map |
sourceMap
|
protected java.lang.Object |
sourceObject
The object whose property value change should trigger the link. |
protected java.lang.String |
sourceProperty
The property of the source object which should trigger the link. |
protected java.lang.Class |
targetClass
The cached Class of the target property value. |
protected java.lang.Object |
targetObject
The object which should have its property value set when the source property changes. |
protected java.lang.String |
targetProperty
The property of the target object which should be set with the value of the source property (or a transformation of that value) when the value of the source property changes. |
protected java.lang.reflect.Method |
targetSetMethod
The cached "set" method for the target property. |
protected com.sas.util.transforms.TransformInterface |
transform
The transform used to convert the value of the source property to the type used by the target property. |
protected boolean |
transformSpecified
true if the transform was specified when the PropertyLinkAdaptor was created. |
static java.util.Map |
userProxyMap
|
| Constructor Summary | |
|---|---|
PropertyLinkAdaptor(java.lang.Object sourceObject,
java.lang.Object targetObject,
java.lang.String sourceProperty,
java.lang.String targetProperty)
Constructor. |
|
PropertyLinkAdaptor(java.lang.Object sourceObject,
java.lang.Object targetObject,
java.lang.String sourceProperty,
java.lang.String targetProperty,
com.sas.util.transforms.TransformInterface specifiedTransform)
Constructor. |
|
PropertyLinkAdaptor(java.lang.Object sourceObject,
java.lang.Object targetObject,
java.lang.String sourceProperty,
java.lang.String targetProperty,
com.sas.util.transforms.TransformInterface specifiedTransform,
com.sas.PropertyValueQueryInterface propertyValueSource,
com.sas.PropertyValueQueryInterface propertyValueTarget)
Constructor. |
|
| Method Summary | |
|---|---|
void |
addLink()
Add a link between the current source and target if one doesn't already exist. |
static PropertyLinkAdaptor |
addLink(java.lang.Object sourceObject,
java.lang.String sourceProperty,
java.lang.Object targetObject,
java.lang.String targetProperty)
Utility method to create a link between two properties. |
static PropertyLinkAdaptor |
addLink(java.lang.Object sourceObject,
java.lang.String sourceProperty,
java.lang.Object targetObject,
java.lang.String targetProperty,
com.sas.util.transforms.TransformInterface specifiedTransform)
Utility method to create a link between two properties. |
static PropertyLinkAdaptor |
addLink(java.lang.Object sourceObject,
java.lang.String sourceProperty,
java.lang.Object targetObject,
java.lang.String targetProperty,
com.sas.util.transforms.TransformInterface specifiedTransform,
com.sas.PropertyValueQueryInterface propertyValueSource,
com.sas.PropertyValueQueryInterface propertyValueTarget)
Utility method to create a link between two properties. |
protected void |
addToSourceAdaptors()
Add the current source object and property to a tracking map. |
protected void |
cleanUpLoopingHistory(java.beans.PropertyChangeEvent evt)
Helper method to clean up the looping history on the target component. |
protected static boolean |
containsProxy(java.lang.Class sourceClass,
java.lang.String sourceProperty,
java.util.Map listenerProxyMap)
Test if the listener proxy map contains the specified source property. |
protected java.lang.Object |
createLinkListenerProxy(java.util.Set methodSet,
java.util.Set interfaceSet,
PropertyLinkAdaptor target)
Create a proxy object that implements the interfaces from the interfaceSet. |
protected java.util.List |
findListenerMethodList(java.lang.Class sourceClass,
java.lang.String sourceProperty)
Find any listener methods for the specified source property. |
protected java.util.List |
getAdaptors(java.lang.Object source,
java.lang.String propertyName)
|
protected java.lang.Object |
getPropertyValue()
Retrieves the value of the source property from the source component. |
protected static java.util.Map |
getProxyMap()
Get the current list of methods to use in the proxy for each specific property. |
java.lang.Object |
getSource()
|
java.lang.String |
getSourceProperty()
|
java.lang.Object |
getTarget()
|
java.lang.String |
getTargetProperty()
|
boolean |
isConnected()
Determine if the PropertyLinkAdaptor is already connected. |
boolean |
isEnabled()
isEnabled returns whether the link is currently handling PropertyChangeEvents received from the source component. |
static boolean |
isLinkable(java.lang.Object source,
java.lang.String property)
Check if a specific property is able to be linked to. |
protected static void |
loadProxyMap()
Load the map of properties and methods to activate any links from those properties. |
protected void |
processEventListener(java.lang.String listenerOperation,
java.util.Set listenerInterfaceSet,
java.lang.Object eventSource,
java.util.EventListener eventListener)
Process the eventListener. |
protected void |
processInterfaceMethods(java.util.List listenerMethodList,
java.util.Set interfaceSet,
java.util.Set methodSet)
Process the list of methods to produce an interface set and a method set. |
protected java.util.List |
processListenerMethodList(java.lang.String listenerList)
Process the list of listenerInterfaces and methods. |
void |
propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange handles the PropertyChangeEvent from the source object. |
protected boolean |
removeFromSourceAdaptors()
Remove the current source object and property from the tracking map. |
void |
removeLink()
Disconnect the current link if it is connected. |
static void |
removeLink(PropertyLinkAdaptor adaptor)
Utility method to remove a link between two properties. |
void |
setEnabled(boolean enabled)
setEnabled sets whether the link is currently handling PropertyChangeEvents received from the source component. |
protected void |
setPropertyValue(java.lang.Object newValue)
Sets the property value on the target property. |
void |
synchronizeValues()
Synchonize the values of the source and the target of the link. |
| Field Detail |
|---|
public static final java.lang.String RB_KEY
protected java.lang.Object sourceObject
protected java.lang.Object targetObject
protected java.lang.String sourceProperty
protected java.lang.String targetProperty
protected com.sas.util.transforms.TransformInterface transform
protected java.lang.reflect.Method sourceGetMethod
protected java.lang.reflect.Method targetSetMethod
protected java.lang.Class sourceClass
protected java.lang.Class targetClass
protected boolean transformSpecified
protected com.sas.PropertyValueQueryInterface propertyValueSource
propertyValueSource
object.
protected com.sas.PropertyValueQueryInterface propertyValueTarget
propertyValueTarget
object.
protected boolean enabled
protected java.util.Set interfaceSet
protected java.util.EventListener eventListenerProxy
protected boolean linkConnected
protected static java.util.Map sourceMap
protected static java.util.Map proxyMap
public static java.util.Map userProxyMap
| Constructor Detail |
|---|
public PropertyLinkAdaptor(java.lang.Object sourceObject,
java.lang.Object targetObject,
java.lang.String sourceProperty,
java.lang.String targetProperty)
sourceObject - The object to listen for changes to the value of the sourceProperty on.targetObject - The object to set the value on when the link is triggered.sourceProperty - The property on the source object to listen for changes to.targetProperty - The property on the target object to set.
public PropertyLinkAdaptor(java.lang.Object sourceObject,
java.lang.Object targetObject,
java.lang.String sourceProperty,
java.lang.String targetProperty,
com.sas.util.transforms.TransformInterface specifiedTransform)
sourceObject - The object to listen for changes to the value of the sourceProperty on.targetObject - The object to set the value on when the link is triggered.sourceProperty - The property on the source object to listen for changes to.targetProperty - The property on the target object to set.specifiedTransform - The transform to be used to convert the source property value to the target property type.
public PropertyLinkAdaptor(java.lang.Object sourceObject,
java.lang.Object targetObject,
java.lang.String sourceProperty,
java.lang.String targetProperty,
com.sas.util.transforms.TransformInterface specifiedTransform,
com.sas.PropertyValueQueryInterface propertyValueSource,
com.sas.PropertyValueQueryInterface propertyValueTarget)
sourceObject - The object to listen for changes to the value of the sourceProperty on.targetObject - The object to set the value on when the link is triggered.sourceProperty - The property on the source object to listen for changes to.targetProperty - The property on the target object to set.specifiedTransform - The transform to be used to convert the source property value to the target property type.propertyValueSource - The object to get/set the property values from. Passing in null
means that reflection should be used to get/set the value of the property from
the sourceObject and the targetObject.| Method Detail |
|---|
public static PropertyLinkAdaptor addLink(java.lang.Object sourceObject,
java.lang.String sourceProperty,
java.lang.Object targetObject,
java.lang.String targetProperty)
sourceObject - The object to listen for changes to the value of the sourceProperty on.targetObject - The object to set the value on when the link is triggered.sourceProperty - The property on the source object to listen for changes to.targetProperty - The property on the target object to set.
public static PropertyLinkAdaptor addLink(java.lang.Object sourceObject,
java.lang.String sourceProperty,
java.lang.Object targetObject,
java.lang.String targetProperty,
com.sas.util.transforms.TransformInterface specifiedTransform)
sourceObject - The object to listen for changes to the value of the sourceProperty on.targetObject - The object to set the value on when the link is triggered.sourceProperty - The property on the source object to listen for changes to.targetProperty - The property on the target object to set.specifiedTransform - The transform to be used to convert the source property value to the target property type.
This value may be null, indicating that a transform will be looked up in the list of
registered transforms.
public static PropertyLinkAdaptor addLink(java.lang.Object sourceObject,
java.lang.String sourceProperty,
java.lang.Object targetObject,
java.lang.String targetProperty,
com.sas.util.transforms.TransformInterface specifiedTransform,
com.sas.PropertyValueQueryInterface propertyValueSource,
com.sas.PropertyValueQueryInterface propertyValueTarget)
sourceObject - The object to listen for changes to the value of the sourceProperty on.targetObject - The object to set the value on when the link is triggered.sourceProperty - The property on the source object to listen for changes to.targetProperty - The property on the target object to set.specifiedTransform - The transform to be used to convert the source property value to the target property type.
This value may be null, indicating that a transform will be looked up in the list of
registered transforms.propertyValueSource - The object to get/set the property values from. Passing in null
means that reflection should be used to get/set the value of the property from
the sourceObject and the targetObject.
public static boolean isLinkable(java.lang.Object source,
java.lang.String property)
source - the source object that the link will get the value for the target fromproperty - the property on the source to check if it is linkablepublic boolean isConnected()
public java.lang.Object getSource()
public java.lang.Object getTarget()
public java.lang.String getSourceProperty()
public java.lang.String getTargetProperty()
protected java.lang.Object createLinkListenerProxy(java.util.Set methodSet,
java.util.Set interfaceSet,
PropertyLinkAdaptor target)
methodSet - the methods which the proxy specifically handleinterfaceSet - the interfaces which the proxy will implementtarget - the PropertyLinkAdaptor to call synchronizeValues() on when one of the methods in the methodSet is called
protected void processInterfaceMethods(java.util.List listenerMethodList,
java.util.Set interfaceSet,
java.util.Set methodSet)
protected static void loadProxyMap()
protected static java.util.Map getProxyMap()
protected java.util.List processListenerMethodList(java.lang.String listenerList)
protected static boolean containsProxy(java.lang.Class sourceClass,
java.lang.String sourceProperty,
java.util.Map listenerProxyMap)
sourceClass - the class of with the property to find in the listener proxy mapsourceProperty - the property to find in the listener proxy maplistenerProxyMap - the map to search for the property
protected java.util.List findListenerMethodList(java.lang.Class sourceClass,
java.lang.String sourceProperty)
sourceClass - the class of with the property to find in the listener proxy mapsourceProperty - the property to find in the listener proxy map
protected void processEventListener(java.lang.String listenerOperation,
java.util.Set listenerInterfaceSet,
java.lang.Object eventSource,
java.util.EventListener eventListener)
listenerOperation - the prefix of the method to executelistenerInterfaceSet - the set of listener interfaces to execute the method foreventSource - the object used to execute the specified methodeventListener - the argument for the method to executepublic void addLink()
protected void addToSourceAdaptors()
protected boolean removeFromSourceAdaptors()
protected java.util.List getAdaptors(java.lang.Object source,
java.lang.String propertyName)
public void synchronizeValues()
public static void removeLink(PropertyLinkAdaptor adaptor)
adaptor - The adaptor that should no longer be linking.public void removeLink()
public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange in interface java.beans.PropertyChangeListenerevt - The property change event from the source object.protected void cleanUpLoopingHistory(java.beans.PropertyChangeEvent evt)
evt - The PropertyChangeEvent that is currently being handled.protected java.lang.Object getPropertyValue()
protected void setPropertyValue(java.lang.Object newValue)
newValue - The new value for the property.public boolean isEnabled()
setEnabled(boolean)public void setEnabled(boolean enabled)
enabled - whether the link is currently handling PropertyChangeEvents received from the
source component.isEnabled()
|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||