org.caleigo.core
Class ProxySelection

java.lang.Object
  extended byorg.caleigo.core.ProxySelection
All Implemented Interfaces:
IEntityPool, IProxySelection, ISelection, java.io.Serializable
Direct Known Subclasses:
ControlledProxySelection, FilteredProxySelection, OrderedProxySelection

public class ProxySelection
extends java.lang.Object
implements IProxySelection

Version:
1.00
Author:
Dennis Zikovic
See Also:
Serialized Form

Nested Class Summary
protected  class ProxySelection.RelayListener
           
 
Constructor Summary
ProxySelection(IEntityDescriptor entityDescriptor)
          Creates new ProxySelection
ProxySelection(ISelection selection)
          Creates new ProxySelection
 
Method Summary
 boolean addEntity(IEntity entity)
          Adds the provided IEntity object to the end of selection object.
 boolean addEntity(int index, IEntity entity)
          Adds the provided IEntity object to at the specified index in the selection object.
 void addEntityChangeListener(IEntityChangeListener listener)
          Adds IEntityChangeListener to receive notifications of performed data operations on all entities contained in the collection object.
 void addEntityListener(IEntityListener listener)
          Adds IEntityListener to receive notifications of performed data operations on all entities contained in the collection object.
 void addProxyListener(IProxyListener listener)
          Adds an IProxyListener to receive notifications of changes of the remote object.
 void addSelectionListener(ISelectionListener listener)
          Adds an ISelectionListener to receive notifiactions of changes in the entity content of the collection object.
 java.util.List asList()
          Returns a List that acts as a wrapper for the selection.
 java.util.Set asSet()
          Returns a Set that acts as a wrapper for the selection.
 void clear()
          Mutation method the removes all entities currently stored in the selection.
 boolean contains(IEntity entity)
          Help method that returns true if the provided IEntity object exists in the selection otherwise false is returned.
protected  ProxySelection.RelayListener createRelayListener()
          Help method that creates a new relay listener.
 ISelection createSubSelection(int[] indexArray)
          Creates a sub selection with the indexed entities in the called selection.
 ISelection createSubSelection(Qualifier qualifier)
          Creates a sub selection with all qualified entities in the called selection.
 void deleteAll()
          Deletes all contained entities.
protected  void doAfterRemoteChange()
          Empty help method provided for sub class customization.
 boolean doesAccept(IEntity entity)
          Help method that returns true if the provided IEntity object will be accepted by the selection if added or inserted to it.
protected  void fireContentsChanged()
          Help method to fire a SelectionEvent to all registered SelectionListeners for notification of generally changed contents.
protected  void fireEntityAdded(IEntity entity, int row)
          Help method to fire a SelectionEvent to all registered SelectionListeners for notification of an added entity.
protected  void fireEntityRemoved(IEntity entity, int row)
          Help method to fire a SelectionEvent to all registered SelectionListeners for notification of an removed entity.
protected  void fireProxyEvent(int eventType)
          Fires a ProxyEvent with the provided operation type to all registered IProxyListener objects.
protected  void fireStatusChangedEvent(IEntity entity, int statusType, boolean newState)
          Fires an EntityChangeEvent with the provided operation type to all registered IEntityChangeListener objects.
 java.lang.Object getData(int row, int column)
          Access method that views the selection objct as a grid where row is the entity index and column is the field index for the stored entities.
 IEntity getEntity(int index)
          Access method that returns the contained IEntity object with the specified index.
 IEntityDescriptor getEntityDescriptor()
          Access method that returns the IEntityDescriptor for the selection.
protected  ProxySelection.RelayListener getRelayListener()
          Help method that returns the selections relay listener.
 ISelection getRemoteSelection()
          Access method that returns the remote selection of the proxy.
 ISelection getSourceSelection()
          Access method that returns the source selection of the proxy.
 boolean hasRemoteSelection()
          Boolean access method that returns true if the proxy has a remote selection if false then getRemoteSelection() will return null.
 boolean hasSourceSelection()
          Boolean access method that returns true if the proxy has a source selection if false then getSourceSelection() will return null.
 int indexOf(IEntity entity)
          Help method that returns the index of the provided IEntity object in the selection if it exists othewise a negative value is returned.
 int indexOf(IFieldDescriptor fieldDescriptor, java.lang.Object fieldData)
          Help method that returns the index of the the first entity object in the selection with the specified field set to the specified value.
 boolean isDirty()
          Return true if any (one or more) of the collections's contained entities has the DIRTY flag set to true that is have unsaved changes.
 boolean isEmpty()
          Boolean access method that return true if the selection is empty.
 java.util.Iterator iterator()
          Returns a java.util.Iterator object that iterates over all entities in the selection.
 void refreshAll()
          Performs a refresh on all contained entities.
 boolean removeEntity(IEntity entity)
          Mutation method that removes the provided entity from the selection.
 IEntity removeEntity(int index)
          Mutation method that removes the indexed entity from the selection.
 void removeEntityChangeListener(IEntityChangeListener listener)
          Removes the specified IEntityListener from the collection object.
 void removeEntityListener(IEntityListener listener)
          Removes the specified IEntityListener from the collection object.
 void removeProxyListener(IProxyListener listener)
          Removes the specified IProxyListener from the remote object.
 void removeSelectionListener(ISelectionListener listener)
          Removes an ISelectionListener from the collection object.
 void setData(int row, int column, java.lang.Object dataValue)
          Mutation method that views the selection objct as a grid where row is the entity index and column is the field index for the stored entities.
 void setRemoteSelection(ISelection selection)
          Optional mutation method that throws an UnsupportedOperationException if the implementing class does not support the method.
 int size()
          Access method that reurns the number entities currently contained in the selection object.
 void sort(java.util.Comparator comparator)
          This method sorts the called selection using the provided comparator.
 void storeAll()
          Stores all contained entities that have the DIRTY flag set to true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProxySelection

public ProxySelection(IEntityDescriptor entityDescriptor)
Creates new ProxySelection


ProxySelection

public ProxySelection(ISelection selection)
Creates new ProxySelection

Method Detail

isDirty

public boolean isDirty()
Return true if any (one or more) of the collections's contained entities has the DIRTY flag set to true that is have unsaved changes.

Specified by:
isDirty in interface ISelection

storeAll

public void storeAll()
Stores all contained entities that have the DIRTY flag set to true. The entities are stored in a single transaction meaning that if one store fails then all fails.

Specified by:
storeAll in interface ISelection

deleteAll

public void deleteAll()
Deletes all contained entities. The entities are deleted in a single transaction meaning that if one delete fails then all fails. USE THIS METHOD WITH CAUTION.

Specified by:
deleteAll in interface ISelection

refreshAll

public void refreshAll()
Performs a refresh on all contained entities. The refresh is batched to save performance.

Specified by:
refreshAll in interface ISelection

addEntity

public boolean addEntity(IEntity entity)
Adds the provided IEntity object to the end of selection object. If an entity with the same identity already exists in the selection the requeat is ignored and false is returned.

Specified by:
addEntity in interface ISelection

addEntity

public boolean addEntity(int index,
                         IEntity entity)
Adds the provided IEntity object to at the specified index in the selection object. If an entity with the same identity already exists in the selection the requeat is ignored and false is returned.

Specified by:
addEntity in interface ISelection

getEntity

public IEntity getEntity(int index)
Access method that returns the contained IEntity object with the specified index.

Specified by:
getEntity in interface ISelection

removeEntity

public boolean removeEntity(IEntity entity)
Mutation method that removes the provided entity from the selection. Returns true if the entity was found and removed otherwise false is returned.

Specified by:
removeEntity in interface ISelection

removeEntity

public IEntity removeEntity(int index)
Mutation method that removes the indexed entity from the selection. Returns the indexed entity if it was found and removed otherwise null is returned. The entities are not effecte in any other way.

Specified by:
removeEntity in interface ISelection

iterator

public java.util.Iterator iterator()
Returns a java.util.Iterator object that iterates over all entities in the selection. The iterator should be read only and should not support the remove method. The entities are not effected in any other way.

Specified by:
iterator in interface ISelection

clear

public void clear()
Mutation method the removes all entities currently stored in the selection. The entities are not effected in any other way.

Specified by:
clear in interface ISelection

size

public int size()
Access method that reurns the number entities currently contained in the selection object.

Specified by:
size in interface ISelection

isEmpty

public boolean isEmpty()
Boolean access method that return true if the selection is empty.

Specified by:
isEmpty in interface ISelection

getData

public java.lang.Object getData(int row,
                                int column)
Access method that views the selection objct as a grid where row is the entity index and column is the field index for the stored entities.

Specified by:
getData in interface ISelection

setData

public void setData(int row,
                    int column,
                    java.lang.Object dataValue)
Mutation method that views the selection objct as a grid where row is the entity index and column is the field index for the stored entities.

Specified by:
setData in interface ISelection

getEntityDescriptor

public IEntityDescriptor getEntityDescriptor()
Access method that returns the IEntityDescriptor for the selection. The selection object will only support entities of that type.

Specified by:
getEntityDescriptor in interface ISelection

addSelectionListener

public void addSelectionListener(ISelectionListener listener)
Adds an ISelectionListener to receive notifiactions of changes in the entity content of the collection object.

Specified by:
addSelectionListener in interface ISelection

removeSelectionListener

public void removeSelectionListener(ISelectionListener listener)
Removes an ISelectionListener from the collection object.

Specified by:
removeSelectionListener in interface ISelection

addEntityListener

public void addEntityListener(IEntityListener listener)
Adds IEntityListener to receive notifications of performed data operations on all entities contained in the collection object.

Specified by:
addEntityListener in interface ISelection

removeEntityListener

public void removeEntityListener(IEntityListener listener)
Removes the specified IEntityListener from the collection object.

Specified by:
removeEntityListener in interface ISelection

addEntityChangeListener

public void addEntityChangeListener(IEntityChangeListener listener)
Adds IEntityChangeListener to receive notifications of performed data operations on all entities contained in the collection object. Note that changes can in specific situations like during end-user editation be very frequent.

