com.iternum.swlink
Class DefaultLink

java.lang.Object
  extended bycom.iternum.swlink.DefaultLink
All Implemented Interfaces:
Activatable, EndpointObserver, Link

public final class DefaultLink
extends java.lang.Object
implements Link, Activatable

A default implementation of the Link interface.

Author:
Karl F. Banke

Constructor Summary
DefaultLink()
          Create a new abstract link.
DefaultLink(java.lang.Object pSource, java.lang.Object pTarget, Activator pActivator, Action pAction)
          Creates a new DefaultLink.
DefaultLink(java.lang.Object pSource, java.lang.Object pTarget, java.lang.String pSourcePath, java.lang.String pTargetPath, Activator pActivator, Action pAction)
          Creates a new DefaultLink where the actual source and target are determined using nested path expression.
 
Method Summary
 void activate()
          Activates the link.
 void activate(java.lang.Object pArgs)
          Activates the link.
 void close()
          Unlink the from its source and its target link.
 Action getAction()
           
 java.lang.Object getSource()
           
 java.lang.Object getTarget()
          The target of the link.
protected  java.lang.Object[] getThisInArray()
           
 boolean isActivateOnSetSource()
           
 void setAction(Action pAction)
           
 void setActivateOnSetSource(boolean pIsActivate)
           
 void setActivator(Activator pActivator)
          Sets the Activator of this link.
 void setSource(java.lang.Object pSource)
          Sets and registers the source of this link.
 void setSource(java.lang.Object pSource, java.lang.String pPath)
          Sets the source of the link as a nested property of a passed object.
 void setTarget(java.lang.Object pTarget)
          Sets and registers the target of this link.
 void setTarget(java.lang.Object pTarget, java.lang.String pPath)
          Sets the target object of the link as a nested property of a passed object.
 void sourceChanged(java.lang.Object pObject)
          Called if the source Proxy that this link is observing is changed.
 void targetChanged(java.lang.Object pObject)
          Called if the target Proxy that this link is observing is changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultLink

public DefaultLink()
Create a new abstract link. This link will activate by default if its source changes


DefaultLink

public DefaultLink(java.lang.Object pSource,
                   java.lang.Object pTarget,
                   Activator pActivator,
                   Action pAction)
Creates a new DefaultLink.

Parameters:
pSource - - The source of the link
pTarget - - The target of the link
pActivator - - The activator used by this link
pAction - - The action executed if the link is activated

DefaultLink

public DefaultLink(java.lang.Object pSource,
                   java.lang.Object pTarget,
                   java.lang.String pSourcePath,
                   java.lang.String pTargetPath,
                   Activator pActivator,
                   Action pAction)
Creates a new DefaultLink where the actual source and target are determined using nested path expression.

Parameters:
pSource - - The source of the link
pTarget - - The target of the link
pSourcePath - The path to resolve the source to an (optional) nested proprty
pTargetPath - The path to resolve the target to an (optional) nested proprty
pActivator - - The activator used by this link
pAction - - The action executed if the link is activated
Method Detail

close

public final void close()
Description copied from interface: Link
Unlink the from its source and its target link.

Specified by:
close in interface Link
See Also:
Link.close()

getTarget

public java.lang.Object getTarget()
Description copied from interface: Link
The target of the link.

Specified by:
getTarget in interface Link
Returns:
The target of this link

getSource

public java.lang.Object getSource()
Specified by:
getSource in interface Link
Returns:
The source of this link

setSource

public void setSource(java.lang.Object pSource)
Description copied from interface: Link
Sets and registers the source of this link. If the passed argument is of Type EndpointProxy the link add itself as an Observer with the EndpointProxy and uses the object wrapped in the proxy as the actual target

Specified by:
setSource in interface Link
Parameters:
pSource - The new source to set

setTarget

public void setTarget(java.lang.Object pTarget)
Description copied from interface: Link
Sets and registers the target of this link. If the passed argument is of Type EndpointProxy the link add itself as an Observer with the EndpointProxy and uses the object wrapped in the proxy as the actual target

Specified by:
setTarget in interface Link
Parameters:
pTarget - The new target to set

setSource

public void setSource(java.lang.Object pSource,
                      java.lang.String pPath)
Sets the source of the link as a nested property of a passed object. The actual source object is resolved using nested property of the source path. In case the source is an EndpointProxy, the source path applies to the wrapped object

Specified by:
setSource in interface Link
Parameters:
pSource - The source of the link or an EndpointProxy
pPath - The property path relative to pSource

setTarget

public void setTarget(java.lang.Object pTarget,
                      java.lang.String pPath)
Sets the target object of the link as a nested property of a passed object. The target object is resolved using the target path. In case the target object is an EndpointProxy, the target path applies to the wrapped object

Specified by:
setTarget in interface Link
Parameters:
pTarget - The target of the link or an EndpointProxy
pPath - The property path relative to pTarget

getAction

public Action getAction()
Specified by:
getAction in interface Link
Returns:
Returns the action.

setAction

public void setAction(Action pAction)
Specified by:
setAction in interface Link
Parameters:
pAction - The action to set.

getThisInArray

protected java.lang.Object[] getThisInArray()
Returns:
Returns an array containing and this instance

setActivator

public void setActivator(Activator pActivator)
Sets the Activator of this link.

Specified by:
setActivator in interface Link
Parameters:
pActivator - - the activator to set

activate

public void activate(java.lang.Object pArgs)
Activates the link. Invokes the Action defined for the link. Only activates if this link has a source, a target and an associated action.

Specified by:
activate in interface Activatable
Parameters:
pArgs - Additional arguments passed on activation

activate

public void activate()
Activates the link. Invokes the Action set for the link. Only activates if this link has a source, a target and an associated action.

Specified by:
activate in interface Activatable

targetChanged

public void targetChanged(java.lang.Object pObject)
Called if the target Proxy that this link is observing is changed.

Specified by:
targetChanged in interface EndpointObserver
Parameters:
pObject - - The changed proxied value

sourceChanged

public void sourceChanged(java.lang.Object pObject)
Called if the source Proxy that this link is observing is changed.

Specified by:
sourceChanged in interface EndpointObserver
Parameters:
pObject - - The changed proxied value

isActivateOnSetSource

public boolean isActivateOnSetSource()
Specified by:
isActivateOnSetSource in interface Link
Returns:
code if the link activates on set source
See Also:
Link.isActivateOnSetSource()

setActivateOnSetSource

public void setActivateOnSetSource(boolean pIsActivate)
Specified by:
setActivateOnSetSource in interface Link
Parameters:
pIsActivate - - true to activate the link on setSource()
See Also:
Link.setActivateOnSetSource(boolean)