LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.data
Class LyWorkSpace

java.lang.Object
  extended by leon.data.LyObjectList
      extended by leon.data.LyWorkSpace
All Implemented Interfaces:
LyGetSessionInterface, LyAdvancedDataSourceListener, LyDataSourceListener
Direct Known Subclasses:
LyClassWorkSpace, LyMultiClassWorkSpace, LyMultiWorkSpace, LySimpleWorkSpace, LyStepWorkSpace, LySubWorkSpace

public abstract class LyWorkSpace
extends LyObjectList
implements LyAdvancedDataSourceListener, LyGetSessionInterface

This class implements workspaces. Workspaces are dynamic objects lists : lists that send events to listeners when their content changes.

A workspace is constructed within a session and is only accessible in that session.

Different types of workspaces are provided, they are implemented as subclasses of this abstract class and correspond to different needs (see inherited classes).

A workspace can be local, that is all objects are searched from memory.

When workspaces are not used anymore, they should be freed via free method to release resources they use to keep themselves up to date. This point is rather important because if they are not freed, they can't be removed by garbage collector and may still use memory and CPU for nothing.

See Also:
LyWorkSpaceEvent, LyAdvancedWorkSpaceEvent, LyWorkSpaceListener, LyAdvancedWorkSpaceListener

Field Summary
static java.lang.String __VERSION
           
 
Method Summary
 void addList(LyObjectList list)
          Adds objects of the specified list to this list.
 void addListener(LyWorkSpaceListener listener)
          Adds a listener on this workspace.
 boolean dataSourceEventsGrouped(java.util.ArrayList<LyDataSourceEvent> events)
          Called when grouped events are sent.
 boolean free(LyWorkSpaceListener listener)
          Remove the given listener of this workspace and free workspace if this listener was the last.
 LyWorkSpaceListener getListener(int index)
          Gets listener at the given position.
 int getListenerCount()
          Gets number of listeners of this workspace.
 LyDataSession getSession()
          Gets session on which this workspace was built.
 LySimpleObjectList getSources(LyObject target)
          Method for retrieving source objects that lead to given target object.
 boolean isDynamic()
          Checks whether this workspace is dynamic or not.
 boolean isLocal()
          Checks whether this workspace is local or not.
 void lock()
          Lock this workspace.
 boolean objectCreated(LyDataSourceEvent event)
          Method for receiving an object creation.
 boolean objectDeleted(LyDataSourceEvent event)
          Method for receiving an object deletion.
 boolean objectModified(LyDataSourceEvent event)
          Method for receiving an object modification.
 boolean objectStateChanged(LyAdvancedDataSourceEvent event)
          Called when an object state is changed.
 boolean objectUserEvent(LyAdvancedDataSourceEvent event)
          Method for receiving user event on an object.
 void removeListener(LyWorkSpaceListener listener)
          Removes a listener on this workspace.
 void reset()
          Method for resetting a workspace.
 void unlock()
          Unlock this workspace.
 
Methods inherited from class leon.data.LyObjectList
contains, delete, delete, equals, equals, getClasses, getIndex, getIntersection, getList, getList, getList, getList, getList, getList, getList, getList, getList, getList, getList, getList, getObject, getObject, getObject, getObjects, getSize, getSize, getSort, getSortedList, indexOf, intersects, isEmpty, isSorted, iterator, set, setSort, setSortByName, setSorted, toObjectIds, toString
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values
Method Detail

free

public final boolean free(LyWorkSpaceListener listener)
Remove the given listener of this workspace and free workspace if this listener was the last.

Parameters:
listener - Removed listener.
Returns:
Returns a boolean indicating if the workspace was freed or not.

lock

public void lock()
Lock this workspace. A locked workspace can't be freed.

See Also:
unlock()

unlock

public void unlock()
Unlock this workspace.

See Also:
lock()

reset