Specified by:
addEntityChangeListener in interface ISelection

removeEntityChangeListener

public void removeEntityChangeListener(IEntityChangeListener listener)
Removes the specified IEntityListener from the collection object.

Specified by:
removeEntityChangeListener in interface ISelection

createSubSelection

public ISelection createSubSelection(int[] indexArray)
Creates a sub selection with the indexed entities in the called selection. The created selection that should be independant of changes in the source/called selection after the time of creation.

Specified by:
createSubSelection in interface IProxySelection

createSubSelection

public ISelection createSubSelection(Qualifier qualifier)
Creates a sub selection with all qualified entities in the called selection. The created selection that should be independant of changes in the source/called selection after the time of creation.

Specified by:
createSubSelection in interface IProxySelection

contains

public boolean contains(IEntity entity)
Help method that returns true if the provided IEntity object exists in the selection otherwise false is returned.

Specified by:
contains in interface IProxySelection

indexOf

public int indexOf(IEntity entity)
Help method that returns the index of the provided IEntity object in the selection if it exists othewise a negative value is returned.

Specified by:
indexOf in interface ISelection

indexOf

public int indexOf(IFieldDescriptor fieldDescriptor,
                   java.lang.Object fieldData)
Help method that returns the index of the the first entity object in the selection with the specified field set to the specified value.

Specified by:
indexOf in interface ISelection

doesAccept

public boolean doesAccept(IEntity entity)
Help method that returns true if the provided IEntity object will be accepted by the selection if added or inserted to it. Reasons for not accepting an entity is wrong type (IEntityDescriptor), already included or if selection is qualified the entity may fail qualification.

Specified by:
doesAccept in interface ISelection

sort

public void sort(java.util.Comparator comparator)
This method sorts the called selection using the provided comparator. One single content change event will be fired when this method is called. Note that if the provided Comparator does not support IEntity objects an exeption will be thrown.

Specified by:
sort in interface ISelection
See Also:
EntityCollator

asSet

public java.util.Set asSet()
Returns a Set that acts as a wrapper for the selection. The Set object should reflect changes to and from the wrapped selection.

Specified by:
asSet in interface ISelection

asList

public java.util.List asList()
Returns a List that acts as a wrapper for the selection. The List object should reflect changes to and from the wrapped selection.

Specified by:
asList in interface ISelection

hasRemoteSelection

public boolean hasRemoteSelection()
Boolean access method that returns true if the proxy has a remote selection if false then getRemoteSelection() will return null.

Specified by:
hasRemoteSelection in interface IProxySelection

getRemoteSelection

public ISelection getRemoteSelection()
Access method that returns the remote selection of the proxy. May return null if the proxy does not currently have a remote.

Specified by:
getRemoteSelection in interface IProxySelection

hasSourceSelection

public boolean hasSourceSelection()
Boolean access method that returns true if the proxy has a source selection if false then getSourceSelection() will return null.

Specified by:
hasSourceSelection in interface IProxySelection

getSourceSelection

public ISelection getSourceSelection()
Access method that returns the source selection of the proxy. May return null if the proxy does not currently have a source entity.

Specified by:
getSourceSelection in interface IProxySelection

setRemoteSelection

public void setRemoteSelection(ISelection selection)
Optional mutation method that throws an UnsupportedOperationException if the implementing class does not support the method.

Specified by:
setRemoteSelection in interface IProxySelection

addProxyListener

public void addProxyListener(IProxyListener listener)
Adds an IProxyListener to receive notifications of changes of the remote object.

Specified by:
addProxyListener in interface IProxySelection

removeProxyListener

public void removeProxyListener(IProxyListener listener)
Removes the specified IProxyListener from the remote object.

Specified by:
removeProxyListener in interface IProxySelection

fireContentsChanged

protected void fireContentsChanged()
Help method to fire a SelectionEvent to all registered SelectionListeners for notification of generally changed contents.


fireEntityAdded

protected void fireEntityAdded(IEntity entity,
                               int row)
Help method to fire a SelectionEvent to all registered SelectionListeners for notification of an added entity.


fireEntityRemoved

protected void fireEntityRemoved(IEntity entity,
                                 int row)
Help method to fire a SelectionEvent to all registered SelectionListeners for notification of an removed entity.


fireProxyEvent

protected void fireProxyEvent(int eventType)
Fires a ProxyEvent with the provided operation type to all registered IProxyListener objects.


fireStatusChangedEvent

protected void fireStatusChangedEvent(IEntity entity,
                                      int statusType,
                                      boolean newState)
Fires an EntityChangeEvent with the provided operation type to all registered IEntityChangeListener objects.


getRelayListener

protected ProxySelection.RelayListener getRelayListener()
Help method that returns the selections relay listener.


createRelayListener

protected ProxySelection.RelayListener createRelayListener()
Help method that creates a new relay listener. Can be used by subclasses replace or extend the RelayListener.


doAfterRemoteChange

protected void doAfterRemoteChange()
Empty help method provided for sub class customization. The method is called directly after the remote object has been changed but before any listeners has been registered or events been fired.



Copyright © 2005 Caleigo. All Rights Reserved.