public void reset()
Method for resetting a workspace. By default, this method clears the content of the workspace. But depending on the type of workspace, this method may recompute the entire content of the workspace.

Overrides:
reset in class LyObjectList

isDynamic

public final boolean isDynamic()
Checks whether this workspace is dynamic or not.

Overrides:
isDynamic in class LyObjectList
Returns:
True if the workspace is dynamic, false otherwise.

isLocal

public final boolean isLocal()
Checks whether this workspace is local or not.

Returns:
True if the workspace is local, false otherwise.

getSession

public final LyDataSession getSession()
Gets session on which this workspace was built.

Specified by:
getSession in interface LyGetSessionInterface
Returns:
The session of this workspace.

getListener

public LyWorkSpaceListener getListener(int index)
Gets listener at the given position.


getListenerCount

public int getListenerCount()
Gets number of listeners of this workspace.


addListener

public void addListener(LyWorkSpaceListener listener)
Adds a listener on this workspace.

Parameters:
listener - Listener to register.
IllegalStateException - If this workspace is not dynamic.
IllegalArgumentException - If the given listener is null.

removeListener

public void removeListener(LyWorkSpaceListener listener)
Removes a listener on this workspace.

Parameters:
listener - Listener to unregister.
IllegalStateException - If this workspace is not dynamic or if the given listener is not registered as listener of this workspace.
IllegalArgumentException - If the given listener is null.

addList

public void addList(LyObjectList list)
Adds objects of the specified list to this list. This method may be inherited by subclasses to change its behavior.

It's overriden from LyObjectList to throw an exception if this workspace is dynamic since we won't known how to recompute it anymore.

Overrides:
addList in class LyObjectList
Parameters:
objectList - Objects to add to this list.
Throws:
java.lang.IllegalStateException - If this workspace is dynamic.

objectCreated

public boolean objectCreated(LyDataSourceEvent event)
Method for receiving an object creation. Adds the object concerned by the event in this workspace if it was not already in.

Specified by:
objectCreated in interface LyDataSourceListener
Parameters:
event - Event notifying the creation of an object.
Returns:
True indicating if the event was used, false otherwise.

objectDeleted

public boolean objectDeleted(LyDataSourceEvent event)
Method for receiving an object deletion. Removes the object concerned by the event if it is found in this workspace.

Specified by:
objectDeleted in interface LyDataSourceListener
Parameters:
event - Event notifying the deletion of an object.
Returns:
True indicating if the event was used, false otherwise.

objectModified

public boolean objectModified(LyDataSourceEvent event)
Method for receiving an object modification. Changes the object concerned by the event if it is found in this workspace.

Specified by:
objectModified in interface LyDataSourceListener
Parameters:
event - Event notifying the modification of an object.
Returns:
True indicating if the event was used, false otherwise.

objectStateChanged

public boolean objectStateChanged(LyAdvancedDataSourceEvent event)
Called when an object state is changed.

Specified by:
objectStateChanged in interface LyAdvancedDataSourceListener
Parameters:
event - Event notifying object state change.
Returns:
True if the event is used by the listener, false otherwise.

objectUserEvent

public boolean objectUserEvent(LyAdvancedDataSourceEvent event)
Method for receiving user event on an object.

Specified by:
objectUserEvent in interface LyAdvancedDataSourceListener
Parameters:
event - Event notifying the user event of an object.
Returns:
True indicating if the event was used, false otherwise.

dataSourceEventsGrouped

public boolean dataSourceEventsGrouped(java.util.ArrayList<LyDataSourceEvent> events)
Called when grouped events are sent.

Specified by:
dataSourceEventsGrouped in interface LyAdvancedDataSourceListener
Parameters:
events - Sorted list of events.
Returns:
True if the events are used by the listener, false otherwise.

getSources

public LySimpleObjectList getSources(LyObject target)
Method for retrieving source objects that lead to given target object.

Parameters:
target - Target object
Returns:
Source objects that leade to target object.

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com